]> granicus.if.org Git - clang/commitdiff
Nest variable declaration into into 'if' condition, thus restricting the scope of...
authorTed Kremenek <kremenek@apple.com>
Fri, 6 Aug 2010 21:12:53 +0000 (21:12 +0000)
committerTed Kremenek <kremenek@apple.com>
Fri, 6 Aug 2010 21:12:53 +0000 (21:12 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110472 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Checker/MallocChecker.cpp

index 5ad1706e0551e1fb6e98c75c904c096d9cc7997e..0b98d07b85cfd4b86ef61c8d02ac815c8a7f97a4 100644 (file)
@@ -334,7 +334,6 @@ const GRState *MallocChecker::FreeMemAux(CheckerContext &C, const CallExpr *CE,
     return notNullState;
 
   SymbolRef Sym = SR->getSymbol();
-  
   const RefState *RS = state->get<RegionState>(Sym);
 
   // If the symbol has not been tracked, return. This is possible when free() is
@@ -345,8 +344,7 @@ const GRState *MallocChecker::FreeMemAux(CheckerContext &C, const CallExpr *CE,
 
   // Check double free.
   if (RS->isReleased()) {
-    ExplodedNode *N = C.GenerateSink();
-    if (N) {
+    if (ExplodedNode *N = C.GenerateSink()) {
       if (!BT_DoubleFree)
         BT_DoubleFree
           = new BuiltinBug("Double free",
@@ -457,8 +455,7 @@ bool MallocChecker::SummarizeRegion(llvm::raw_ostream& os,
 
 void MallocChecker::ReportBadFree(CheckerContext &C, SVal ArgVal,
                                   SourceRange range) {
-  ExplodedNode *N = C.GenerateSink();
-  if (N) {
+  if (ExplodedNode *N = C.GenerateSink()) {
     if (!BT_BadFree)
       BT_BadFree = new BuiltinBug("Bad free");
     
@@ -571,8 +568,7 @@ void MallocChecker::EvalDeadSymbols(CheckerContext &C,SymbolReaper &SymReaper) {
       return;
 
     if (RS->isAllocated()) {
-      ExplodedNode *N = C.GenerateSink();
-      if (N) {
+      if (ExplodedNode *N = C.GenerateSink()) {
         if (!BT_Leak)
           BT_Leak = new BuiltinBug("Memory leak",
                      "Allocated memory never released. Potential memory leak.");