Changeset View
Changeset View
Standalone View
Standalone View
clang/lib/StaticAnalyzer/Core/CallEvent.cpp
Show First 20 Lines • Show All 67 Lines • ▼ Show 20 Lines | |||||
using namespace clang; | using namespace clang; | ||||
using namespace ento; | using namespace ento; | ||||
QualType CallEvent::getResultType() const { | QualType CallEvent::getResultType() const { | ||||
ASTContext &Ctx = getState()->getStateManager().getContext(); | ASTContext &Ctx = getState()->getStateManager().getContext(); | ||||
const Expr *E = getOriginExpr(); | const Expr *E = getOriginExpr(); | ||||
if (!E) | if (!E) | ||||
return Ctx.VoidTy; | return Ctx.VoidTy; | ||||
assert(E); | return Ctx.getReferenceQualifiedType(E); | ||||
aaronpuchert: This seems also more of a coincidence. There is no parenthesized expression, we're just trying… | |||||
Yes, not a coincidence, still fundamentally the same thing. mizvekov: Yes, not a coincidence, still fundamentally the same thing. | |||||
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 | |||||
// proper type. | |||||
switch (E->getValueKind()) { | |||||
case VK_LValue: | |||||
ResultTy = Ctx.getLValueReferenceType(ResultTy); | |||||
break; | |||||
case VK_XValue: | |||||
ResultTy = Ctx.getRValueReferenceType(ResultTy); | |||||
break; | |||||
case VK_PRValue: | |||||
// No adjustment is necessary. | |||||
break; | |||||
} | |||||
return ResultTy; | |||||
} | } | ||||
static bool isCallback(QualType T) { | static bool isCallback(QualType T) { | ||||
// If a parameter is a block or a callback, assume it can modify pointer. | // If a parameter is a block or a callback, assume it can modify pointer. | ||||
if (T->isBlockPointerType() || | if (T->isBlockPointerType() || | ||||
T->isFunctionPointerType() || | T->isFunctionPointerType() || | ||||
T->isObjCSelType()) | T->isObjCSelType()) | ||||
return true; | return true; | ||||
▲ Show 20 Lines • Show All 1,391 Lines • Show Last 20 Lines |
This seems also more of a coincidence. There is no parenthesized expression, we're just trying to figure out a function return type.
(Ok, it's not a pure coincidence, the decltype is probably chosen to match that type.)