diff options
author | Anders Carlsson <andersca@mac.com> | 2009-05-26 04:57:27 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-05-26 04:57:27 +0000 |
commit | 6dde78f744382a5627a04f984a97049e0c4b5e73 (patch) | |
tree | 9d05b931c63e86661d7eb258f3eca6219d1c1a55 /lib/AST/Expr.cpp | |
parent | 5e5783180acb42c9d9b1be2838370ea5930a2a8b (diff) |
Add a new CallExpr::getCallReturnType and use it in Expr::isLvalueInternal. No intended functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72410 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/Expr.cpp')
-rw-r--r-- | lib/AST/Expr.cpp | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp index fbc8889567..6711faffe7 100644 --- a/lib/AST/Expr.cpp +++ b/lib/AST/Expr.cpp @@ -278,6 +278,16 @@ unsigned CallExpr::isBuiltinCall(ASTContext &Context) const { 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 /// corresponds to, e.g. "<<=". @@ -773,15 +783,9 @@ Expr::isLvalueResult Expr::isLvalueInternal(ASTContext &Ctx) const { // C++0x [expr.call]p10 // A function call is an lvalue if and only if the result type // is an lvalue reference. - QualType CalleeType = cast<CallExpr>(this)->getCallee()->getType(); - if (const PointerType *FnTypePtr = CalleeType->getAsPointerType()) - CalleeType = FnTypePtr->getPointeeType(); - else if (const BlockPointerType *BPT = CalleeType->getAsBlockPointerType()) - CalleeType = BPT->getPointeeType(); - - if (const FunctionType *FnType = CalleeType->getAsFunctionType()) - if (FnType->getResultType()->isLValueReferenceType()) - return LV_Valid; + QualType ReturnType = cast<CallExpr>(this)->getCallReturnType(); + if (ReturnType->isLValueReferenceType()) + return LV_Valid; break; } |