From 046c51ebe14c550cacaba4e5f68bcdc681edadc9 Mon Sep 17 00:00:00 2001 From: Robert Widmann Date: Thu, 21 Nov 2019 11:52:07 -0800 Subject: [PATCH] Drop the requirement that nested types be clang::TypeDecls The nested types table contains more than just nested typedefs and aggregate decls, it also contains classes that we've imported under nested names. We were previously falling back to direct lookup to resolve (cross) references to these entities. Instead, relax the preconditions for searching the table. This breaks a few cycles involving re-entrant calls to lookupDirect/lookupQualified through the ClangImporter. --- lib/ClangImporter/ClangImporter.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/ClangImporter/ClangImporter.cpp b/lib/ClangImporter/ClangImporter.cpp index 21ff9e67be946..a0c0871d8626a 100644 --- a/lib/ClangImporter/ClangImporter.cpp +++ b/lib/ClangImporter/ClangImporter.cpp @@ -2902,12 +2902,11 @@ ClangModuleUnit::lookupNestedType(Identifier name, // If the entry is not visible, skip it. if (!isVisibleClangEntry(clangCtx, entry)) continue; - auto clangDecl = entry.dyn_cast(); - auto clangTypeDecl = dyn_cast_or_null(clangDecl); - if (!clangTypeDecl) + auto *clangDecl = entry.dyn_cast(); + if (!clangDecl) continue; - clangTypeDecl = cast(clangTypeDecl->getMostRecentDecl()); + const auto *clangTypeDecl = clangDecl->getMostRecentDecl(); bool anyMatching = false; TypeDecl *originalDecl = nullptr;