[PATCH] [analyzer][Review request] Improved checker naming in CFG dump.

Антон Ярцев anton.yartsev at gmail.com
Thu Feb 13 15:59:24 PST 2014


  Sure. Not immediately found the proper means for concatenation. Here is the new patch.

Hi jordan_rose, zaks.anna,

http://llvm-reviews.chandlerc.com/D2793

CHANGE SINCE LAST DIFF
  http://llvm-reviews.chandlerc.com/D2793?vs=7094&id=7100#toc

Files:
  include/clang/Analysis/ProgramPoint.h
  lib/Analysis/ProgramPoint.cpp
  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: include/clang/Analysis/ProgramPoint.h
===================================================================
--- include/clang/Analysis/ProgramPoint.h
+++ include/clang/Analysis/ProgramPoint.h
@@ -662,7 +662,7 @@
 class SimpleProgramPointTag : public ProgramPointTag {
   std::string desc;
 public:
-  SimpleProgramPointTag(StringRef description);
+  SimpleProgramPointTag(const Twine &description);
   StringRef getTagDescription() const;
 };
 
Index: lib/Analysis/ProgramPoint.cpp
===================================================================
--- lib/Analysis/ProgramPoint.cpp
+++ lib/Analysis/ProgramPoint.cpp
@@ -43,8 +43,8 @@
   }
 }
 
-SimpleProgramPointTag::SimpleProgramPointTag(StringRef description)
-  : desc(description) {}
+SimpleProgramPointTag::SimpleProgramPointTag(const Twine &description)
+  : desc(description.str()) {}
 
 StringRef SimpleProgramPointTag::getTagDescription() const {
   return desc;
Index: lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
+++ lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
@@ -455,7 +455,7 @@
                                               ProgramStateRef state,
                                               const ObjCMethodCall &Msg) const {
   ASTContext &Ctx = C.getASTContext();
-  static SimpleProgramPointTag Tag("CallAndMessageChecker : NilReceiver");
+  static SimpleProgramPointTag Tag(getCheckName().getName() + " : NilReceiver");
 
   // 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,8 @@
     return;
   }
 
-  static SimpleProgramPointTag Tag("MacOSKeychainAPIChecker : DeadSymbolsLeak");
+  static SimpleProgramPointTag 
+         Tag(getCheckName().getName() + " : DeadSymbolsLeak");
   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,8 @@
   // Generate leak node.
   ExplodedNode *N = C.getPredecessor();
   if (!Errors.empty()) {
-    static SimpleProgramPointTag Tag("MallocChecker : DeadSymbolsLeak");
+    static SimpleProgramPointTag 
+           Tag(getCheckName().getName() + " : DeadSymbolsLeak");
     N = C.addTransition(C.getState(), C.getPredecessor(), &Tag);
     for (SmallVectorImpl<SymbolRef>::iterator
            I = Errors.begin(), E = Errors.end(); I != E; ++I) {
@@ -2251,7 +2252,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,8 @@
     return;
 
   // Update the autorelease counts.
-  static SimpleProgramPointTag
-         AutoreleaseTag("RetainCountChecker : Autorelease");
+  static SimpleProgramPointTag 
+         AutoreleaseTag(getCheckName().getName() + " : Autorelease");
   state = handleAutoreleaseCounts(state, Pred, &AutoreleaseTag, C, Sym, X);
 
   // Did we cache out?
@@ -3320,8 +3320,8 @@
         // Generate an error node.
         state = setRefBinding(state, Sym, X);
 
-        static SimpleProgramPointTag
-               ReturnOwnLeakTag("RetainCountChecker : ReturnsOwnLeak");
+        static SimpleProgramPointTag 
+               ReturnOwnLeakTag(getCheckName().getName() + " : ReturnsOwnLeak");
         ExplodedNode *N = C.addTransition(state, Pred, &ReturnOwnLeakTag);
         if (N) {
           const LangOptions &LOpts = C.getASTContext().getLangOpts();
@@ -3341,8 +3341,8 @@
       // owned object.
       state = setRefBinding(state, Sym, X ^ RefVal::ErrorReturnedNotOwned);
 
-      static SimpleProgramPointTag
-             ReturnNotOwnedTag("RetainCountChecker : ReturnNotOwnedForOwned");
+      static SimpleProgramPointTag 
+             ReturnNotOwnedTag(getCheckName().getName() + " : ReturnNotOwnedForOwned");
       ExplodedNode *N = C.addTransition(state, Pred, &ReturnNotOwnedTag);
       if (N) {
         if (!returnNotOwnedForOwned)
@@ -3632,7 +3632,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.2.patch
Type: text/x-patch
Size: 6237 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140213/0fa94b0c/attachment.bin>


More information about the cfe-commits mailing list