[PATCH] D16044: getVariableName() for MemRegion
Alexander Droste via cfe-commits
cfe-commits at lists.llvm.org
Sun Jan 17 12:17:38 PST 2016
Alexander_Droste marked an inline comment as done.
================
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()};
----------------
xazax.hun wrote:
> 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?
Right, `getAs<..::ConcreteInt>()` might return a `nullptr`.
What do you think of including the number if it is a `nonloc::ConcreteInt`,
the name if it is a `nonloc::SymbolValKind` (`getAs<nonloc::SymbolVal>().getSymbol()`)
and else keeping the brackets empty?
================
Comment at: tools/clang/lib/StaticAnalyzer/Core/MemRegion.cpp:656
@@ +655,3 @@
+
+ ArrayIndices = "[" + idx + "]" + ArrayIndices;
+
----------------
xazax.hun wrote:
> 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.
So would be invoking `push_back` within and `reverse` after the loop sufficient?
http://reviews.llvm.org/D16044
More information about the cfe-commits
mailing list