Index: lldb/source/Plugins/ExpressionParser/Clang/ASTUtils.h =================================================================== --- lldb/source/Plugins/ExpressionParser/Clang/ASTUtils.h +++ lldb/source/Plugins/ExpressionParser/Clang/ASTUtils.h @@ -9,6 +9,7 @@ #ifndef LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_ASTUTILS_H #define LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_ASTUTILS_H +#include "Plugins/TypeSystem/Clang/ImporterBackedASTSource.h" #include "clang/Basic/Module.h" #include "clang/Sema/Lookup.h" #include "clang/Sema/MultiplexExternalSemaSource.h" @@ -19,7 +20,7 @@ /// Wraps an ExternalASTSource into an ExternalSemaSource. Doesn't take /// ownership of the provided source. -class ExternalASTSourceWrapper : public clang::ExternalSemaSource { +class ExternalASTSourceWrapper : public ImporterBackedASTSource { ExternalASTSource *m_Source; public: @@ -239,7 +240,7 @@ /// provide more accurate replies to the requests, but might not be able to /// answer all requests. The debug information will be used as a fallback then /// to provide information that is not in the C++ module. -class SemaSourceWithPriorities : public clang::ExternalSemaSource { +class SemaSourceWithPriorities : public ImporterBackedASTSource { private: /// The sources ordered in decreasing priority. Index: lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h =================================================================== --- lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h +++ lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h @@ -13,6 +13,7 @@ #include "Plugins/ExpressionParser/Clang/ClangASTImporter.h" #include "Plugins/ExpressionParser/Clang/NameSearchContext.h" +#include "Plugins/TypeSystem/Clang/ImporterBackedASTSource.h" #include "lldb/Symbol/CompilerType.h" #include "lldb/Target/Target.h" #include "clang/AST/ExternalASTSource.h" @@ -30,7 +31,7 @@ /// knows the name it is looking for, but nothing else. The ExternalSemaSource /// class provides Decls (VarDecl, FunDecl, TypeDecl) to Clang for these /// names, consulting the ClangExpressionDeclMap to do the actual lookups. -class ClangASTSource : public clang::ExternalASTSource, +class ClangASTSource : public ImporterBackedASTSource, public ClangASTImporter::MapCompleter { public: /// Constructor Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.h =================================================================== --- lldb/source/Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.h +++ lldb/source/Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.h @@ -9,18 +9,21 @@ #ifndef LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGEXTERNALASTSOURCECALLBACKS_H #define LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGEXTERNALASTSOURCECALLBACKS_H +#include "Plugins/TypeSystem/Clang/ImporterBackedASTSource.h" #include "Plugins/TypeSystem/Clang/TypeSystemClang.h" #include "clang/Basic/Module.h" namespace lldb_private { -class ClangExternalASTSourceCallbacks : public clang::ExternalASTSource { +class ClangExternalASTSourceCallbacks : public ImporterBackedASTSource { /// LLVM RTTI support. static char ID; public: /// LLVM RTTI support. - bool isA(const void *ClassID) const override { return ClassID == &ID; } + bool isA(const void *ClassID) const override { + return ClassID == &ID || ImporterBackedASTSource::isA(ClassID); + } static bool classof(const clang::ExternalASTSource *s) { return s->isA(&ID); } ClangExternalASTSourceCallbacks(TypeSystemClang &ast) : m_ast(ast) {} Index: lldb/source/Plugins/TypeSystem/Clang/CMakeLists.txt =================================================================== --- lldb/source/Plugins/TypeSystem/Clang/CMakeLists.txt +++ lldb/source/Plugins/TypeSystem/Clang/CMakeLists.txt @@ -1,4 +1,5 @@ add_lldb_library(lldbPluginTypeSystemClang PLUGIN + ImporterBackedASTSource.cpp TypeSystemClang.cpp LINK_LIBS Index: lldb/source/Plugins/TypeSystem/Clang/ImporterBackedASTSource.h =================================================================== --- /dev/null +++ lldb/source/Plugins/TypeSystem/Clang/ImporterBackedASTSource.h @@ -0,0 +1,46 @@ +//===-- ImporterBackedASTSource.h -------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SOURCE_PLUGINS_TYPESYSTEM_CLANG_IMPORTERBACKEDASTSOURCE +#define LLDB_SOURCE_PLUGINS_TYPESYSTEM_CLANG_IMPORTERBACKEDASTSOURCE + +#include "clang/AST/ASTContext.h" +#include "clang/Sema/ExternalSemaSource.h" + +namespace lldb_private { + +/// The base class of all ExternalASTSources in LLDB that use the +/// ClangASTImporter to move declarations from other ASTs to the ASTContext they +/// are attached to. +class ImporterBackedASTSource : public clang::ExternalSemaSource { + /// LLVM RTTI support. + static char ID; + +public: + /// LLVM RTTI support. + bool isA(const void *ClassID) const override { + return ClassID == &ID || ExternalSemaSource::isA(ClassID); + } + static bool classof(const clang::ExternalASTSource *s) { return s->isA(&ID); } + + /// This marks all redeclaration chains in the ASTContext as out-of-date and + /// that this ExternalASTSource should be consulted to get the complete + /// redeclaration chain. + /// + /// \see ExternalASTSource::CompleteRedeclChain + void MarkRedeclChainsAsOutOfDate(clang::ASTContext &c) { + // This invalidates redeclaration chains but also other things such as + // identifiers. There isn't a more precise way at the moment that only + // affects redecl chains. + incrementGeneration(c); + } +}; + +} // namespace lldb_private + +#endif // LLDB_SOURCE_PLUGINS_TYPESYSTEM_CLANG_IMPORTERBACKEDASTSOURCE Index: lldb/source/Plugins/TypeSystem/Clang/ImporterBackedASTSource.cpp =================================================================== --- /dev/null +++ lldb/source/Plugins/TypeSystem/Clang/ImporterBackedASTSource.cpp @@ -0,0 +1,13 @@ +//===-- ImporterBackedASTSource.cpp ---------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "Plugins/TypeSystem/Clang/ImporterBackedASTSource.h" + +using namespace lldb_private; + +char ImporterBackedASTSource::ID;