diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-09-28 02:45:33 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-09-28 02:45:33 +0000 |
commit | c8680f46970a5a53d07e05edd93657e64764da3c (patch) | |
tree | 101b82ab8c2522f4ce799de0d2fd9c82ffc2e7ee /lib/AST/DeclBase.cpp | |
parent | 4f8de278b73f438f1911128ae9c8ce27c2b53546 (diff) |
Introduce Decl::getParentFunctionOrMethod which if the decl is defined inside
a function/method/block it returns the corresponding DeclContext, otherwise it returns null.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140672 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/DeclBase.cpp')
-rw-r--r-- | lib/AST/DeclBase.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp index 60fb7025ab..d0afcbc45b 100644 --- a/lib/AST/DeclBase.cpp +++ b/lib/AST/DeclBase.cpp @@ -137,14 +137,14 @@ bool Decl::isTemplateDecl() const { return isa<TemplateDecl>(this); } -bool Decl::isDefinedOutsideFunctionOrMethod() const { - for (const DeclContext *DC = getDeclContext(); - DC && !DC->isTranslationUnit(); +const DeclContext *Decl::getParentFunctionOrMethod() const { + for (const DeclContext *DC = getDeclContext(); + DC && !DC->isTranslationUnit() && !DC->isNamespace(); DC = DC->getParent()) if (DC->isFunctionOrMethod()) - return false; + return DC; - return true; + return 0; } |