From 5126c60498a78b90bda699ba6a2afbb7043686f5 Mon Sep 17 00:00:00 2001 From: Zhongxing Xu Date: Wed, 16 Jun 2010 05:45:09 +0000 Subject: [PATCH] Register CallAndMessageChecker before AttrNonNullChecker. Then we can assume arguments are not undefined. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106083 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Checker/AttrNonNullChecker.cpp | 8 ++------ lib/Checker/GRExprEngine.cpp | 4 +++- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/Checker/AttrNonNullChecker.cpp b/lib/Checker/AttrNonNullChecker.cpp index 309a74ce54..471cf19717 100644 --- a/lib/Checker/AttrNonNullChecker.cpp +++ b/lib/Checker/AttrNonNullChecker.cpp @@ -60,15 +60,11 @@ void AttrNonNullChecker::PreVisitCallExpr(CheckerContext &C, if (!Att->isNonNull(idx)) continue; - const SVal &V = state->getSVal(*I); - const DefinedSVal *DV = dyn_cast(&V); - - if (!DV) - continue; + const DefinedSVal &V = cast(state->getSVal(*I)); ConstraintManager &CM = C.getConstraintManager(); const GRState *stateNotNull, *stateNull; - llvm::tie(stateNotNull, stateNull) = CM.AssumeDual(state, *DV); + llvm::tie(stateNotNull, stateNull) = CM.AssumeDual(state, V); if (stateNull && !stateNotNull) { // Generate an error node. Check for a null node in case diff --git a/lib/Checker/GRExprEngine.cpp b/lib/Checker/GRExprEngine.cpp index d5bd4b0cb0..615e8e3791 100644 --- a/lib/Checker/GRExprEngine.cpp +++ b/lib/Checker/GRExprEngine.cpp @@ -312,8 +312,10 @@ static void RegisterInternalChecks(GRExprEngine &Eng) { // automatically. Note that the check itself is owned by the GRExprEngine // object. RegisterAdjustedReturnValueChecker(Eng); - RegisterAttrNonNullChecker(Eng); + // CallAndMessageChecker should be registered before AttrNonNullChecker, + // where we assume arguments are not undefined. RegisterCallAndMessageChecker(Eng); + RegisterAttrNonNullChecker(Eng); RegisterDereferenceChecker(Eng); RegisterVLASizeChecker(Eng); RegisterDivZeroChecker(Eng); -- 2.40.0