aboutsummaryrefslogtreecommitdiff
path: root/include/clang/AST/ASTImporterSharedState.h
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2019-08-20 20:50:49 +0000
committerDimitry Andric <dim@FreeBSD.org>2019-08-20 20:50:49 +0000
commit2298981669bf3bd63335a4be179bc0f96823a8f4 (patch)
tree1cbe2eb27f030d2d70b80ee5ca3c86bee7326a9f /include/clang/AST/ASTImporterSharedState.h
parent9a83721404652cea39e9f02ae3e3b5c964602a5c (diff)
Vendor import of stripped clang trunk r366426 (just before thevendor/clang/clang-trunk-r366426
Notes
Notes: svn path=/vendor/clang/dist/; revision=351280 svn path=/vendor/clang/clang-trunk-r366426/; revision=351281; tag=vendor/clang/clang-trunk-r366426
Diffstat (limited to 'include/clang/AST/ASTImporterSharedState.h')
-rw-r--r--include/clang/AST/ASTImporterSharedState.h81
1 files changed, 81 insertions, 0 deletions
diff --git a/include/clang/AST/ASTImporterSharedState.h b/include/clang/AST/ASTImporterSharedState.h
new file mode 100644
index 000000000000..3635a62deef0
--- /dev/null
+++ b/include/clang/AST/ASTImporterSharedState.h
@@ -0,0 +1,81 @@
+//===- ASTImporterSharedState.h - ASTImporter specific state --*- C++ -*---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines the ASTImporter specific state, which may be shared
+// amongst several ASTImporter objects.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_AST_ASTIMPORTERSHAREDSTATE_H
+#define LLVM_CLANG_AST_ASTIMPORTERSHAREDSTATE_H
+
+#include "clang/AST/ASTImporterLookupTable.h"
+#include "clang/AST/Decl.h"
+#include "llvm/ADT/DenseMap.h"
+// FIXME We need this because of ImportError.
+#include "clang/AST/ASTImporter.h"
+
+namespace clang {
+
+class TranslationUnitDecl;
+
+/// Importer specific state, which may be shared amongst several ASTImporter
+/// objects.
+class ASTImporterSharedState {
+
+ /// Pointer to the import specific lookup table.
+ std::unique_ptr<ASTImporterLookupTable> LookupTable;
+
+ /// Mapping from the already-imported declarations in the "to"
+ /// context to the error status of the import of that declaration.
+ /// This map contains only the declarations that were not correctly
+ /// imported. The same declaration may or may not be included in
+ /// ImportedFromDecls. This map is updated continuously during imports and
+ /// never cleared (like ImportedFromDecls).
+ llvm::DenseMap<Decl *, ImportError> ImportErrors;
+
+ // FIXME put ImportedFromDecls here!
+ // And from that point we can better encapsulate the lookup table.
+
+public:
+ ASTImporterSharedState() = default;
+
+ ASTImporterSharedState(TranslationUnitDecl &ToTU) {
+ LookupTable = llvm::make_unique<ASTImporterLookupTable>(ToTU);
+ }
+
+ ASTImporterLookupTable *getLookupTable() { return LookupTable.get(); }
+
+ void addDeclToLookup(Decl *D) {
+ if (LookupTable)
+ if (auto *ND = dyn_cast<NamedDecl>(D))
+ LookupTable->add(ND);
+ }
+
+ void removeDeclFromLookup(Decl *D) {
+ if (LookupTable)
+ if (auto *ND = dyn_cast<NamedDecl>(D))
+ LookupTable->remove(ND);
+ }
+
+ llvm::Optional<ImportError> getImportDeclErrorIfAny(Decl *ToD) const {
+ auto Pos = ImportErrors.find(ToD);
+ if (Pos != ImportErrors.end())
+ return Pos->second;
+ else
+ return Optional<ImportError>();
+ }
+
+ void setImportDeclError(Decl *To, ImportError Error) {
+ ImportErrors[To] = Error;
+ }
+};
+
+} // namespace clang
+#endif // LLVM_CLANG_AST_ASTIMPORTERSHAREDSTATE_H