r348637 - [analyzer] RetainCountChecker: remove untested, unused, incorrect option IncludeAllocationLine

George Karpenkov via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 7 12:21:37 PST 2018


Author: george.karpenkov
Date: Fri Dec  7 12:21:37 2018
New Revision: 348637

URL: http://llvm.org/viewvc/llvm-project?rev=348637&view=rev
Log:
[analyzer] RetainCountChecker: remove untested, unused, incorrect option IncludeAllocationLine

The option has no tests, is not used anywhere, and is actually
incorrect: it prints the line number without the reference to a file,
which can be outright incorrect.

Differential Revision: https://reviews.llvm.org/D55385

Modified:
    cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
    cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
    cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.h

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp?rev=348637&r1=348636&r2=348637&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp Fri Dec  7 12:21:37 2018
@@ -1059,8 +1059,7 @@ ExplodedNode * RetainCountChecker::check
         if (N) {
           const LangOptions &LOpts = C.getASTContext().getLangOpts();
           auto R = llvm::make_unique<CFRefLeakReport>(
-              *getLeakAtReturnBug(LOpts), LOpts, SummaryLog, N, Sym, C,
-              IncludeAllocationLine);
+              *getLeakAtReturnBug(LOpts), LOpts, SummaryLog, N, Sym, C);
           C.emitReport(std::move(R));
         }
         return N;
@@ -1346,7 +1345,7 @@ RetainCountChecker::processLeaks(Program
       assert(BT && "BugType not initialized.");
 
       Ctx.emitReport(llvm::make_unique<CFRefLeakReport>(
-          *BT, LOpts, SummaryLog, N, *I, Ctx, IncludeAllocationLine));
+          *BT, LOpts, SummaryLog, N, *I, Ctx));
     }
   }
 
@@ -1508,8 +1507,6 @@ void ento::registerRetainCountChecker(Ch
 
   AnalyzerOptions &Options = Mgr.getAnalyzerOptions();
 
-  Chk->IncludeAllocationLine = Options.getCheckerBooleanOption(
-                           "leak-diagnostics-reference-allocation", false, Chk);
   Chk->ShouldCheckOSObjectRetainCount = Options.getCheckerBooleanOption(
                                                     "CheckOSObject", true, Chk);
 }

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp?rev=348637&r1=348636&r2=348637&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp Fri Dec  7 12:21:37 2018
@@ -634,8 +634,7 @@ void CFRefLeakReport::deriveAllocLocatio
   UniqueingDecl = AllocNode->getLocationContext()->getDecl();
 }
 
-void CFRefLeakReport::createDescription(CheckerContext &Ctx,
-                                        bool IncludeAllocationLine) {
+void CFRefLeakReport::createDescription(CheckerContext &Ctx) {
   assert(Location.isValid() && UniqueingDecl && UniqueingLocation.isValid());
   Description.clear();
   llvm::raw_string_ostream os(Description);
@@ -644,10 +643,6 @@ void CFRefLeakReport::createDescription(
   Optional<std::string> RegionDescription = describeRegion(AllocBinding);
   if (RegionDescription) {
     os << " stored into '" << *RegionDescription << '\'';
-    if (IncludeAllocationLine) {
-      FullSourceLoc SL(AllocStmt->getBeginLoc(), Ctx.getSourceManager());
-      os << " (allocated on line " << SL.getSpellingLineNumber() << ")";
-    }
   } else {
 
     // If we can't figure out the name, just supply the type information.
@@ -658,15 +653,14 @@ void CFRefLeakReport::createDescription(
 CFRefLeakReport::CFRefLeakReport(CFRefBug &D, const LangOptions &LOpts,
                                  const SummaryLogTy &Log,
                                  ExplodedNode *n, SymbolRef sym,
-                                 CheckerContext &Ctx,
-                                 bool IncludeAllocationLine)
+                                 CheckerContext &Ctx)
   : CFRefReport(D, LOpts, Log, n, sym, false) {
 
   deriveAllocLocation(Ctx, sym);
   if (!AllocBinding)
     deriveParamLocation(Ctx, sym);
 
-  createDescription(Ctx, IncludeAllocationLine);
+  createDescription(Ctx);
 
   addVisitor(llvm::make_unique<CFRefLeakReportVisitor>(sym, Log));
 }

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.h?rev=348637&r1=348636&r2=348637&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.h (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.h Fri Dec  7 12:21:37 2018
@@ -71,13 +71,12 @@ class CFRefLeakReport : public CFRefRepo
   // Finds the location where a leak warning for 'sym' should be raised.
   void deriveAllocLocation(CheckerContext &Ctx, SymbolRef sym);
   // Produces description of a leak warning which is printed on the console.
-  void createDescription(CheckerContext &Ctx, bool IncludeAllocationLine);
+  void createDescription(CheckerContext &Ctx);
 
 public:
   CFRefLeakReport(CFRefBug &D, const LangOptions &LOpts,
                   const SummaryLogTy &Log, ExplodedNode *n, SymbolRef sym,
-                  CheckerContext &Ctx,
-                  bool IncludeAllocationLine);
+                  CheckerContext &Ctx);
 
   PathDiagnosticLocation getLocation(const SourceManager &SM) const override {
     assert(Location.isValid());




More information about the cfe-commits mailing list