summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2016-04-25 19:28:08 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2016-04-25 19:28:08 +0000
commit2eba90e0dbe1bf846448bd6fa5b412b6a9ece817 (patch)
treed5dd79551c1e420c9bdef1f18c0eae9492569469 /clang/lib/AST
parent99c14524ec6bb67b1ccdf9f100d01dab8afa2bf0 (diff)
downloadbcm5719-llvm-2eba90e0dbe1bf846448bd6fa5b412b6a9ece817.tar.gz
bcm5719-llvm-2eba90e0dbe1bf846448bd6fa5b412b6a9ece817.zip
Refactor traversal of bases in deduction of template parameters from base
classes of an argument to use CXXRecordDecl::forallBases. Fix forallBases to only visit each base class once. llvm-svn: 267453
Diffstat (limited to 'clang/lib/AST')
-rw-r--r--clang/lib/AST/CXXInheritance.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/clang/lib/AST/CXXInheritance.cpp b/clang/lib/AST/CXXInheritance.cpp
index 6a6ca76a016..d1a2b435df1 100644
--- a/clang/lib/AST/CXXInheritance.cpp
+++ b/clang/lib/AST/CXXInheritance.cpp
@@ -137,6 +137,7 @@ CXXRecordDecl::isCurrentInstantiation(const DeclContext *CurContext) const {
bool CXXRecordDecl::forallBases(ForallBasesCallback BaseMatches,
bool AllowShortCircuit) const {
SmallVector<const CXXRecordDecl*, 8> Queue;
+ llvm::SmallPtrSet<const CXXRecordDecl*, 8> Enqueued;
const CXXRecordDecl *Record = this;
bool AllMatches = true;
@@ -158,12 +159,14 @@ bool CXXRecordDecl::forallBases(ForallBasesCallback BaseMatches,
AllMatches = false;
continue;
}
-
- Queue.push_back(Base);
- if (!BaseMatches(Base)) {
- if (AllowShortCircuit) return false;
- AllMatches = false;
- continue;
+
+ if (Enqueued.insert(Base).second) {
+ Queue.push_back(Base);
+ if (!BaseMatches(Base)) {
+ if (AllowShortCircuit) return false;
+ AllMatches = false;
+ continue;
+ }
}
}
OpenPOWER on IntegriCloud