diff options
author | John McCall <rjmccall@apple.com> | 2012-02-17 03:32:35 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2012-02-17 03:32:35 +0000 |
commit | a345edb668380691fc92d4e4aa0a5ffec366ca6a (patch) | |
tree | 0f83203e4c7abb9dc3dd05edbf43f69331650007 | |
parent | 84fa9cd13c2b260937625b6ad7445af7f7648565 (diff) |
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
-rw-r--r-- | include/clang/AST/Expr.h | 2 | ||||
-rw-r--r-- | lib/AST/Expr.cpp | 7 |
2 files changed, 5 insertions, 4 deletions
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<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 { |