14 #ifndef LLVM_CLANG_AST_ASTIMPORTER_H 15 #define LLVM_CLANG_AST_ASTIMPORTER_H 26 #include "llvm/ADT/DenseMap.h" 27 #include "llvm/ADT/DenseSet.h" 28 #include "llvm/ADT/Optional.h" 29 #include "llvm/ADT/SmallVector.h" 30 #include "llvm/Support/Error.h" 36 class ASTImporterSharedState;
38 class CXXBaseSpecifier;
39 class CXXCtorInitializer;
47 class TranslationUnitDecl;
73 void log(raw_ostream &OS)
const override;
93 llvm::DenseMap<const CXXBaseSpecifier *, CXXBaseSpecifier *>;
193 auto Pos = Aux.find(
Nodes.back());
194 return Pos != Aux.end() && Pos->second > 1;
197 using Cycle = llvm::iterator_range<VecTy::const_reverse_iterator>;
199 assert(
Nodes.size() >= 2);
207 auto R = getCycleAtBack();
208 return VecTy(R.begin(), R.end());
217 llvm::SmallDenseMap<Decl *, int, 32> Aux;
223 std::shared_ptr<ASTImporterSharedState> SharedState =
nullptr;
232 using SavedImportPathsTy =
233 llvm::SmallDenseMap<Decl *, SavedImportPathsForOneDecl, 32>;
234 SavedImportPathsTy SavedImportPaths;
248 bool LastDiagFromFrom =
false;
252 llvm::DenseMap<const Type *, const Type *> ImportedTypes;
256 llvm::DenseMap<Decl *, Decl *> ImportedDecls;
264 llvm::DenseMap<Decl *, ImportError> ImportDeclErrors;
268 llvm::DenseMap<Decl *, Decl *> ImportedFromDecls;
272 llvm::DenseMap<Stmt *, Stmt *> ImportedStmts;
276 llvm::DenseMap<FileID, FileID> ImportedFileIDs;
290 void AddToLookupTable(
Decl *ToD);
321 std::shared_ptr<ASTImporterSharedState> SharedState =
nullptr);
330 FileIDImportHandler = H;
344 template <
typename ImportT>
346 auto ToOrErr = Import(From);
349 return ToOrErr.takeError();
379 return Import(const_cast<Decl *>(FromD));
385 Decl *GetAlreadyImportedOrNull(
const Decl *FromD)
const;
394 template <
typename DeclT>
396 auto FromI = ImportedFromDecls.find(ToD);
397 if (FromI == ImportedFromDecls.end())
399 auto *FromD = dyn_cast<DeclT>(FromI->second);
561 virtual void CompleteDecl(
Decl* D);
567 void RegisterImportedDecl(
Decl *FromD,
Decl *ToD);
593 bool Complain =
true);
604 #endif // LLVM_CLANG_AST_ASTIMPORTER_H
Smart pointer class that efficiently represents Objective-C method names.
A (possibly-)qualified type.
Implements support for file system lookup, file system caching, and directory search management...
Stmt - This represents one statement.
C Language Family Type Representation.
Decl - This represents one declaration (or definition), e.g.
Cycle getCycleAtBack() const
VecTy copyCycleAtBack() const
Returns the copy of the cycle.
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
A container of type source information.
Not supported node or case.
virtual bool returnWithErrorInTest()
Used only in unittests to verify the behaviour of the error handling.
virtual Decl * GetOriginalDecl(Decl *To)
Called by StructuralEquivalenceContext.
llvm::iterator_range< VecTy::const_reverse_iterator > Cycle
FileManager & getFromFileManager() const
Retrieve the file manager that AST nodes are being imported from.
BoundNodesTreeBuilder Nodes
One of these records is kept for each identifier that is lexed.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
A C++ nested-name-specifier augmented with source location information.
ImportError & operator=(const ImportError &Other)
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
llvm::Optional< DeclT * > getImportedFromDecl(const DeclT *ToD) const
Return the declaration in the "from" context from which the declaration in the "to" context was impor...
Defines the Diagnostic-related interfaces.
void log(raw_ostream &OS) const override
llvm::DenseMap< const CXXBaseSpecifier *, CXXBaseSpecifier * > ImportedCXXBaseSpecifierMap
ASTContext & getToContext() const
Retrieve the context that AST nodes are being imported into.
A little helper class used to produce diagnostics.
This represents one expression.
Represents a C++ template name within the type system.
llvm::SmallVector< Decl *, 2 > getCanonicalForwardRedeclChain(Decl *D)
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
std::error_code convertToErrorCode() const override
ImportError(ErrorKind Error)
void setFileIDImportHandler(FileIDImportHandlerType H)
Set a callback function for FileID import handling.
Encodes a location in the source.
static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context, QualType T1, QualType T2)
Determine structural equivalence of two types.
ImportError(const ImportError &Other)
virtual void Imported(Decl *From, Decl *To)
Subclasses can override this function to observe all of the From -> To declaration mappings as they a...
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
bool isMinimalImport() const
Whether the importer will perform a minimal import, creating to-be-completed forward declarations whe...
FileManager & getToFileManager() const
Retrieve the file manager that AST nodes are being imported into.
void setODRHandling(ODRHandlingType T)
Naming ambiguity (likely ODR violation).
llvm::Expected< const Decl * > Import(const Decl *FromD)
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
NonEquivalentDeclSet & getNonEquivalentDecls()
Return the set of declarations that we know are not equivalent.
Dataflow Directional Tag Classes.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
bool hasCycleAtBack() const
Returns true if the last element can be found earlier in the path.
LLVM_NODISCARD llvm::Error importInto(ImportT &To, const ImportT &From)
Import the given object, returns the result.
The name of a declaration.
Imports selected nodes from one AST context into another context, merging AST nodes where appropriate...
Represents a C++ base or member initializer.
Represents a base class of a C++ class.
Defines the clang::SourceLocation class and associated facilities.
ASTContext & getFromContext() const
Retrieve the context that AST nodes are being imported from.
The top declaration context.
std::string toString() const
A trivial tuple used to represent a source range.
This represents a decl that may have a name.
std::function< void(FileID, FileID)> FileIDImportHandlerType
Attr - This represents one attribute.
ErrorKind
Kind of error when importing an AST component.