From: John McCall Date: Fri, 17 Feb 2012 03:32:35 +0000 (+0000) Subject: Block expressions always have a prototyped function type; expose this X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a345edb668380691fc92d4e4aa0a5ffec366ca6a;p=clang Block expressions always have a prototyped function type; expose this 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 --- diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h index 8a80803f01..0f325bdcc9 100644 --- a/include/clang/AST/Expr.h +++ b/include/clang/AST/Expr.h @@ -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; diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp index 4b19031852..d5eab77816 100644 --- a/lib/AST/Expr.cpp +++ b/lib/AST/Expr.cpp @@ -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()-> - getPointeeType()->getAs(); +const FunctionProtoType *BlockExpr::getFunctionType() const { + // The block pointer is never sugared, but the function type might be. + return cast(getType()) + ->getPointeeType()->castAs(); } SourceLocation BlockExpr::getCaretLocation() const {