Fraunhofer-AISEC / cpg

A library to extract Code Property Graphs from C/C++, Java, Go, Python, Ruby and every other language through LLVM-IR.
https://fraunhofer-aisec.github.io/cpg/
Apache License 2.0
277 stars 62 forks source link

Support multiple vars in a forloop #1702

Open maximiliankaul opened 4 hours ago

maximiliankaul commented 4 hours ago
for a, b in foo:
  pass

should be correctly modeled in the CPG.

We decided to introduce a dummy variable in the loop itself (as the CPG does not support multiple vars here) and then introduce an a, b = dummy assignment at the top of the body.

:warning: This is "easy" for known variables but we have to consider where to store declarations for new variables.

oxisto commented 4 hours ago

⚠️ This is "easy" for known variables but we have to consider where to store declarations for new variables.

Actually this would be already taken care of in the existing code of the assignment expression / the python extra pass. That's the added advantage of using this "fake" assignment here.