forked from OSchip/llvm-project
Add a new CallExpr::getCallReturnType and use it in Expr::isLvalueInternal. No intended functionality change.
llvm-svn: 72410
This commit is contained in:
parent
3b70b300b0
commit
00a2759ca9
|
@ -1006,6 +1006,11 @@ public:
|
||||||
/// not, return 0.
|
/// not, return 0.
|
||||||
unsigned isBuiltinCall(ASTContext &Context) const;
|
unsigned isBuiltinCall(ASTContext &Context) const;
|
||||||
|
|
||||||
|
/// getCallReturnType - Get the return type of the call expr. This is not
|
||||||
|
/// always the type of the expr itself, if the return type is a reference
|
||||||
|
/// type.
|
||||||
|
QualType getCallReturnType() const;
|
||||||
|
|
||||||
SourceLocation getRParenLoc() const { return RParenLoc; }
|
SourceLocation getRParenLoc() const { return RParenLoc; }
|
||||||
void setRParenLoc(SourceLocation L) { RParenLoc = L; }
|
void setRParenLoc(SourceLocation L) { RParenLoc = L; }
|
||||||
|
|
||||||
|
|
|
@ -278,6 +278,16 @@ unsigned CallExpr::isBuiltinCall(ASTContext &Context) const {
|
||||||
return FDecl->getBuiltinID(Context);
|
return FDecl->getBuiltinID(Context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QualType CallExpr::getCallReturnType() const {
|
||||||
|
QualType CalleeType = getCallee()->getType();
|
||||||
|
if (const PointerType *FnTypePtr = CalleeType->getAsPointerType())
|
||||||
|
CalleeType = FnTypePtr->getPointeeType();
|
||||||
|
else if (const BlockPointerType *BPT = CalleeType->getAsBlockPointerType())
|
||||||
|
CalleeType = BPT->getPointeeType();
|
||||||
|
|
||||||
|
const FunctionType *FnType = CalleeType->getAsFunctionType();
|
||||||
|
return FnType->getResultType();
|
||||||
|
}
|
||||||
|
|
||||||
/// getOpcodeStr - Turn an Opcode enum value into the punctuation char it
|
/// getOpcodeStr - Turn an Opcode enum value into the punctuation char it
|
||||||
/// corresponds to, e.g. "<<=".
|
/// corresponds to, e.g. "<<=".
|
||||||
|
@ -773,15 +783,9 @@ Expr::isLvalueResult Expr::isLvalueInternal(ASTContext &Ctx) const {
|
||||||
// C++0x [expr.call]p10
|
// C++0x [expr.call]p10
|
||||||
// A function call is an lvalue if and only if the result type
|
// A function call is an lvalue if and only if the result type
|
||||||
// is an lvalue reference.
|
// is an lvalue reference.
|
||||||
QualType CalleeType = cast<CallExpr>(this)->getCallee()->getType();
|
QualType ReturnType = cast<CallExpr>(this)->getCallReturnType();
|
||||||
if (const PointerType *FnTypePtr = CalleeType->getAsPointerType())
|
if (ReturnType->isLValueReferenceType())
|
||||||
CalleeType = FnTypePtr->getPointeeType();
|
return LV_Valid;
|
||||||
else if (const BlockPointerType *BPT = CalleeType->getAsBlockPointerType())
|
|
||||||
CalleeType = BPT->getPointeeType();
|
|
||||||
|
|
||||||
if (const FunctionType *FnType = CalleeType->getAsFunctionType())
|
|
||||||
if (FnType->getResultType()->isLValueReferenceType())
|
|
||||||
return LV_Valid;
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue