summaryrefslogtreecommitdiffstats
path: root/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
diff options
context:
space:
mode:
authorAnton Yartsev <anton.yartsev@gmail.com>2013-04-05 19:08:04 +0000
committerAnton Yartsev <anton.yartsev@gmail.com>2013-04-05 19:08:04 +0000
commit030bcdd9e8c4bb2b2b471b123d76cac0ee18818c (patch)
treed3bbcfdbc453810b6af8538db2d5d9d3af1a626b /clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
parent1388893b7b06f485816b5700628d25692a958a23 (diff)
downloadbcm5719-llvm-030bcdd9e8c4bb2b2b471b123d76cac0ee18818c.tar.gz
bcm5719-llvm-030bcdd9e8c4bb2b2b471b123d76cac0ee18818c.zip
[analyzer] Eliminates all the cases with unknown family.
Now treat AF_None family as impossible in isTrackedFamily() llvm-svn: 178899
Diffstat (limited to 'clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp')
-rw-r--r--clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
index 851aa0ca36b..a1ec819ef28 100644
--- a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -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::FreeMemAux(CheckerContext &C,
}
}
- 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(AllocationFamily Family) const {
return true;
}
case AF_None: {
- return true;
+ llvm_unreachable("no family");
}
}
llvm_unreachable("unhandled family");
@@ -1095,10 +1096,10 @@ bool MallocChecker::isTrackedFamily(CheckerContext &C,
}
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) {
OpenPOWER on IntegriCloud