diff options
author | Ted Kremenek <kremenek@apple.com> | 2010-08-06 21:12:53 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2010-08-06 21:12:53 +0000 |
commit | 63dc1f4694d6be187593c06449995ecf108d2b8f (patch) | |
tree | e4b2c65c6bc31e578b7157ec571fed7382c71e3d /clang/lib/Checker/MallocChecker.cpp | |
parent | b0c67c85db0503112c85f7890f07838391729381 (diff) | |
download | bcm5719-llvm-63dc1f4694d6be187593c06449995ecf108d2b8f.tar.gz bcm5719-llvm-63dc1f4694d6be187593c06449995ecf108d2b8f.zip |
Nest variable declaration into into 'if' condition, thus restricting the scope of the variable and condensing the code.
llvm-svn: 110472
Diffstat (limited to 'clang/lib/Checker/MallocChecker.cpp')
-rw-r--r-- | clang/lib/Checker/MallocChecker.cpp | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/clang/lib/Checker/MallocChecker.cpp b/clang/lib/Checker/MallocChecker.cpp index 5ad1706e055..0b98d07b85c 100644 --- a/clang/lib/Checker/MallocChecker.cpp +++ b/clang/lib/Checker/MallocChecker.cpp @@ -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."); |