diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-11-22 00:24:47 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-11-22 00:24:47 +0000 |
commit | d80b2d57cf24fb80c8ecc40b32ca10fdbeae0c85 (patch) | |
tree | 57f99c982707c8bbd59ffb8ec9634ea998f22abe /clang/lib/AST/CXXInheritance.cpp | |
parent | 56cb16dd927fa9304aa5b4474aa1d23ea8acc5c0 (diff) | |
download | bcm5719-llvm-d80b2d57cf24fb80c8ecc40b32ca10fdbeae0c85.tar.gz bcm5719-llvm-d80b2d57cf24fb80c8ecc40b32ca10fdbeae0c85.zip |
Fix CXXRecordDecl::forallBases to not look through bases which are dependent
and defined within the current instantiation, but which are not part of the
current instantiation. Previously, it would look at bases which could be
specialized separately from the current template.
llvm-svn: 168477
Diffstat (limited to 'clang/lib/AST/CXXInheritance.cpp')
-rw-r--r-- | clang/lib/AST/CXXInheritance.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/clang/lib/AST/CXXInheritance.cpp b/clang/lib/AST/CXXInheritance.cpp index 213b214a4e4..292b23dcc69 100644 --- a/clang/lib/AST/CXXInheritance.cpp +++ b/clang/lib/AST/CXXInheritance.cpp @@ -121,6 +121,17 @@ bool CXXRecordDecl::isProvablyNotDerivedFrom(const CXXRecordDecl *Base) const { return forallBases(BaseIsNot, (void*) Base->getCanonicalDecl()); } +bool +CXXRecordDecl::isCurrentInstantiation(const DeclContext *CurContext) const { + assert(isDependentContext()); + + for (; !CurContext->isFileContext(); CurContext = CurContext->getParent()) + if (CurContext->Equals(this)) + return true; + + return false; +} + bool CXXRecordDecl::forallBases(ForallBasesCallback *BaseMatches, void *OpaqueData, bool AllowShortCircuit) const { @@ -140,7 +151,9 @@ bool CXXRecordDecl::forallBases(ForallBasesCallback *BaseMatches, CXXRecordDecl *Base = cast_or_null<CXXRecordDecl>(Ty->getDecl()->getDefinition()); - if (!Base) { + if (!Base || + (Base->isDependentContext() && + !Base->isCurrentInstantiation(Record))) { if (AllowShortCircuit) return false; AllMatches = false; continue; @@ -725,4 +738,3 @@ CXXRecordDecl::getIndirectPrimaryBases(CXXIndirectPrimaryBaseSet& Bases) const { AddIndirectPrimaryBases(BaseDecl, Context, Bases); } } - |