aboutsummaryrefslogtreecommitdiff
path: root/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
commit77407b802130b1c44b1f63b855722a5376f57bca (patch)
tree4005f53b992648d8a730bc9b03543920dd985646 /lib/AST/DeclBase.cpp
parenta468d34bed16861f25aff6c8354f4e75d3358c1a (diff)
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59650 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/DeclBase.cpp')
-rw-r--r--lib/AST/DeclBase.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp
index 88d9a20855..c0655cf9ce 100644
--- a/lib/AST/DeclBase.cpp
+++ b/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;
+}