[cfe-commits] r90086 - in /cfe/trunk: include/clang/Analysis/PathSensitive/BugReporter.h include/clang/Analysis/PathSensitive/BugType.h lib/Analysis/BugReporter.cpp lib/Analysis/CFRefCount.cpp lib/Analysis/CheckDeadStores.cpp lib/Analysis/CheckObjCDealloc.cpp lib/Analysis/CheckObjCInstMethSignature.cpp lib/Analysis/CheckObjCUnusedIVars.cpp lib/Analysis/CheckSecuritySyntaxOnly.cpp lib/Analysis/NSErrorChecker.cpp

Ted Kremenek kremenek at apple.com
Sun Nov 29 21:07:46 PST 2009


Awesome!

On Nov 29, 2009, at 10:27 AM, Benjamin Kramer wrote:

> Author: d0k
> Date: Sun Nov 29 12:27:55 2009
> New Revision: 90086
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=90086&view=rev
> Log:
> Port BugReporter and BugType to StringRef.
> 
> Modified:
>    cfe/trunk/include/clang/Analysis/PathSensitive/BugReporter.h
>    cfe/trunk/include/clang/Analysis/PathSensitive/BugType.h
>    cfe/trunk/lib/Analysis/BugReporter.cpp
>    cfe/trunk/lib/Analysis/CFRefCount.cpp
>    cfe/trunk/lib/Analysis/CheckDeadStores.cpp
>    cfe/trunk/lib/Analysis/CheckObjCDealloc.cpp
>    cfe/trunk/lib/Analysis/CheckObjCInstMethSignature.cpp
>    cfe/trunk/lib/Analysis/CheckObjCUnusedIVars.cpp
>    cfe/trunk/lib/Analysis/CheckSecuritySyntaxOnly.cpp
>    cfe/trunk/lib/Analysis/NSErrorChecker.cpp
> 
> Modified: cfe/trunk/include/clang/Analysis/PathSensitive/BugReporter.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/BugReporter.h?rev=90086&r1=90085&r2=90086&view=diff
> 
> ==============================================================================
> --- cfe/trunk/include/clang/Analysis/PathSensitive/BugReporter.h (original)
> +++ cfe/trunk/include/clang/Analysis/PathSensitive/BugReporter.h Sun Nov 29 12:27:55 2009
> @@ -309,32 +309,33 @@
> 
>   void EmitReport(BugReport *R);
> 
> -  void EmitBasicReport(const char* BugName, const char* BugStr,
> +  void EmitBasicReport(llvm::StringRef BugName, llvm::StringRef BugStr,
>                        SourceLocation Loc,
>                        SourceRange* RangeBeg, unsigned NumRanges);
> 
> -  void EmitBasicReport(const char* BugName, const char* BugCategory,
> -                       const char* BugStr, SourceLocation Loc,
> +  void EmitBasicReport(llvm::StringRef BugName, llvm::StringRef BugCategory,
> +                       llvm::StringRef BugStr, SourceLocation Loc,
>                        SourceRange* RangeBeg, unsigned NumRanges);
> 
> 
> -  void EmitBasicReport(const char* BugName, const char* BugStr,
> +  void EmitBasicReport(llvm::StringRef BugName, llvm::StringRef BugStr,
>                        SourceLocation Loc) {
>     EmitBasicReport(BugName, BugStr, Loc, 0, 0);
>   }
> 
> -  void EmitBasicReport(const char* BugName, const char* BugCategory,
> -                       const char* BugStr, SourceLocation Loc) {
> +  void EmitBasicReport(llvm::StringRef BugName, llvm::StringRef BugCategory,
> +                       llvm::StringRef BugStr, SourceLocation Loc) {
>     EmitBasicReport(BugName, BugCategory, BugStr, Loc, 0, 0);
>   }
> 
> -  void EmitBasicReport(const char* BugName, const char* BugStr,
> +  void EmitBasicReport(llvm::StringRef BugName, llvm::StringRef BugStr,
>                        SourceLocation Loc, SourceRange R) {
>     EmitBasicReport(BugName, BugStr, Loc, &R, 1);
>   }
> 
> -  void EmitBasicReport(const char* BugName, const char* Category,
> -                       const char* BugStr, SourceLocation Loc, SourceRange R) {
> +  void EmitBasicReport(llvm::StringRef BugName, llvm::StringRef Category,
> +                       llvm::StringRef BugStr, SourceLocation Loc,
> +                       SourceRange R) {
>     EmitBasicReport(BugName, Category, BugStr, Loc, &R, 1);
>   }
> 
> @@ -432,7 +433,7 @@
>   std::list<std::string> Strs;
>   FullSourceLoc L;
> public:
> -  DiagBugReport(BugType& D, const char* desc, FullSourceLoc l) :
> +  DiagBugReport(BugType& D, llvm::StringRef desc, FullSourceLoc l) :
>   RangedBugReport(D, desc, 0), L(l) {}
> 
>   virtual ~DiagBugReport() {}
> 
> Modified: cfe/trunk/include/clang/Analysis/PathSensitive/BugType.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/BugType.h?rev=90086&r1=90085&r2=90086&view=diff
> 
> ==============================================================================
> --- cfe/trunk/include/clang/Analysis/PathSensitive/BugType.h (original)
> +++ cfe/trunk/include/clang/Analysis/PathSensitive/BugType.h Sun Nov 29 12:27:55 2009
> @@ -34,7 +34,7 @@
>   friend class BugReporter;
>   bool SuppressonSink;
> public:
> -  BugType(const char *name, const char* cat)
> +  BugType(llvm::StringRef name, llvm::StringRef cat)
>     : Name(name), Category(cat), SuppressonSink(false) {}
>   virtual ~BugType();
> 
> 
> Modified: cfe/trunk/lib/Analysis/BugReporter.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/BugReporter.cpp?rev=90086&r1=90085&r2=90086&view=diff
> 
> ==============================================================================
> --- cfe/trunk/lib/Analysis/BugReporter.cpp (original)
> +++ cfe/trunk/lib/Analysis/BugReporter.cpp Sun Nov 29 12:27:55 2009
> @@ -1835,14 +1835,15 @@
>   PD->HandlePathDiagnostic(D.take());
> }
> 
> -void BugReporter::EmitBasicReport(const char* name, const char* str,
> +void BugReporter::EmitBasicReport(llvm::StringRef name, llvm::StringRef str,
>                                   SourceLocation Loc,
>                                   SourceRange* RBeg, unsigned NumRanges) {
>   EmitBasicReport(name, "", str, Loc, RBeg, NumRanges);
> }
> 
> -void BugReporter::EmitBasicReport(const char* name, const char* category,
> -                                  const char* str, SourceLocation Loc,
> +void BugReporter::EmitBasicReport(llvm::StringRef name,
> +                                  llvm::StringRef category,
> +                                  llvm::StringRef str, SourceLocation Loc,
>                                   SourceRange* RBeg, unsigned NumRanges) {
> 
>   // 'BT' will be owned by BugReporter as soon as we call 'EmitReport'.
> 
> Modified: cfe/trunk/lib/Analysis/CFRefCount.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFRefCount.cpp?rev=90086&r1=90085&r2=90086&view=diff
> 
> ==============================================================================
> --- cfe/trunk/lib/Analysis/CFRefCount.cpp (original)
> +++ cfe/trunk/lib/Analysis/CFRefCount.cpp Sun Nov 29 12:27:55 2009
> @@ -2098,7 +2098,7 @@
>   protected:
>     CFRefCount& TF;
> 
> -    CFRefBug(CFRefCount* tf, const char* name)
> +    CFRefBug(CFRefCount* tf, llvm::StringRef name)
>     : BugType(name, "Memory (Core Foundation/Objective-C)"), TF(*tf) {}
>   public:
> 
> @@ -2175,7 +2175,7 @@
>   class Leak : public CFRefBug {
>     const bool isReturn;
>   protected:
> -    Leak(CFRefCount* tf, const char* name, bool isRet)
> +    Leak(CFRefCount* tf, llvm::StringRef name, bool isRet)
>     : CFRefBug(tf, name), isReturn(isRet) {}
>   public:
> 
> @@ -2186,13 +2186,13 @@
> 
>   class LeakAtReturn : public Leak {
>   public:
> -    LeakAtReturn(CFRefCount* tf, const char* name)
> +    LeakAtReturn(CFRefCount* tf, llvm::StringRef name)
>     : Leak(tf, name, true) {}
>   };
> 
>   class LeakWithinFunction : public Leak {
>   public:
> -    LeakWithinFunction(CFRefCount* tf, const char* name)
> +    LeakWithinFunction(CFRefCount* tf, llvm::StringRef name)
>     : Leak(tf, name, false) {}
>   };
> 
> @@ -2210,7 +2210,7 @@
>       : RangedBugReport(D, D.getDescription(), n), Sym(sym), TF(tf) {}
> 
>     CFRefReport(CFRefBug& D, const CFRefCount &tf,
> -                ExplodedNode *n, SymbolRef sym, const char* endText)
> +                ExplodedNode *n, SymbolRef sym, llvm::StringRef endText)
>       : RangedBugReport(D, D.getDescription(), endText, n), Sym(sym), TF(tf) {}
> 
>     virtual ~CFRefReport() {}
> @@ -3466,7 +3466,7 @@
> 
>     CFRefReport *report =
>       new CFRefReport(*static_cast<CFRefBug*>(overAutorelease),
> -                      *this, N, Sym, os.str().c_str());
> +                      *this, N, Sym, os.str());
>     BR->EmitReport(report);
>   }
> 
> 
> Modified: cfe/trunk/lib/Analysis/CheckDeadStores.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CheckDeadStores.cpp?rev=90086&r1=90085&r2=90086&view=diff
> 
> ==============================================================================
> --- cfe/trunk/lib/Analysis/CheckDeadStores.cpp (original)
> +++ cfe/trunk/lib/Analysis/CheckDeadStores.cpp Sun Nov 29 12:27:55 2009
> @@ -76,7 +76,7 @@
>         break;
>     }
> 
> -    BR.EmitBasicReport(BugType, "Dead store", msg.c_str(), L, R);
> +    BR.EmitBasicReport(BugType, "Dead store", msg, L, R);
>   }
> 
>   void CheckVarDecl(VarDecl* VD, Expr* Ex, Expr* Val,
> 
> Modified: cfe/trunk/lib/Analysis/CheckObjCDealloc.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CheckObjCDealloc.cpp?rev=90086&r1=90085&r2=90086&view=diff
> 
> ==============================================================================
> --- cfe/trunk/lib/Analysis/CheckObjCDealloc.cpp (original)
> +++ cfe/trunk/lib/Analysis/CheckObjCDealloc.cpp Sun Nov 29 12:27:55 2009
> @@ -169,7 +169,7 @@
>     os << "Objective-C class '" << D->getNameAsString()
>        << "' lacks a 'dealloc' instance method";
> 
> -    BR.EmitBasicReport(name, os.str().c_str(), D->getLocStart());
> +    BR.EmitBasicReport(name, os.str(), D->getLocStart());
>     return;
>   }
> 
> @@ -187,7 +187,7 @@
>        << "' does not send a 'dealloc' message to its super class"
>            " (missing [super dealloc])";
> 
> -    BR.EmitBasicReport(name, os.str().c_str(), D->getLocStart());
> +    BR.EmitBasicReport(name, os.str(), D->getLocStart());
>     return;
>   }
> 
> @@ -251,8 +251,7 @@
>               "but was released in 'dealloc'";
>       }
> 
> -      BR.EmitBasicReport(name, category,
> -                         os.str().c_str(), (*I)->getLocation());
> +      BR.EmitBasicReport(name, category, os.str(), (*I)->getLocation());
>     }
>   }
> }
> 
> Modified: cfe/trunk/lib/Analysis/CheckObjCInstMethSignature.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CheckObjCInstMethSignature.cpp?rev=90086&r1=90085&r2=90086&view=diff
> 
> ==============================================================================
> --- cfe/trunk/lib/Analysis/CheckObjCInstMethSignature.cpp (original)
> +++ cfe/trunk/lib/Analysis/CheckObjCInstMethSignature.cpp Sun Nov 29 12:27:55 2009
> @@ -65,7 +65,7 @@
>           "behavior for clients of these classes.";
> 
>     BR.EmitBasicReport("Incompatible instance method return type",
> -                       os.str().c_str(), MethDerived->getLocStart());
> +                       os.str(), MethDerived->getLocStart());
>   }
> }
> 
> 
> Modified: cfe/trunk/lib/Analysis/CheckObjCUnusedIVars.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CheckObjCUnusedIVars.cpp?rev=90086&r1=90085&r2=90086&view=diff
> 
> ==============================================================================
> --- cfe/trunk/lib/Analysis/CheckObjCUnusedIVars.cpp (original)
> +++ cfe/trunk/lib/Analysis/CheckObjCUnusedIVars.cpp Sun Nov 29 12:27:55 2009
> @@ -157,6 +157,6 @@
>             "(although it may be used by category methods).";
> 
>       BR.EmitBasicReport("Unused instance variable", "Optimization",
> -                         os.str().c_str(), I->first->getLocation());
> +                         os.str(), I->first->getLocation());
>     }
> }
> 
> Modified: cfe/trunk/lib/Analysis/CheckSecuritySyntaxOnly.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CheckSecuritySyntaxOnly.cpp?rev=90086&r1=90085&r2=90086&view=diff
> 
> ==============================================================================
> --- cfe/trunk/lib/Analysis/CheckSecuritySyntaxOnly.cpp (original)
> +++ cfe/trunk/lib/Analysis/CheckSecuritySyntaxOnly.cpp Sun Nov 29 12:27:55 2009
> @@ -209,7 +209,7 @@
>   ranges.push_back(drInc->getSourceRange());
> 
>   const char *bugType = "Floating point variable used as loop counter";
> -  BR.EmitBasicReport(bugType, "Security", os.str().c_str(),
> +  BR.EmitBasicReport(bugType, "Security", os.str(),
>                      FS->getLocStart(), ranges.data(), ranges.size());
> }
> 
> @@ -346,7 +346,7 @@
> 
>   SourceRange R = CE->getCallee()->getSourceRange();
> 
> -  BR.EmitBasicReport(os1.str().c_str(), "Security", os2.str().c_str(),
> +  BR.EmitBasicReport(os1.str(), "Security", os2.str(),
>                      CE->getLocStart(), &R, 1);
> }
> 
> @@ -436,7 +436,7 @@
> 
>   SourceRange R = CE->getCallee()->getSourceRange();
> 
> -  BR.EmitBasicReport(os1.str().c_str(), "Security", os2.str().c_str(),
> +  BR.EmitBasicReport(os1.str(), "Security", os2.str(),
>                      CE->getLocStart(), &R, 1);
> }
> 
> 
> Modified: cfe/trunk/lib/Analysis/NSErrorChecker.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/NSErrorChecker.cpp?rev=90086&r1=90085&r2=90086&view=diff
> 
> ==============================================================================
> --- cfe/trunk/lib/Analysis/NSErrorChecker.cpp (original)
> +++ cfe/trunk/lib/Analysis/NSErrorChecker.cpp Sun Nov 29 12:27:55 2009
> @@ -113,13 +113,10 @@
>   os << " should have a non-void return value to indicate whether or not an "
>         "error occurred";
> 
> -  // FIXME: Remove when we migrate EmitBasicReport to StringRef.
> -  std::string cat = getCategory().str();
> -  
>   BR.EmitBasicReport(isNSErrorWarning
>                      ? "Bad return type when passing NSError**"
>                      : "Bad return type when passing CFError*",
> -                     cat.c_str(), os.str().c_str(),
> +                     getCategory(), os.str(),
>                      CodeDecl.getLocation());
> }
> 
> 
> 
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits





More information about the cfe-commits mailing list