aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/AST/CXXInheritance.cpp
diff options
context:
space:
mode:
authorAlex Lorenz <arphaman@gmail.com>2017-05-18 18:06:07 +0000
committerAlex Lorenz <arphaman@gmail.com>2017-05-18 18:06:07 +0000
commit6796c0b97fafcc03a6a4bda555136d3bf42768ac (patch)
tree662cd79ff0f2af4b9403758e37d2ef5ad6c2653b /clang/lib/AST/CXXInheritance.cpp
parentf8355ccb77eda715e6f7058e475aeaa46d9beee0 (diff)
downloadllvm-6796c0b97fafcc03a6a4bda555136d3bf42768ac.zip
llvm-6796c0b97fafcc03a6a4bda555136d3bf42768ac.tar.gz
llvm-6796c0b97fafcc03a6a4bda555136d3bf42768ac.tar.bz2
[index] Avoid one more crash caused by infinite recursion that happens when
looking up a dependent name in a record that derives from itself rdar://32273000 Differential Revision: https://reviews.llvm.org/D33324 llvm-svn: 303366
Diffstat (limited to 'clang/lib/AST/CXXInheritance.cpp')
-rw-r--r--clang/lib/AST/CXXInheritance.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/clang/lib/AST/CXXInheritance.cpp b/clang/lib/AST/CXXInheritance.cpp
index 746602d..fc4d8b1 100644
--- a/clang/lib/AST/CXXInheritance.cpp
+++ b/clang/lib/AST/CXXInheritance.cpp
@@ -57,6 +57,7 @@ bool CXXBasePaths::isAmbiguous(CanQualType BaseType) {
void CXXBasePaths::clear() {
Paths.clear();
ClassSubobjects.clear();
+ VisitedDependentRecords.clear();
ScratchPath.clear();
DetectedVirtual = nullptr;
}
@@ -67,6 +68,7 @@ void CXXBasePaths::swap(CXXBasePaths &Other) {
std::swap(Origin, Other.Origin);
Paths.swap(Other.Paths);
ClassSubobjects.swap(Other.ClassSubobjects);
+ VisitedDependentRecords.swap(Other.VisitedDependentRecords);
std::swap(FindAmbiguities, Other.FindAmbiguities);
std::swap(RecordPaths, Other.RecordPaths);
std::swap(DetectVirtual, Other.DetectVirtual);
@@ -278,8 +280,14 @@ bool CXXBasePaths::lookupInBases(ASTContext &Context,
dyn_cast_or_null<ClassTemplateDecl>(TN.getAsTemplateDecl()))
BaseRecord = TD->getTemplatedDecl();
}
- if (BaseRecord && !BaseRecord->hasDefinition())
- BaseRecord = nullptr;
+ if (BaseRecord) {
+ if (!BaseRecord->hasDefinition() ||
+ VisitedDependentRecords.count(BaseRecord)) {
+ BaseRecord = nullptr;
+ } else {
+ VisitedDependentRecords.insert(BaseRecord);
+ }
+ }
} else {
BaseRecord = cast<CXXRecordDecl>(
BaseSpec.getType()->castAs<RecordType>()->getDecl());