[PATCH] [analyzer][Review request] Improved checker naming in CFG dump.
Антон Ярцев
anton.yartsev at gmail.com
Thu Feb 13 15:07:12 PST 2014
Hi jordan_rose, zaks.anna,
The patch implements FIXME from Checker.cpp (FIXME: We want to return the package + name of the checker here.) and replaces hardcoded checker names with the new one obtained via getCheckName().getName().
http://llvm-reviews.chandlerc.com/D2793
Files:
lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp
lib/StaticAnalyzer/Checkers/MallocChecker.cpp
lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp
lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
lib/StaticAnalyzer/Core/Checker.cpp
Index: lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
+++ lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
@@ -455,7 +455,10 @@
ProgramStateRef state,
const ObjCMethodCall &Msg) const {
ASTContext &Ctx = C.getASTContext();
- static SimpleProgramPointTag Tag("CallAndMessageChecker : NilReceiver");
+ SmallString<55> TagBuf;
+ llvm::raw_svector_ostream TagOs(TagBuf);
+ TagOs << getCheckName().getName() << " : NilReceiver";
+ static SimpleProgramPointTag Tag(TagOs.str());
// Check the return type of the message expression. A message to nil will
// return different values depending on the return type and the architecture.
Index: lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp
+++ lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp
@@ -575,7 +575,10 @@
return;
}
- static SimpleProgramPointTag Tag("MacOSKeychainAPIChecker : DeadSymbolsLeak");
+ SmallString<55> TagBuf;
+ llvm::raw_svector_ostream TagOs(TagBuf);
+ TagOs << getCheckName().getName() << " : DeadSymbolsLeak";
+ static SimpleProgramPointTag Tag(TagOs.str());
ExplodedNode *N = C.addTransition(C.getState(), C.getPredecessor(), &Tag);
// Generate the error reports.
Index: lib/StaticAnalyzer/Checkers/MallocChecker.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -1738,7 +1738,10 @@
// Generate leak node.
ExplodedNode *N = C.getPredecessor();
if (!Errors.empty()) {
- static SimpleProgramPointTag Tag("MallocChecker : DeadSymbolsLeak");
+ SmallString<55> TagBuf;
+ llvm::raw_svector_ostream TagOs(TagBuf);
+ TagOs << getCheckName().getName() << " : DeadSymbolsLeak";
+ static SimpleProgramPointTag Tag(TagOs.str());
N = C.addTransition(C.getState(), C.getPredecessor(), &Tag);
for (SmallVectorImpl<SymbolRef>::iterator
I = Errors.begin(), E = Errors.end(); I != E; ++I) {
@@ -2251,7 +2254,7 @@
RegionStateTy RS = State->get<RegionState>();
if (!RS.isEmpty()) {
- Out << Sep << "MallocChecker:" << NL;
+ Out << Sep << getCheckName().getName() << " :" << NL;
for (RegionStateTy::iterator I = RS.begin(), E = RS.end(); I != E; ++I) {
I.getKey()->dumpToStream(Out);
Out << " : ";
Index: lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp
+++ lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp
@@ -350,7 +350,7 @@
if (FlagMap.isEmpty() && !DidCallInit && !PreCallFlags)
return;
- Out << Sep << NL << "ObjCSelfInitChecker:" << NL;
+ Out << Sep << NL << getCheckName().getName() << " :" << NL;
if (DidCallInit)
Out << " An init method has been called." << NL;
Index: lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
+++ lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
@@ -3258,8 +3258,10 @@
return;
// Update the autorelease counts.
- static SimpleProgramPointTag
- AutoreleaseTag("RetainCountChecker : Autorelease");
+ SmallString<55> TagBuf;
+ llvm::raw_svector_ostream TagOs(TagBuf);
+ TagOs << getCheckName().getName() << " : Autorelease";
+ static SimpleProgramPointTag AutoreleaseTag(TagOs.str());
state = handleAutoreleaseCounts(state, Pred, &AutoreleaseTag, C, Sym, X);
// Did we cache out?
@@ -3320,8 +3322,10 @@
// Generate an error node.
state = setRefBinding(state, Sym, X);
- static SimpleProgramPointTag
- ReturnOwnLeakTag("RetainCountChecker : ReturnsOwnLeak");
+ SmallString<55> TagBuf;
+ llvm::raw_svector_ostream TagOs(TagBuf);
+ TagOs << getCheckName().getName() << " : ReturnsOwnLeak";
+ static SimpleProgramPointTag ReturnOwnLeakTag(TagOs.str());
ExplodedNode *N = C.addTransition(state, Pred, &ReturnOwnLeakTag);
if (N) {
const LangOptions &LOpts = C.getASTContext().getLangOpts();
@@ -3341,8 +3345,10 @@
// owned object.
state = setRefBinding(state, Sym, X ^ RefVal::ErrorReturnedNotOwned);
- static SimpleProgramPointTag
- ReturnNotOwnedTag("RetainCountChecker : ReturnNotOwnedForOwned");
+ SmallString<55> TagBuf;
+ llvm::raw_svector_ostream TagOs(TagBuf);
+ TagOs << getCheckName().getName() << " : ReturnNotOwnedForOwned";
+ static SimpleProgramPointTag ReturnNotOwnedTag(TagOs.str());
ExplodedNode *N = C.addTransition(state, Pred, &ReturnNotOwnedTag);
if (N) {
if (!returnNotOwnedForOwned)
@@ -3632,7 +3638,7 @@
if (!tag) {
SmallString<64> buf;
llvm::raw_svector_ostream out(buf);
- out << "RetainCountChecker : Dead Symbol : ";
+ out << getCheckName().getName() << " : Dead Symbol : ";
sym->dumpToStream(out);
tag = new SimpleProgramPointTag(out.str());
}
Index: lib/StaticAnalyzer/Core/Checker.cpp
===================================================================
--- lib/StaticAnalyzer/Core/Checker.cpp
+++ lib/StaticAnalyzer/Core/Checker.cpp
@@ -18,8 +18,7 @@
using namespace ento;
StringRef CheckerBase::getTagDescription() const {
- // FIXME: We want to return the package + name of the checker here.
- return "A Checker";
+ return getCheckName().getName();
}
CheckName CheckerBase::getCheckName() const { return Name; }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2793.1.patch
Type: text/x-patch
Size: 5864 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140213/40d6ae51/attachment.bin>
More information about the cfe-commits
mailing list