summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/DeclBase.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2008-11-19 18:01:13 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2008-11-19 18:01:13 +0000
commit0d09c4944e448958ab1ff1941948777805df95e7 (patch)
tree6b5c36f3ade69e225924258059cf95b0dfbc6615 /clang/lib/AST/DeclBase.cpp
parentef5e6934cb38f616938a448bd31868c19edafd71 (diff)
downloadbcm5719-llvm-0d09c4944e448958ab1ff1941948777805df95e7.tar.gz
bcm5719-llvm-0d09c4944e448958ab1ff1941948777805df95e7.zip
Take care another assert:
struct A { struct B; }; struct A::B { void m() {} // Assertion failed: getContainingDC(DC) == CurContext && "The next DeclContext should be lexically contained in the current one." }; Introduce DeclContext::getLexicalParent which may be different from DeclContext::getParent when nested-names are involved, e.g: namespace A { struct S; } struct A::S {}; // getParent() == namespace 'A' // getLexicalParent() == translation unit llvm-svn: 59650
Diffstat (limited to 'clang/lib/AST/DeclBase.cpp')
-rw-r--r--clang/lib/AST/DeclBase.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp
index 88d9a208553..c0655cf9ceb 100644
--- a/clang/lib/AST/DeclBase.cpp
+++ b/clang/lib/AST/DeclBase.cpp
@@ -361,3 +361,12 @@ const DeclContext *DeclContext::getParent() const {
else
return NULL;
}
+
+const DeclContext *DeclContext::getLexicalParent() const {
+ if (const ScopedDecl *SD = dyn_cast<ScopedDecl>(this))
+ return SD->getLexicalDeclContext();
+ else if (const BlockDecl *BD = dyn_cast<BlockDecl>(this))
+ return BD->getParentContext();
+ else
+ return NULL;
+}
OpenPOWER on IntegriCloud