[cfe-commits] r110472 - /cfe/trunk/lib/Checker/MallocChecker.cpp

Ted Kremenek kremenek at apple.com
Fri Aug 6 14:12:53 PDT 2010


Author: kremenek
Date: Fri Aug  6 16:12:53 2010
New Revision: 110472

URL: http://llvm.org/viewvc/llvm-project?rev=110472&view=rev
Log:
Nest variable declaration into into 'if' condition, thus restricting the scope of the variable and condensing the code.

Modified:
    cfe/trunk/lib/Checker/MallocChecker.cpp

Modified: cfe/trunk/lib/Checker/MallocChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/MallocChecker.cpp?rev=110472&r1=110471&r2=110472&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/MallocChecker.cpp (original)
+++ cfe/trunk/lib/Checker/MallocChecker.cpp Fri Aug  6 16:12:53 2010
@@ -334,7 +334,6 @@
     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 @@
 
   // 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 @@
 
 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 @@
       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.");





More information about the cfe-commits mailing list