diff options
author | Aaron Ballman <aaron@aaronballman.com> | 2014-01-16 13:55:42 +0000 |
---|---|---|
committer | Aaron Ballman <aaron@aaronballman.com> | 2014-01-16 13:55:42 +0000 |
commit | 12b9f6535b9a10774b3c2ed79921fd98ccbfa09d (patch) | |
tree | e43e350e94d8f93312ecbb9f2eb0e928b3c00ed6 /clang/lib/AST/DeclBase.cpp | |
parent | da93c0f37c9dec2a6416b4ff710f24b56fc11cda (diff) | |
download | bcm5719-llvm-12b9f6535b9a10774b3c2ed79921fd98ccbfa09d.tar.gz bcm5719-llvm-12b9f6535b9a10774b3c2ed79921fd98ccbfa09d.zip |
Factored some function-like type reasoning out of SemaDeclAttr and onto Decl itself. This allows for more declarative subjects in attribute tablegen where the attribute appertains to something function-like, but not strictly a FunctionDecl.
llvm-svn: 199387
Diffstat (limited to 'clang/lib/AST/DeclBase.cpp')
-rw-r--r-- | clang/lib/AST/DeclBase.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp index 8e7373631db..46adad6c3c3 100644 --- a/clang/lib/AST/DeclBase.cpp +++ b/clang/lib/AST/DeclBase.cpp @@ -701,6 +701,24 @@ bool Decl::AccessDeclContextSanity() const { static Decl::Kind getKind(const Decl *D) { return D->getKind(); } static Decl::Kind getKind(const DeclContext *DC) { return DC->getDeclKind(); } +const FunctionType *Decl::getFunctionType(bool BlocksToo) const { + QualType Ty; + if (const ValueDecl *D = dyn_cast<ValueDecl>(this)) + Ty = D->getType(); + else if (const TypedefNameDecl *D = dyn_cast<TypedefNameDecl>(this)) + Ty = D->getUnderlyingType(); + else + return 0; + + if (Ty->isFunctionPointerType()) + Ty = Ty->getAs<PointerType>()->getPointeeType(); + else if (BlocksToo && Ty->isBlockPointerType()) + Ty = Ty->getAs<BlockPointerType>()->getPointeeType(); + + return Ty->getAs<FunctionType>(); +} + + /// Starting at a given context (a Decl or DeclContext), look for a /// code context that is not a closure (a lambda, block, etc.). template <class T> static Decl *getNonClosureContext(T *D) { |