зеркало из https://github.com/microsoft/clang-1.git
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
This commit is contained in:
Родитель
8d4c5ea0ee
Коммит
6dd38daf14
|
@ -578,12 +578,9 @@ public:
|
|||
/// inline namespaces.
|
||||
bool isTransparentContext() const;
|
||||
|
||||
bool Encloses(DeclContext *DC) const {
|
||||
for (; DC; DC = DC->getParent())
|
||||
if (DC == this)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
/// \brief Determine whether this declaration context encloses the
|
||||
/// declaration context DC.
|
||||
bool Encloses(DeclContext *DC);
|
||||
|
||||
/// getPrimaryContext - There may be many different
|
||||
/// declarations of the same entity (including forward declarations
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -63,3 +63,6 @@ template<typename T, typename U>
|
|||
X0<T, U>::operator T*() const {
|
||||
return &value;
|
||||
}
|
||||
|
||||
namespace N { template <class X> class A {void a();}; }
|
||||
namespace N { template <class X> void A<X>::a() {} }
|
||||
|
|
Загрузка…
Ссылка в новой задаче