diff options
author | Ted Kremenek <kremenek@apple.com> | 2010-02-04 04:18:55 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2010-02-04 04:18:55 +0000 |
commit | 95a011204fec58cc5dbc4f4a9830a8f0435c4b72 (patch) | |
tree | 3a2f1ef21e3e457820178f91c9060e6a5c49c7ba /lib/Checker/AdjustedReturnValueChecker.cpp | |
parent | 8928d41f721db9a57595cd2ab208af77a70daff4 (diff) |
Specially handle casts to 'void' in AdjustedReturnValueChecker.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95287 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Checker/AdjustedReturnValueChecker.cpp')
-rw-r--r-- | lib/Checker/AdjustedReturnValueChecker.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/Checker/AdjustedReturnValueChecker.cpp b/lib/Checker/AdjustedReturnValueChecker.cpp index 898ce76a99..483b41b6bd 100644 --- a/lib/Checker/AdjustedReturnValueChecker.cpp +++ b/lib/Checker/AdjustedReturnValueChecker.cpp @@ -43,12 +43,21 @@ void clang::RegisterAdjustedReturnValueChecker(GRExprEngine &Eng) { void AdjustedReturnValueChecker::PostVisitCallExpr(CheckerContext &C, const CallExpr *CE) { + // Get the result type of the call. + QualType expectedResultTy = CE->getType(); + // Fetch the signature of the called function. const GRState *state = C.getState(); SVal V = state->getSVal(CE); if (V.isUnknown()) return; + + // Casting to void? Discard the value. + if (expectedResultTy->isVoidType()) { + C.GenerateNode(state->BindExpr(CE, UnknownVal())); + return; + } const MemRegion *callee = state->getSVal(CE->getCallee()).getAsRegion(); if (!callee) @@ -76,8 +85,6 @@ void AdjustedReturnValueChecker::PostVisitCallExpr(CheckerContext &C, if (actualResultTy->getAs<ReferenceType>()) return; - // Get the result type of the call. - QualType expectedResultTy = CE->getType(); // Are they the same? if (expectedResultTy != actualResultTy) { |