[PATCH] D15924: [analyzer] Utility to extract the variable name from a memory region.

Alexander Droste via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 6 08:06:49 PST 2016


Alexander_Droste added inline comments.

================
Comment at: lib/StaticAnalyzer/Core/MemRegion.cpp:586
@@ +585,3 @@
+    return "";
+  return nd->getName();
+}
----------------
Isn't calling `getDecl()` and `getName()` afterwards identical to `printPretty()`?
Is it possible that a `NamedDecl` cannot be obtained from a `DeclRegion`?

================
Comment at: lib/StaticAnalyzer/Core/MemRegion.cpp:588
@@ -576,1 +587,3 @@
+}
+
 void MemRegion::printPretty(raw_ostream &os) const {
----------------
Regarding the MPI-Checker patch http://reviews.llvm.org/D12761 it is insufficient 
if the array index (if obtainable) is not provided. 
I think it would be nice if a `getVariableName` function could always provide as much
information as possible, regarding the passed memory region. Do you actually see a case in 
the other implementation where this function fails?
The index is a member variable of the `ElementRegion` why obtaining that
value cannot fail. If the memory region passed is no `ElementRegion` then 
simply `printPretty()` is called. I could submit the patch right away if this helps.





http://reviews.llvm.org/D15924





More information about the cfe-commits mailing list