forked from OSchip/llvm-project
[analyzer] Do not crash in CallEvent.getReturnType()
When the call expression is not available. llvm-svn: 328406
This commit is contained in:
parent
2c0a62ab9a
commit
405fdfc34c
|
@ -67,11 +67,13 @@ using namespace clang;
|
|||
using namespace ento;
|
||||
|
||||
QualType CallEvent::getResultType() const {
|
||||
const Expr *E = getOriginExpr();
|
||||
assert(E && "Calls without origin expressions do not have results");
|
||||
QualType ResultTy = E->getType();
|
||||
|
||||
ASTContext &Ctx = getState()->getStateManager().getContext();
|
||||
const Expr *E = getOriginExpr();
|
||||
if (!E)
|
||||
return Ctx.VoidTy;
|
||||
assert(E);
|
||||
|
||||
QualType ResultTy = E->getType();
|
||||
|
||||
// A function that returns a reference to 'int' will have a result type
|
||||
// of simply 'int'. Check the origin expr's value kind to recover the
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
#pragma clang system_header
|
||||
|
||||
struct S {
|
||||
~S(){}
|
||||
};
|
||||
|
||||
void foo() {
|
||||
S s;
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
// RUN: %clang_analyze_cc1 -fblocks -analyze -analyzer-checker=core,nullability,apiModeling -verify %s
|
||||
|
||||
#include "Inputs/system-header-simulator-for-nullability-cxx.h"
|
||||
|
||||
// expected-no-diagnostics
|
||||
|
||||
void blah() {
|
||||
foo(); // no-crash
|
||||
}
|
Loading…
Reference in New Issue