From a3989b8f54421cd90a48ace8820c7147cea6bb3d Mon Sep 17 00:00:00 2001 From: Anton Yartsev Date: Fri, 5 Apr 2013 19:08:04 +0000 Subject: [PATCH] [analyzer] Eliminates all the cases with unknown family. Now treat AF_None family as impossible in isTrackedFamily() git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178899 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/StaticAnalyzer/Checkers/MallocChecker.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/StaticAnalyzer/Checkers/MallocChecker.cpp b/lib/StaticAnalyzer/Checkers/MallocChecker.cpp index 851aa0ca36..a1ec819ef2 100644 --- a/lib/StaticAnalyzer/Checkers/MallocChecker.cpp +++ b/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(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(Sym); - return RS ? isTrackedFamily(RS->getAllocationFamily()) - : isTrackedFamily(AF_None); + const RefState *RS = C.getState()->get(Sym); + assert(RS); + return isTrackedFamily(RS->getAllocationFamily()); } bool MallocChecker::SummarizeValue(raw_ostream &os, SVal V) { -- 2.40.0