summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/AST/DeclBase.cpp9
-rw-r--r--clang/lib/Sema/SemaDecl.cpp6
2 files changed, 12 insertions, 3 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;
+}
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index d6d9845af79..941f40fa52a 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -53,10 +53,10 @@ DeclContext *Sema::getContainingDC(DeclContext *DC) {
// A C++ inline method is parsed *after* the topmost class it was declared in
// is fully parsed (it's "complete").
// The parsing of a C++ inline method happens at the declaration context of
- // the topmost (non-nested) class it is declared in.
+ // the topmost (non-nested) class it is lexically declared in.
assert(isa<CXXRecordDecl>(MD->getParent()) && "C++ method not in Record.");
DC = MD->getParent();
- while (CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(DC->getParent()))
+ while (CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(DC->getLexicalParent()))
DC = RD;
// Return the declaration context of the topmost class the inline method is
@@ -70,7 +70,7 @@ DeclContext *Sema::getContainingDC(DeclContext *DC) {
if (ScopedDecl *SD = dyn_cast<ScopedDecl>(DC))
return SD->getLexicalDeclContext();
- return DC->getParent();
+ return DC->getLexicalParent();
}
void Sema::PushDeclContext(DeclContext *DC) {
OpenPOWER on IntegriCloud