]> granicus.if.org Git - clang/commitdiff
Block expressions always have a prototyped function type; expose this
authorJohn McCall <rjmccall@apple.com>
Fri, 17 Feb 2012 03:32:35 +0000 (03:32 +0000)
committerJohn McCall <rjmccall@apple.com>
Fri, 17 Feb 2012 03:32:35 +0000 (03:32 +0000)
in the AST accessor and micro-optimize it very slightly.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150787 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/Expr.h
lib/AST/Expr.cpp

index 8a80803f01c216e4a1cb4ce6766ff0702be60e54..0f325bdcc91503cfd70d2f8ff3045147d22d95c0 100644 (file)
@@ -4233,7 +4233,7 @@ public:
   }
 
   /// 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;
index 4b19031852c648cfcd82b34d03514c54c2ba87b7..d5eab77816c6f02db2c5541ff1a53653984dad25 100644 (file)
@@ -1512,9 +1512,10 @@ SourceRange InitListExpr::getSourceRange() const {
 
 /// 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 {