forked from OSchip/llvm-project
Specially handle casts to 'void' in AdjustedReturnValueChecker.
llvm-svn: 95287
This commit is contained in:
parent
33617e055a
commit
49f878524c
|
@ -43,6 +43,9 @@ void clang::RegisterAdjustedReturnValueChecker(GRExprEngine &Eng) {
|
||||||
void AdjustedReturnValueChecker::PostVisitCallExpr(CheckerContext &C,
|
void AdjustedReturnValueChecker::PostVisitCallExpr(CheckerContext &C,
|
||||||
const CallExpr *CE) {
|
const CallExpr *CE) {
|
||||||
|
|
||||||
|
// Get the result type of the call.
|
||||||
|
QualType expectedResultTy = CE->getType();
|
||||||
|
|
||||||
// Fetch the signature of the called function.
|
// Fetch the signature of the called function.
|
||||||
const GRState *state = C.getState();
|
const GRState *state = C.getState();
|
||||||
|
|
||||||
|
@ -50,6 +53,12 @@ void AdjustedReturnValueChecker::PostVisitCallExpr(CheckerContext &C,
|
||||||
if (V.isUnknown())
|
if (V.isUnknown())
|
||||||
return;
|
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();
|
const MemRegion *callee = state->getSVal(CE->getCallee()).getAsRegion();
|
||||||
if (!callee)
|
if (!callee)
|
||||||
return;
|
return;
|
||||||
|
@ -76,8 +85,6 @@ void AdjustedReturnValueChecker::PostVisitCallExpr(CheckerContext &C,
|
||||||
if (actualResultTy->getAs<ReferenceType>())
|
if (actualResultTy->getAs<ReferenceType>())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Get the result type of the call.
|
|
||||||
QualType expectedResultTy = CE->getType();
|
|
||||||
|
|
||||||
// Are they the same?
|
// Are they the same?
|
||||||
if (expectedResultTy != actualResultTy) {
|
if (expectedResultTy != actualResultTy) {
|
||||||
|
|
|
@ -893,3 +893,11 @@ int bar_rev95267() {
|
||||||
return 1;
|
return 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Same as previous case, but handle casts to 'void'.
|
||||||
|
int bar_rev95274() {
|
||||||
|
void (*Callback_rev95274)(void) = (void (*)(void)) foo_rev95267;
|
||||||
|
(*Callback_rev95274)();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue