File indexing completed on 2026-05-10 08:36:28
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef LLVM_CLANG_AST_ASTIMPORTERSHAREDSTATE_H
0015 #define LLVM_CLANG_AST_ASTIMPORTERSHAREDSTATE_H
0016
0017 #include "clang/AST/ASTImportError.h"
0018 #include "clang/AST/ASTImporterLookupTable.h"
0019 #include "clang/AST/Decl.h"
0020 #include "llvm/ADT/DenseMap.h"
0021 #include <optional>
0022
0023 namespace clang {
0024
0025 class TranslationUnitDecl;
0026
0027
0028
0029 class ASTImporterSharedState {
0030
0031
0032 std::unique_ptr<ASTImporterLookupTable> LookupTable;
0033
0034
0035
0036
0037
0038
0039
0040 llvm::DenseMap<Decl *, ASTImportError> ImportErrors;
0041
0042
0043 llvm::DenseSet<Decl *> NewDecls;
0044
0045
0046
0047
0048 public:
0049 ASTImporterSharedState() = default;
0050
0051 ASTImporterSharedState(TranslationUnitDecl &ToTU) {
0052 LookupTable = std::make_unique<ASTImporterLookupTable>(ToTU);
0053 }
0054
0055 ASTImporterLookupTable *getLookupTable() { return LookupTable.get(); }
0056
0057 void addDeclToLookup(Decl *D) {
0058 if (LookupTable)
0059 if (auto *ND = dyn_cast<NamedDecl>(D))
0060 LookupTable->add(ND);
0061 }
0062
0063 void removeDeclFromLookup(Decl *D) {
0064 if (LookupTable)
0065 if (auto *ND = dyn_cast<NamedDecl>(D))
0066 LookupTable->remove(ND);
0067 }
0068
0069 std::optional<ASTImportError> getImportDeclErrorIfAny(Decl *ToD) const {
0070 auto Pos = ImportErrors.find(ToD);
0071 if (Pos != ImportErrors.end())
0072 return Pos->second;
0073 else
0074 return std::nullopt;
0075 }
0076
0077 void setImportDeclError(Decl *To, ASTImportError Error) {
0078 ImportErrors[To] = Error;
0079 }
0080
0081 bool isNewDecl(const Decl *ToD) const { return NewDecls.count(ToD); }
0082
0083 void markAsNewDecl(Decl *ToD) { NewDecls.insert(ToD); }
0084 };
0085
0086 }
0087 #endif