When checking whether one declaration context encloses another, make sure to look at the primary contexts. Thanks to Eli for the test case
llvm-svn: 80212
This commit is contained in:
parent
35d6e3e710
commit
e985a3b724
|
@ -578,12 +578,9 @@ public:
|
||||||
/// inline namespaces.
|
/// inline namespaces.
|
||||||
bool isTransparentContext() const;
|
bool isTransparentContext() const;
|
||||||
|
|
||||||
bool Encloses(DeclContext *DC) const {
|
/// \brief Determine whether this declaration context encloses the
|
||||||
for (; DC; DC = DC->getParent())
|
/// declaration context DC.
|
||||||
if (DC == this)
|
bool Encloses(DeclContext *DC);
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// getPrimaryContext - There may be many different
|
/// getPrimaryContext - There may be many different
|
||||||
/// declarations of the same entity (including forward declarations
|
/// declarations of the same entity (including forward declarations
|
||||||
|
|
|
@ -448,6 +448,16 @@ bool DeclContext::isTransparentContext() const {
|
||||||
return false;
|
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() {
|
DeclContext *DeclContext::getPrimaryContext() {
|
||||||
switch (DeclKind) {
|
switch (DeclKind) {
|
||||||
case Decl::TranslationUnit:
|
case Decl::TranslationUnit:
|
||||||
|
|
|
@ -63,3 +63,6 @@ template<typename T, typename U>
|
||||||
X0<T, U>::operator T*() const {
|
X0<T, U>::operator T*() const {
|
||||||
return &value;
|
return &value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace N { template <class X> class A {void a();}; }
|
||||||
|
namespace N { template <class X> void A<X>::a() {} }
|
||||||
|
|
Loading…
Reference in New Issue