Extend MallocBugVisitor to place a note at the point where objects with AF_InternalBuffer allocation family are destroyed.
Details
Diff Detail
Event Timeline
lib/StaticAnalyzer/Checkers/MallocChecker.cpp | ||
---|---|---|
484–490 | To be honest, I am not sure what was the purpose of the AST based checks in the original version. IMHO, looking at the states only should be sufficient without examining the AST. | |
2921 | I think these messages should be full sentences starting with a capital letter and ending with a period. | |
2994 | This new code should only be used for AF_InternalBuffer allocation family? If that is the case, maybe adding an assert here and running it on some large codebases to se if this is triggered would be great. | |
2995 | LLVM's optional can implicitly convert to bool. I think it is perfectly fine to rely on the implicit conversion here. |
Only minor nits, as usual :)
lib/StaticAnalyzer/Checkers/MallocChecker.cpp | ||
---|---|---|
484–490 | Yeah, same. I guess we could replace the check with an assertion (i.e. if there's statement, it's a call or delete-expression and it's AF_InternalBuffer), and see if anything crashes. | |
2867–2869 | I don't think our check will be limited to STL containers only. We might cover other containers as well, such as LLVM or WebKit custom strings and string views. | |
2921 | Or exclamantion mark! :) | |
2997 | PostImplCall->getLocation(). |
Thanks for the comments!
I'll run this on some projects and see if any assertions fail.
To be honest, I am not sure what was the purpose of the AST based checks in the original version. IMHO, looking at the states only should be sufficient without examining the AST.