[PATCH] D16044: getVariableName() for MemRegion

Gábor Horváth via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 13 05:49:13 PST 2016

xazax.hun added inline comments.

Comment at: tools/clang/lib/StaticAnalyzer/Core/MemRegion.cpp:653
@@ +652,3 @@
+    llvm::SmallString<2> intValAsString;
+    IndexInArray.toString(intValAsString);
+    std::string idx{intValAsString.begin(), intValAsString.end()};
What will be the content of IndexInArray in case the index is not a concrete int? Will the above code work at all in that case? In case the index is a variable do we want to include the name of the variable in the index?

Comment at: tools/clang/lib/StaticAnalyzer/Core/MemRegion.cpp:656
@@ +655,3 @@
+    ArrayIndices = "[" + idx + "]" + ArrayIndices;
I do not really like this part. You could either use Twine to avoid some temporal values (and you could also eliminate the string copy this way) or you could construct the indices using the reverse of idx and than reverse the whole string after the loop.


More information about the cfe-commits mailing list