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

John McCall rjmccall at apple.com
Thu Feb 16 19:32:35 PST 2012


Author: rjmccall
Date: Thu Feb 16 21:32:35 2012
New Revision: 150787

URL: http://llvm.org/viewvc/llvm-project?rev=150787&view=rev
Log:
Block expressions always have a prototyped function type; expose this
in the AST accessor and micro-optimize it very slightly.

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=150787&r1=150786&r2=150787&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Thu Feb 16 21:32:35 2012
@@ -4233,7 +4233,7 @@
   }
 
   /// getFunctionType - Return the underlying function type for this block.
-  const FunctionType *getFunctionType() const;
+  const FunctionProtoType *getFunctionType() const;
 
   static bool classof(const Stmt *T) {
     return T->getStmtClass() == BlockExprClass;

Modified: cfe/trunk/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=150787&r1=150786&r2=150787&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Thu Feb 16 21:32:35 2012
@@ -1512,9 +1512,10 @@
 
 /// getFunctionType - Return the underlying function type for this block.
 ///
-const FunctionType *BlockExpr::getFunctionType() const {
-  return getType()->getAs<BlockPointerType>()->
-                    getPointeeType()->getAs<FunctionType>();
+const FunctionProtoType *BlockExpr::getFunctionType() const {
+  // The block pointer is never sugared, but the function type might be.
+  return cast<BlockPointerType>(getType())
+           ->getPointeeType()->castAs<FunctionProtoType>();
 }
 
 SourceLocation BlockExpr::getCaretLocation() const {





More information about the cfe-commits mailing list