diff options
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Checker/AdjustedReturnValueChecker.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/clang/lib/Checker/AdjustedReturnValueChecker.cpp b/clang/lib/Checker/AdjustedReturnValueChecker.cpp index 898ce76a991..483b41b6bdf 100644 --- a/clang/lib/Checker/AdjustedReturnValueChecker.cpp +++ b/clang/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) { |