[PATCH] D48522: [analyzer] Highlight c_str() call in DanglingInternalBuffer checker

Artem Dergachev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Jun 23 16:11:15 PDT 2018


NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

Looks good tho!



================
Comment at: lib/StaticAnalyzer/Checkers/DanglingInternalBufferChecker.cpp:63-64
+      RawPtrMapTy Map = State->get<RawPtrMap>();
+      for (const auto Entry : Map) {
+        if (Entry.second == Sym)
+          Found = true;
----------------
Interesting, so we don't have access to the region with which the symbol is associated, so we have to scan the whole map.

Probably we can scan the map only once (eg., in the visitor's consturctor if we also supply the program state) and then do a direct lookup by region?

Because it's a premature optimization, i'm in favor of a FIXME.


================
Comment at: lib/StaticAnalyzer/Checkers/DanglingInternalBufferChecker.cpp:155
+  llvm::raw_svector_ostream OS(Buf);
+  OS << "Dangling buffer was obtained here";
+  PathDiagnosticLocation Pos(S, BRC.getSourceManager(),
----------------
Maybe "pointer to dangling buffer".


https://reviews.llvm.org/D48522





More information about the cfe-commits mailing list