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
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp
index fbc8889..6711faf 100644
--- a/lib/AST/Expr.cpp
+++ b/lib/AST/Expr.cpp
@@ -278,6 +278,16 @@
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 @@
// 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;
}