r178899 - [analyzer] Eliminates all the cases with unknown family.
Anton Yartsev
anton.yartsev at gmail.com
Fri Apr 5 12:08:04 PDT 2013
Author: ayartsev
Date: Fri Apr 5 14:08:04 2013
New Revision: 178899
URL: http://llvm.org/viewvc/llvm-project?rev=178899&view=rev
Log:
[analyzer] Eliminates all the cases with unknown family.
Now treat AF_None family as impossible in isTrackedFamily()
Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp?rev=178899&r1=178898&r2=178899&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp Fri Apr 5 14:08:04 2013
@@ -284,7 +284,7 @@ private:
bool(*CheckRefState)(const RefState*)) const;
// Used to suppress warnings if they are not related to the tracked family
- // (derived from AllocDeallocStmt).
+ // (derived from Sym or AllocDeallocStmt).
bool isTrackedFamily(AllocationFamily Family) const;
bool isTrackedFamily(CheckerContext &C, const Stmt *AllocDeallocStmt) const;
bool isTrackedFamily(CheckerContext &C, SymbolRef Sym) const;
@@ -1058,7 +1058,8 @@ ProgramStateRef MallocChecker::FreeMemAu
}
}
- AllocationFamily Family = RsBase ? RsBase->getAllocationFamily() : AF_None;
+ AllocationFamily Family = RsBase ? RsBase->getAllocationFamily()
+ : getAllocationFamily(C, ParentExpr);
// Normal free.
if (Hold)
return State->set<RegionState>(SymBase,
@@ -1083,7 +1084,7 @@ bool MallocChecker::isTrackedFamily(Allo
return true;
}
case AF_None: {
- return true;
+ llvm_unreachable("no family");
}
}
llvm_unreachable("unhandled family");
@@ -1095,10 +1096,10 @@ bool MallocChecker::isTrackedFamily(Chec
}
bool MallocChecker::isTrackedFamily(CheckerContext &C, SymbolRef Sym) const {
- const RefState *RS = C.getState()->get<RegionState>(Sym);
- return RS ? isTrackedFamily(RS->getAllocationFamily())
- : isTrackedFamily(AF_None);
+ const RefState *RS = C.getState()->get<RegionState>(Sym);
+ assert(RS);
+ return isTrackedFamily(RS->getAllocationFamily());
}
bool MallocChecker::SummarizeValue(raw_ostream &os, SVal V) {
More information about the cfe-commits
mailing list