diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-08-27 06:03:53 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-08-27 06:03:53 +0000 |
commit | 6dd38daf1495367db8fe9e9a5cacb7420cf08e27 (patch) | |
tree | c27ebac6d29c4760556002f2530bdf6f896c9d62 /lib/AST/DeclBase.cpp | |
parent | 8d4c5ea0ee899d3e916d79cde98f16fb47810c4f (diff) |
When checking whether one declaration context encloses another, make sure to look at the primary contexts. Thanks to Eli for the test case
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80212 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/DeclBase.cpp')
-rw-r--r-- | lib/AST/DeclBase.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp index 8296f2931b..cd5b0063a6 100644 --- a/lib/AST/DeclBase.cpp +++ b/lib/AST/DeclBase.cpp @@ -448,6 +448,16 @@ bool DeclContext::isTransparentContext() const { return false; } +bool DeclContext::Encloses(DeclContext *DC) { + if (getPrimaryContext() != this) + return getPrimaryContext()->Encloses(DC); + + for (; DC; DC = DC->getParent()) + if (DC->getPrimaryContext() == this) + return true; + return false; +} + DeclContext *DeclContext::getPrimaryContext() { switch (DeclKind) { case Decl::TranslationUnit: |