[clang] [Clang][analyzer] replace Stmt* with ConstCFGElementRef in SymbolConjured (PR #128251)

via cfe-commits cfe-commits at lists.llvm.org
Sun Feb 23 17:26:45 PST 2025


================
@@ -113,8 +113,18 @@ class SValExplainer : public FullSValVisitor<SValExplainer, std::string> {
   }
 
   std::string VisitSymbolConjured(const SymbolConjured *S) {
-    return "symbol of type '" + S->getType().getAsString() +
-           "' conjured at statement '" + printStmt(S->getStmt()) + "'";
+    std::string Str;
+    llvm::raw_string_ostream OS(Str);
+    OS << "symbol of type '" + S->getType().getAsString() +
+              "' conjured at statement '";
+    S->getCFGElementRef()->dumpToStream(OS);
+    // HACK: dumpToStream will output a new line in the end, this is
+    // undesireable, thus we remove it.
+    if (Str.back() == '\n') {
----------------
isuckatcs wrote:

What if we are on windows and the line ending is `\r\n`?

https://github.com/llvm/llvm-project/pull/128251


More information about the cfe-commits mailing list