[cfe-commits] r157772 - /cfe/trunk/lib/StaticAnalyzer/Checkers/IdempotentOperationChecker.cpp

Tom Care tom.care at uqconnect.edu.au
Thu May 31 14:24:58 PDT 2012


Author: tcare
Date: Thu May 31 16:24:58 2012
New Revision: 157772

URL: http://llvm.org/viewvc/llvm-project?rev=157772&view=rev
Log:
[analyzer] Fix BugType memory leak in IdempotentOperationChecker.

Modified:
    cfe/trunk/lib/StaticAnalyzer/Checkers/IdempotentOperationChecker.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/IdempotentOperationChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/IdempotentOperationChecker.cpp?rev=157772&r1=157771&r2=157772&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/IdempotentOperationChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/IdempotentOperationChecker.cpp Thu May 31 16:24:58 2012
@@ -106,6 +106,7 @@
   typedef llvm::DenseMap<const BinaryOperator *, BinaryOperatorData>
       AssumptionMap;
   mutable AssumptionMap hash;
+  mutable OwningPtr<BugType> BT;
 };
 }
 
@@ -343,7 +344,9 @@
 void IdempotentOperationChecker::checkEndAnalysis(ExplodedGraph &G,
                                                   BugReporter &BR,
                                                   ExprEngine &Eng) const {
-  BugType *BT = new BugType("Idempotent operation", "Dead code");
+  if (!BT)
+    BT.reset(new BugType("Idempotent operation", "Dead code"));
+
   // Iterate over the hash to see if we have any paths with definite
   // idempotent operations.
   for (AssumptionMap::const_iterator i = hash.begin(); i != hash.end(); ++i) {





More information about the cfe-commits mailing list