[PATCH] D48522: [analyzer] Highlight c_str() call in DanglingInternalBuffer checker
Gábor Horváth via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Jun 23 12:11:29 PDT 2018
xazax.hun added a comment.
Regarding the visitor:
Maybe rather than looking at the AST, we should check the states, when we started to track the returned symbol?
Using your current design you need to check for the AST twice. Once in the visitor and once in the check.
Also, I wonder if this always give you the right note. Consider the following example:
void deref_after_scope_char() {
const char *c;
{
std::string s;
c = s.c_str();
}
std::string s;
const char *c2 = s.c_str();
consume(c);
}
================
Comment at: lib/StaticAnalyzer/Checkers/DanglingInternalBufferChecker.cpp:149
+
+ if (!(FunI->getName() == "c_str"))
+ return nullptr;
----------------
Why not `!=`?
Repository:
rC Clang
https://reviews.llvm.org/D48522
More information about the cfe-commits
mailing list