[cfe-commits] r72410 - in /cfe/trunk: include/clang/AST/Expr.h lib/AST/Expr.cpp

Anders Carlsson andersca at mac.com
Mon May 25 21:57:28 PDT 2009


Author: andersca
Date: Mon May 25 23:57:27 2009
New Revision: 72410

URL: http://llvm.org/viewvc/llvm-project?rev=72410&view=rev
Log:
Add a new CallExpr::getCallReturnType and use it in Expr::isLvalueInternal. No intended functionality change.

Modified:
    cfe/trunk/include/clang/AST/Expr.h
    cfe/trunk/lib/AST/Expr.cpp

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=72410&r1=72409&r2=72410&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Mon May 25 23:57:27 2009
@@ -1006,6 +1006,11 @@
   /// not, return 0.
   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; }
   void setRParenLoc(SourceLocation L) { RParenLoc = L; }
 

Modified: cfe/trunk/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=72410&r1=72409&r2=72410&view=diff

==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Mon May 25 23:57:27 2009
@@ -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;
   }





More information about the cfe-commits mailing list