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 | 0ce4c9ab551c7e48cb72bad0a2c27a9561c2b38f (patch) | |
tree | b7d017299ec29713fb453e40c073defde8fa045c /clang/lib | |
parent | 8c219ecd1a9a4ad851efce74cf382f097b96ca3a (diff) | |
download | bcm5719-llvm-0ce4c9ab551c7e48cb72bad0a2c27a9561c2b38f.tar.gz bcm5719-llvm-0ce4c9ab551c7e48cb72bad0a2c27a9561c2b38f.zip |
Introduce Decl::getParentFunctionOrMethod which if the decl is defined inside
a function/method/block it returns the corresponding DeclContext, otherwise it returns null.
llvm-svn: 140672
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/AST/DeclBase.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp index 60fb7025abe..d0afcbc45b5 100644 --- a/clang/lib/AST/DeclBase.cpp +++ b/clang/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; } |