clang  14.0.0git
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Friends | List of all members
clang::ASTImporter Class Reference

Imports selected nodes from one AST context into another context, merging AST nodes where appropriate. More...

#include "clang/AST/ASTImporter.h"

Classes

class  ImportPathTy
 

Public Types

enum  ODRHandlingType { ODRHandlingType::Conservative, ODRHandlingType::Liberal }
 
using NonEquivalentDeclSet = llvm::DenseSet< std::pair< Decl *, Decl * > >
 
using ImportedCXXBaseSpecifierMap = llvm::DenseMap< const CXXBaseSpecifier *, CXXBaseSpecifier * >
 

Public Member Functions

 ASTImporter (ASTContext &ToContext, FileManager &ToFileManager, ASTContext &FromContext, FileManager &FromFileManager, bool MinimalImport, std::shared_ptr< ASTImporterSharedState > SharedState=nullptr)
 
virtual ~ASTImporter ()
 
bool isMinimalImport () const
 Whether the importer will perform a minimal import, creating to-be-completed forward declarations when possible. More...
 
void setODRHandling (ODRHandlingType T)
 
template<typename ImportT >
LLVM_NODISCARD llvm::Error importInto (ImportT &To, const ImportT &From)
 Import the given object, returns the result. More...
 
llvm::Expected< ExprWithCleanups::CleanupObjectImport (ExprWithCleanups::CleanupObject From)
 Import cleanup objects owned by ExprWithCleanup. More...
 
llvm::Expected< const Type * > Import (const Type *FromT)
 Import the given type from the "from" context into the "to" context. More...
 
llvm::Expected< QualTypeImport (QualType FromT)
 Import the given qualified type from the "from" context into the "to" context. More...
 
llvm::Expected< TypeSourceInfo * > Import (TypeSourceInfo *FromTSI)
 Import the given type source information from the "from" context into the "to" context. More...
 
llvm::Expected< Attr * > Import (const Attr *FromAttr)
 Import the given attribute from the "from" context into the "to" context. More...
 
llvm::Expected< Decl * > Import (Decl *FromD)
 Import the given declaration from the "from" context into the "to" context. More...
 
llvm::Expected< const Decl * > Import (const Decl *FromD)
 
llvm::Expected< InheritedConstructorImport (const InheritedConstructor &From)
 
DeclGetAlreadyImportedOrNull (const Decl *FromD) const
 Return the copy of the given declaration in the "to" context if it has already been imported from the "from" context. More...
 
TranslationUnitDeclGetFromTU (Decl *ToD)
 Return the translation unit from where the declaration was imported. More...
 
template<typename DeclT >
llvm::Optional< DeclT * > getImportedFromDecl (const DeclT *ToD) const
 Return the declaration in the "from" context from which the declaration in the "to" context was imported. More...
 
llvm::Expected< DeclContext * > ImportContext (DeclContext *FromDC)
 Import the given declaration context from the "from" AST context into the "to" AST context. More...
 
llvm::Expected< Expr * > Import (Expr *FromE)
 Import the given expression from the "from" context into the "to" context. More...
 
llvm::Expected< Stmt * > Import (Stmt *FromS)
 Import the given statement from the "from" context into the "to" context. More...
 
llvm::Expected< NestedNameSpecifier * > Import (NestedNameSpecifier *FromNNS)
 Import the given nested-name-specifier from the "from" context into the "to" context. More...
 
llvm::Expected< NestedNameSpecifierLocImport (NestedNameSpecifierLoc FromNNS)
 Import the given nested-name-specifier-loc from the "from" context into the "to" context. More...
 
llvm::Expected< TemplateNameImport (TemplateName From)
 Import the given template name from the "from" context into the "to" context, or the import error. More...
 
llvm::Expected< SourceLocationImport (SourceLocation FromLoc)
 Import the given source location from the "from" context into the "to" context. More...
 
llvm::Expected< SourceRangeImport (SourceRange FromRange)
 Import the given source range from the "from" context into the "to" context. More...
 
llvm::Expected< DeclarationNameImport (DeclarationName FromName)
 Import the given declaration name from the "from" context into the "to" context. More...
 
IdentifierInfoImport (const IdentifierInfo *FromId)
 Import the given identifier from the "from" context into the "to" context. More...
 
llvm::Expected< SelectorImport (Selector FromSel)
 Import the given Objective-C selector from the "from" context into the "to" context. More...
 
llvm::Expected< FileIDImport (FileID, bool IsBuiltin=false)
 Import the given file ID from the "from" context into the "to" context. More...
 
llvm::Expected< CXXCtorInitializer * > Import (CXXCtorInitializer *FromInit)
 Import the given C++ constructor initializer from the "from" context into the "to" context. More...
 
llvm::Expected< CXXBaseSpecifier * > Import (const CXXBaseSpecifier *FromSpec)
 Import the given CXXBaseSpecifier from the "from" context into the "to" context. More...
 
llvm::Expected< APValueImport (const APValue &FromValue)
 Import the given APValue from the "from" context into the "to" context. More...
 
LLVM_NODISCARD llvm::Error ImportDefinition (Decl *From)
 Import the definition of the given declaration, including all of the declarations it contains. More...
 
virtual Expected< DeclarationNameHandleNameConflict (DeclarationName Name, DeclContext *DC, unsigned IDNS, NamedDecl **Decls, unsigned NumDecls)
 Cope with a name conflict when importing a declaration into the given context. More...
 
ASTContextgetToContext () const
 Retrieve the context that AST nodes are being imported into. More...
 
ASTContextgetFromContext () const
 Retrieve the context that AST nodes are being imported from. More...
 
FileManagergetToFileManager () const
 Retrieve the file manager that AST nodes are being imported into. More...
 
FileManagergetFromFileManager () const
 Retrieve the file manager that AST nodes are being imported from. More...
 
DiagnosticBuilder ToDiag (SourceLocation Loc, unsigned DiagID)
 Report a diagnostic in the "to" context. More...
 
DiagnosticBuilder FromDiag (SourceLocation Loc, unsigned DiagID)
 Report a diagnostic in the "from" context. More...
 
NonEquivalentDeclSetgetNonEquivalentDecls ()
 Return the set of declarations that we know are not equivalent. More...
 
virtual void CompleteDecl (Decl *D)
 Called for ObjCInterfaceDecl, ObjCProtocolDecl, and TagDecl. More...
 
virtual void Imported (Decl *From, Decl *To)
 Subclasses can override this function to observe all of the From -> To declaration mappings as they are imported. More...
 
void RegisterImportedDecl (Decl *FromD, Decl *ToD)
 
DeclMapImported (Decl *From, Decl *To)
 Store and assign the imported declaration to its counterpart. More...
 
virtual DeclGetOriginalDecl (Decl *To)
 Called by StructuralEquivalenceContext. More...
 
llvm::Optional< ImportErrorgetImportDeclErrorIfAny (Decl *FromD) const
 Return if import of the given declaration has failed and if yes the kind of the problem. More...
 
void setImportDeclError (Decl *From, ImportError Error)
 Mark (newly) imported declaration with error. More...
 
bool IsStructurallyEquivalent (QualType From, QualType To, bool Complain=true)
 Determine whether the given types are structurally equivalent. More...
 

Static Public Member Functions

static llvm::Optional< unsignedgetFieldIndex (Decl *F)
 Determine the index of a field in its parent record. More...
 

Protected Member Functions

virtual Expected< Decl * > ImportImpl (Decl *From)
 Can be overwritten by subclasses to implement their own import logic. More...
 
virtual bool returnWithErrorInTest ()
 Used only in unittests to verify the behaviour of the error handling. More...
 

Friends

class ASTNodeImporter
 

Detailed Description

Imports selected nodes from one AST context into another context, merging AST nodes where appropriate.

Definition at line 90 of file ASTImporter.h.

Member Typedef Documentation

◆ ImportedCXXBaseSpecifierMap

Definition at line 95 of file ASTImporter.h.

◆ NonEquivalentDeclSet

Definition at line 93 of file ASTImporter.h.

Member Enumeration Documentation

◆ ODRHandlingType

Enumerator
Conservative 
Liberal 

Definition at line 97 of file ASTImporter.h.

Constructor & Destructor Documentation

◆ ASTImporter()

ASTImporter::ASTImporter ( ASTContext ToContext,
FileManager ToFileManager,
ASTContext FromContext,
FileManager FromFileManager,
bool  MinimalImport,
std::shared_ptr< ASTImporterSharedState SharedState = nullptr 
)
Parameters
ToContextThe context we'll be importing into.
ToFileManagerThe file manager we'll be importing into.
FromContextThe context we'll be importing from.
FromFileManagerThe file manager we'll be importing into.
MinimalImportIf true, the importer will attempt to import as little as it can, e.g., by importing declarations as forward declarations that can be completed at a later point.
SharedStateThe importer specific lookup table which may be shared amongst several ASTImporter objects. If not set then the original C/C++ lookup is used.

Definition at line 8322 of file ASTImporter.cpp.

References clang::ASTContext::getTranslationUnitDecl(), and clang::Minimal.

◆ ~ASTImporter()

ASTImporter::~ASTImporter ( )
virtualdefault

Member Function Documentation

◆ CompleteDecl()

void ASTImporter::CompleteDecl ( Decl D)
virtual

Called for ObjCInterfaceDecl, ObjCProtocolDecl, and TagDecl.

Mark the Decl as complete, filling it in as much as possible.

Parameters
DA declaration in the "to" context.

Definition at line 9755 of file ASTImporter.cpp.

Referenced by ImportContext().

◆ FromDiag()

DiagnosticBuilder ASTImporter::FromDiag ( SourceLocation  Loc,
unsigned  DiagID 
)

◆ GetAlreadyImportedOrNull()

Decl * ASTImporter::GetAlreadyImportedOrNull ( const Decl FromD) const

Return the copy of the given declaration in the "to" context if it has already been imported from the "from" context.

Otherwise return nullptr.

Definition at line 8736 of file ASTImporter.cpp.

Referenced by Import(), and clang::ASTNodeImporter::ImportDeclContext().

◆ getFieldIndex()

Optional< unsigned > ASTImporter::getFieldIndex ( Decl F)
static

Determine the index of a field in its parent record.

F should be a field (or indirect field) declaration.

Returns
The index of the field in its parent context (starting from 0). On error None is returned (parent context is non-record).

Definition at line 8341 of file ASTImporter.cpp.

References clang::Decl::getDeclContext().

◆ getFromContext()

ASTContext& clang::ASTImporter::getFromContext ( ) const
inline

◆ getFromFileManager()

FileManager& clang::ASTImporter::getFromFileManager ( ) const
inline

Retrieve the file manager that AST nodes are being imported from.

Definition at line 556 of file ASTImporter.h.

◆ GetFromTU()

TranslationUnitDecl * ASTImporter::GetFromTU ( Decl ToD)

Return the translation unit from where the declaration was imported.

If it does not exist nullptr is returned.

Definition at line 8744 of file ASTImporter.cpp.

Referenced by clang::ASTNodeImporter::hasSameVisibilityContextAndLinkage().

◆ getImportDeclErrorIfAny()

llvm::Optional< ImportError > ASTImporter::getImportDeclErrorIfAny ( Decl FromD) const

Return if import of the given declaration has failed and if yes the kind of the problem.

This gives the first error encountered with the node.

Definition at line 9794 of file ASTImporter.cpp.

Referenced by Import().

◆ getImportedFromDecl()

template<typename DeclT >
llvm::Optional<DeclT *> clang::ASTImporter::getImportedFromDecl ( const DeclT *  ToD) const
inline

Return the declaration in the "from" context from which the declaration in the "to" context was imported.

If it was not imported or of the wrong type a null value is returned.

Definition at line 398 of file ASTImporter.h.

Referenced by clang::ASTNodeImporter::VisitCXXDefaultArgExpr().

◆ getNonEquivalentDecls()

NonEquivalentDeclSet& clang::ASTImporter::getNonEquivalentDecls ( )
inline

Return the set of declarations that we know are not equivalent.

Definition at line 565 of file ASTImporter.h.

Referenced by clang::ASTNodeImporter::IsStructuralMatch().

◆ GetOriginalDecl()

virtual Decl* clang::ASTImporter::GetOriginalDecl ( Decl To)
inlinevirtual

Called by StructuralEquivalenceContext.

If a RecordDecl is being compared to another RecordDecl as part of import, completing the other RecordDecl may trigger importation of the first RecordDecl. This happens especially for anonymous structs. If the original of the second RecordDecl can be found, we can complete it without the need for importation, eliminating this loop.

Definition at line 590 of file ASTImporter.h.

Referenced by clang::ASTNodeImporter::IsStructuralMatch().

◆ getToContext()

ASTContext& clang::ASTImporter::getToContext ( ) const
inline

Retrieve the context that AST nodes are being imported into.

Definition at line 547 of file ASTImporter.h.

Referenced by AttrImporter::cloneAttr(), clang::ASTNodeImporter::import(), AttrImporter::importAttr(), clang::ASTNodeImporter::ImportDefinition(), clang::ASTNodeImporter::ImportObjCTypeParamList(), clang::ASTNodeImporter::ImportTemplateInformation(), clang::ASTNodeImporter::IsStructuralMatch(), clang::ASTNodeImporter::VisitAccessSpecDecl(), clang::ASTNodeImporter::VisitAddrLabelExpr(), clang::ASTNodeImporter::VisitArrayInitIndexExpr(), clang::ASTNodeImporter::VisitArrayInitLoopExpr(), clang::ASTNodeImporter::VisitArraySubscriptExpr(), clang::ASTNodeImporter::VisitArrayTypeTraitExpr(), clang::ASTNodeImporter::VisitAtomicExpr(), clang::ASTNodeImporter::VisitAtomicType(), clang::ASTNodeImporter::VisitAttributedType(), clang::ASTNodeImporter::VisitAutoType(), clang::ASTNodeImporter::VisitBinaryConditionalOperator(), clang::ASTNodeImporter::VisitBinaryOperator(), clang::ASTNodeImporter::VisitBlockPointerType(), clang::ASTNodeImporter::VisitBuiltinTemplateDecl(), clang::ASTNodeImporter::VisitBuiltinType(), clang::ASTNodeImporter::VisitCallExpr(), clang::ASTNodeImporter::VisitCharacterLiteral(), clang::ASTNodeImporter::VisitChooseExpr(), clang::ASTNodeImporter::VisitClassTemplateSpecializationDecl(), clang::ASTNodeImporter::VisitComplexType(), clang::ASTNodeImporter::VisitCompoundAssignOperator(), clang::ASTNodeImporter::VisitCompoundLiteralExpr(), clang::ASTNodeImporter::VisitConditionalOperator(), clang::ASTNodeImporter::VisitConstantArrayType(), clang::ASTNodeImporter::VisitConstantExpr(), clang::ASTNodeImporter::VisitCXXBindTemporaryExpr(), clang::ASTNodeImporter::VisitCXXBoolLiteralExpr(), clang::ASTNodeImporter::VisitCXXConstructExpr(), clang::ASTNodeImporter::VisitCXXDefaultArgExpr(), clang::ASTNodeImporter::VisitCXXDefaultInitExpr(), clang::ASTNodeImporter::VisitCXXDeleteExpr(), clang::ASTNodeImporter::VisitCXXDependentScopeMemberExpr(), clang::ASTNodeImporter::VisitCXXFoldExpr(), clang::ASTNodeImporter::VisitCXXInheritedCtorInitExpr(), clang::ASTNodeImporter::VisitCXXMemberCallExpr(), clang::ASTNodeImporter::VisitCXXNamedCastExpr(), clang::ASTNodeImporter::VisitCXXNewExpr(), clang::ASTNodeImporter::VisitCXXNoexceptExpr(), clang::ASTNodeImporter::VisitCXXNullPtrLiteralExpr(), clang::ASTNodeImporter::VisitCXXPseudoDestructorExpr(), clang::ASTNodeImporter::VisitCXXScalarValueInitExpr(), clang::ASTNodeImporter::VisitCXXStdInitializerListExpr(), clang::ASTNodeImporter::VisitCXXTemporaryObjectExpr(), clang::ASTNodeImporter::VisitCXXThisExpr(), clang::ASTNodeImporter::VisitCXXThrowExpr(), clang::ASTNodeImporter::VisitCXXTypeidExpr(), clang::ASTNodeImporter::VisitCXXUnresolvedConstructExpr(), clang::ASTNodeImporter::VisitDecayedType(), clang::ASTNodeImporter::VisitDeclRefExpr(), clang::ASTNodeImporter::VisitDecltypeType(), clang::ASTNodeImporter::VisitDeducedTemplateSpecializationType(), clang::ASTNodeImporter::VisitDependentScopeDeclRefExpr(), clang::ASTNodeImporter::VisitDependentSizedArrayType(), clang::ASTNodeImporter::VisitDependentTemplateSpecializationType(), clang::ASTNodeImporter::VisitDesignatedInitExpr(), clang::ASTNodeImporter::VisitElaboratedType(), clang::ASTNodeImporter::VisitEmptyDecl(), clang::ASTNodeImporter::VisitEnumType(), clang::ASTNodeImporter::VisitExplicitCastExpr(), clang::ASTNodeImporter::VisitExpressionTraitExpr(), clang::ASTNodeImporter::VisitExprWithCleanups(), clang::ASTNodeImporter::VisitExtVectorType(), clang::ASTNodeImporter::VisitFixedPointLiteral(), clang::ASTNodeImporter::VisitFloatingLiteral(), clang::ASTNodeImporter::VisitFriendDecl(), clang::ASTNodeImporter::VisitFunctionNoProtoType(), clang::ASTNodeImporter::VisitFunctionProtoType(), clang::ASTNodeImporter::VisitGenericSelectionExpr(), clang::ASTNodeImporter::VisitGNUNullExpr(), clang::ASTNodeImporter::VisitImaginaryLiteral(), clang::ASTNodeImporter::VisitImplicitCastExpr(), clang::ASTNodeImporter::VisitImplicitParamDecl(), clang::ASTNodeImporter::VisitImplicitValueInitExpr(), clang::ASTNodeImporter::VisitIncompleteArrayType(), clang::ASTNodeImporter::VisitInitListExpr(), clang::ASTNodeImporter::VisitInjectedClassNameType(), clang::ASTNodeImporter::VisitIntegerLiteral(), clang::ASTNodeImporter::VisitLambdaExpr(), clang::ASTNodeImporter::VisitLinkageSpecDecl(), clang::ASTNodeImporter::VisitLValueReferenceType(), clang::ASTNodeImporter::VisitMaterializeTemporaryExpr(), clang::ASTNodeImporter::VisitMemberExpr(), clang::ASTNodeImporter::VisitMemberPointerType(), clang::ASTNodeImporter::VisitNonTypeTemplateParmDecl(), clang::ASTNodeImporter::VisitObjCCategoryImplDecl(), clang::ASTNodeImporter::VisitObjCImplementationDecl(), clang::ASTNodeImporter::VisitObjCInterfaceType(), clang::ASTNodeImporter::VisitObjCObjectPointerType(), clang::ASTNodeImporter::VisitObjCObjectType(), clang::ASTNodeImporter::VisitObjCPropertyImplDecl(), clang::ASTNodeImporter::VisitOffsetOfExpr(), clang::ASTNodeImporter::VisitOpaqueValueExpr(), clang::ASTNodeImporter::VisitPackExpansionExpr(), clang::ASTNodeImporter::VisitPackExpansionType(), clang::ASTNodeImporter::VisitParenExpr(), clang::ASTNodeImporter::VisitParenListExpr(), clang::ASTNodeImporter::VisitParenType(), clang::ASTNodeImporter::VisitParmVarDecl(), clang::ASTNodeImporter::VisitPointerType(), clang::ASTNodeImporter::VisitPredefinedExpr(), clang::ASTNodeImporter::VisitRecordType(), clang::ASTNodeImporter::VisitRValueReferenceType(), clang::ASTNodeImporter::VisitShuffleVectorExpr(), clang::ASTNodeImporter::VisitSizeOfPackExpr(), clang::ASTNodeImporter::VisitSourceLocExpr(), clang::ASTNodeImporter::VisitStaticAssertDecl(), clang::ASTNodeImporter::VisitStmtExpr(), clang::ASTNodeImporter::VisitStringLiteral(), clang::ASTNodeImporter::VisitSubstNonTypeTemplateParmExpr(), clang::ASTNodeImporter::VisitSubstTemplateTypeParmPackType(), clang::ASTNodeImporter::VisitSubstTemplateTypeParmType(), clang::ASTNodeImporter::VisitTemplateSpecializationType(), clang::ASTNodeImporter::VisitTemplateTemplateParmDecl(), clang::ASTNodeImporter::VisitTemplateTypeParmDecl(), clang::ASTNodeImporter::VisitTemplateTypeParmType(), clang::ASTNodeImporter::VisitTranslationUnitDecl(), clang::ASTNodeImporter::VisitTypedefType(), clang::ASTNodeImporter::VisitTypeOfExprType(), clang::ASTNodeImporter::VisitTypeOfType(), clang::ASTNodeImporter::VisitTypeTraitExpr(), clang::ASTNodeImporter::VisitUnaryExprOrTypeTraitExpr(), clang::ASTNodeImporter::VisitUnaryOperator(), clang::ASTNodeImporter::VisitUnaryTransformType(), clang::ASTNodeImporter::VisitUnresolvedLookupExpr(), clang::ASTNodeImporter::VisitUnresolvedMemberExpr(), clang::ASTNodeImporter::VisitUnresolvedUsingType(), clang::ASTNodeImporter::VisitVAArgExpr(), clang::ASTNodeImporter::VisitVariableArrayType(), clang::ASTNodeImporter::VisitVarTemplateSpecializationDecl(), and clang::ASTNodeImporter::VisitVectorType().

◆ getToFileManager()

FileManager& clang::ASTImporter::getToFileManager ( ) const
inline

Retrieve the file manager that AST nodes are being imported into.

Definition at line 553 of file ASTImporter.h.

◆ HandleNameConflict()

Expected< DeclarationName > ASTImporter::HandleNameConflict ( DeclarationName  Name,
DeclContext DC,
unsigned  IDNS,
NamedDecl **  Decls,
unsigned  NumDecls 
)
virtual

Cope with a name conflict when importing a declaration into the given context.

This routine is invoked whenever there is a name conflict while importing a declaration. The returned name will become the name of the imported declaration. By default, the returned name is the same as the original name, leaving the conflict unresolve such that name lookup for this name is likely to find an ambiguity later.

Subclasses may override this routine to resolve the conflict, e.g., by renaming the declaration being imported.

Parameters
Namethe name of the declaration being imported, which conflicts with other declarations.
DCthe declaration context (in the "to" AST context) in which the name is being imported.
IDNSthe identifier namespace in which the name will be found.
Declsthe set of declarations with the same name as the declaration being imported.
NumDeclsthe number of conflicting declarations in Decls.
Returns
the name that the newly-imported declaration should have. Or an error if we can't handle the name conflict.

Definition at line 9726 of file ASTImporter.cpp.

◆ Import() [1/22]

llvm::Expected< APValue > ASTImporter::Import ( const APValue FromValue)

Import the given APValue from the "from" context into the "to" context.

Returns
the equivalent APValue in the "to" context or the import error.

Definition at line 9430 of file ASTImporter.cpp.

References clang::ASTNodeImporter::ImportAPValue().

◆ Import() [2/22]

Expected< Attr * > ASTImporter::Import ( const Attr FromAttr)

Import the given attribute from the "from" context into the "to" context.

Returns
The equivalent attribute in the "to" context, or the import error.

Definition at line 8602 of file ASTImporter.cpp.

References AttrImporter::cloneAttr(), clang::Attr::getKind(), Import(), AttrImporter::importArg(), AttrImporter::importArrayArg(), and AttrImporter::importAttr().

◆ Import() [3/22]

Expected< CXXBaseSpecifier * > ASTImporter::Import ( const CXXBaseSpecifier FromSpec)

◆ Import() [4/22]

llvm::Expected<const Decl *> clang::ASTImporter::Import ( const Decl FromD)
inline

Definition at line 378 of file ASTImporter.h.

References Import().

◆ Import() [5/22]

IdentifierInfo * ASTImporter::Import ( const IdentifierInfo FromId)

Import the given identifier from the "from" context into the "to" context.

Returns
The equivalent identifier in the "to" context. Note: It returns nullptr only if the FromId was nullptr.

Definition at line 9542 of file ASTImporter.cpp.

References clang::IdentifierTable::get(), clang::IdentifierInfo::getBuiltinID(), clang::IdentifierInfo::getName(), clang::ASTContext::Idents, and clang::IdentifierInfo::setBuiltinID().

◆ Import() [6/22]

llvm::Expected< InheritedConstructor > ASTImporter::Import ( const InheritedConstructor From)

Definition at line 8891 of file ASTImporter.cpp.

References ASTNodeImporter.

◆ Import() [7/22]

ExpectedTypePtr ASTImporter::Import ( const Type FromT)

Import the given type from the "from" context into the "to" context.

Returns
The equivalent type in the "to" context, or the import error.

Definition at line 8422 of file ASTImporter.cpp.

References clang::TypeVisitor< ImplClass, RetTy >::Visit().

◆ Import() [8/22]

Expected< CXXCtorInitializer * > ASTImporter::Import ( CXXCtorInitializer FromInit)

◆ Import() [9/22]

Expected< Decl * > ASTImporter::Import ( Decl FromD)

◆ Import() [10/22]

Expected< DeclarationName > ASTImporter::Import ( DeclarationName  FromName)

Import the given declaration name from the "from" context into the "to" context.

Returns
The equivalent declaration name in the "to" context, or the import error.

Definition at line 9478 of file ASTImporter.cpp.

References clang::DeclarationName::CXXConstructorName, clang::DeclarationName::CXXConversionFunctionName, clang::DeclarationName::CXXDeductionGuideName, clang::DeclarationName::CXXDestructorName, clang::DeclarationName::CXXLiteralOperatorName, clang::DeclarationName::CXXOperatorName, clang::DeclarationName::CXXUsingDirective, clang::ASTContext::DeclarationNames, clang::DeclarationName::getAsIdentifierInfo(), clang::ASTContext::getCanonicalType(), clang::DeclarationNameTable::getCXXConstructorName(), clang::DeclarationNameTable::getCXXConversionFunctionName(), clang::DeclarationNameTable::getCXXDeductionGuideName(), clang::DeclarationName::getCXXDeductionGuideTemplate(), clang::DeclarationNameTable::getCXXDestructorName(), clang::DeclarationName::getCXXLiteralIdentifier(), clang::DeclarationNameTable::getCXXLiteralOperatorName(), clang::DeclarationName::getCXXNameType(), clang::DeclarationNameTable::getCXXOperatorName(), clang::DeclarationName::getCXXOverloadedOperator(), clang::DeclarationName::getNameKind(), clang::DeclarationName::getObjCSelector(), clang::DeclarationName::getUsingDirectiveName(), clang::DeclarationName::Identifier, Import(), clang::DeclarationName::ObjCMultiArgSelector, clang::DeclarationName::ObjCOneArgSelector, and clang::DeclarationName::ObjCZeroArgSelector.

◆ Import() [11/22]

Expected< Expr * > ASTImporter::Import ( Expr FromE)

Import the given expression from the "from" context into the "to" context.

Returns
The equivalent expression in the "to" context, or the import error.

Definition at line 8962 of file ASTImporter.cpp.

References Import().

◆ Import() [12/22]

◆ Import() [13/22]

Expected< FileID > ASTImporter::Import ( FileID  FromID,
bool  IsBuiltin = false 
)

◆ Import() [14/22]

Expected< NestedNameSpecifier * > ASTImporter::Import ( NestedNameSpecifier FromNNS)

◆ Import() [15/22]

Expected< NestedNameSpecifierLoc > ASTImporter::Import ( NestedNameSpecifierLoc  FromNNS)

Import the given nested-name-specifier-loc from the "from" context into the "to" context.

Returns
The equivalent nested-name-specifier-loc in the "to" context, or the import error.

Definition at line 9053 of file ASTImporter.cpp.

References clang::NestedNameSpecifierLoc::getPrefix().

◆ Import() [16/22]

Expected< QualType > ASTImporter::Import ( QualType  FromT)

Import the given qualified type from the "from" context into the "to" context.

A null type is imported as a null type (no error).

Returns
The equivalent type in the "to" context, or the import error.

Definition at line 8444 of file ASTImporter.cpp.

References clang::QualType::getLocalQualifiers(), clang::ASTContext::getQualifiedType(), clang::QualType::getTypePtr(), Import(), and clang::QualType::isNull().

◆ Import() [17/22]

Expected< Selector > ASTImporter::Import ( Selector  FromSel)

Import the given Objective-C selector from the "from" context into the "to" context.

Returns
The equivalent selector in the "to" context, or the import error.

Definition at line 9554 of file ASTImporter.cpp.

References clang::Selector::getIdentifierInfoForSlot(), clang::Selector::getNumArgs(), clang::SelectorTable::getSelector(), Import(), clang::Selector::isNull(), and clang::ASTContext::Selectors.

◆ Import() [18/22]

Expected< SourceLocation > ASTImporter::Import ( SourceLocation  FromLoc)

Import the given source location from the "from" context into the "to" context.

Returns
The equivalent source location in the "to" context, or the import error.

Definition at line 9232 of file ASTImporter.cpp.

References clang::SourceManager::getComposedLoc(), clang::SourceManager::getDecomposedLoc(), clang::ASTContext::getSourceManager(), Import(), clang::SourceLocation::isInvalid(), and clang::SourceManager::isWrittenInBuiltinFile().

◆ Import() [19/22]

Expected< SourceRange > ASTImporter::Import ( SourceRange  FromRange)

Import the given source range from the "from" context into the "to" context.

Returns
The equivalent source range in the "to" context, or the import error.

Definition at line 9247 of file ASTImporter.cpp.

References clang::SourceRange::getBegin(), clang::SourceRange::getEnd(), and importInto().

◆ Import() [20/22]

Expected< Stmt * > ASTImporter::Import ( Stmt FromS)

Import the given statement from the "from" context into the "to" context.

Returns
The equivalent statement in the "to" context, or the import error.

Definition at line 8969 of file ASTImporter.cpp.

References clang::TypeVisitor< ImplClass, RetTy >::Visit().

◆ Import() [21/22]

Expected< TemplateName > ASTImporter::Import ( TemplateName  From)

Import the given template name from the "from" context into the "to" context, or the import error.

Definition at line 9138 of file ASTImporter.cpp.

References clang::UnresolvedSetImpl::addDecl(), clang::TemplateName::AssumedTemplate, clang::UnresolvedSetImpl::begin(), clang::TemplateName::DependentTemplate, clang::UnresolvedSetImpl::end(), clang::SubstTemplateTemplateParmPackStorage::getArgumentPack(), clang::TemplateName::getAsAssumedTemplateName(), clang::TemplateName::getAsDependentTemplateName(), clang::TemplateName::getAsOverloadedTemplate(), clang::TemplateName::getAsQualifiedTemplateName(), clang::TemplateName::getAsSubstTemplateTemplateParm(), clang::TemplateName::getAsSubstTemplateTemplateParmPack(), clang::ASTContext::getAssumedTemplateName(), clang::TemplateName::getAsTemplateDecl(), clang::AssumedTemplateStorage::getDeclName(), clang::ASTContext::getDependentTemplateName(), clang::DependentTemplateName::getIdentifier(), clang::TemplateName::getKind(), clang::DependentTemplateName::getOperator(), clang::ASTContext::getOverloadedTemplateName(), clang::SubstTemplateTemplateParmStorage::getParameter(), clang::SubstTemplateTemplateParmPackStorage::getParameterPack(), clang::ASTContext::getQualifiedTemplateName(), clang::QualifiedTemplateName::getQualifier(), clang::DependentTemplateName::getQualifier(), clang::SubstTemplateTemplateParmStorage::getReplacement(), clang::ASTContext::getSubstTemplateTemplateParm(), clang::ASTContext::getSubstTemplateTemplateParmPack(), clang::QualifiedTemplateName::hasTemplateKeyword(), Import(), clang::ASTNodeImporter::ImportTemplateArgument(), clang::DependentTemplateName::isIdentifier(), clang::TemplateName::OverloadedTemplate, clang::TemplateName::QualifiedTemplate, clang::TemplateName::SubstTemplateTemplateParm, clang::TemplateName::SubstTemplateTemplateParmPack, and clang::TemplateName::Template.

◆ Import() [22/22]

Expected< TypeSourceInfo * > ASTImporter::Import ( TypeSourceInfo FromTSI)

Import the given type source information from the "from" context into the "to" context.

Returns
The equivalent type source information in the "to" context, or the import error.

Definition at line 8455 of file ASTImporter.cpp.

References clang::TypeLoc::getBeginLoc(), clang::ASTContext::getTrivialTypeSourceInfo(), clang::TypeSourceInfo::getType(), clang::TypeSourceInfo::getTypeLoc(), and Import().

◆ ImportContext()

Expected< DeclContext * > ASTImporter::ImportContext ( DeclContext FromDC)

◆ ImportDefinition()

Error ASTImporter::ImportDefinition ( Decl From)

Import the definition of the given declaration, including all of the declarations it contains.

Definition at line 9435 of file ASTImporter.cpp.

References clang::ASTNodeImporter::IDK_Everything, Import(), clang::ASTNodeImporter::ImportDeclContext(), and clang::ASTNodeImporter::ImportDefinition().

Referenced by clang::ExternalASTMerger::CompleteType().

◆ Imported()

virtual void clang::ASTImporter::Imported ( Decl From,
Decl To 
)
inlinevirtual

Subclasses can override this function to observe all of the From -> To declaration mappings as they are imported.

Definition at line 575 of file ASTImporter.h.

Referenced by Import().

◆ ImportImpl()

Expected< Decl * > ASTImporter::ImportImpl ( Decl From)
protectedvirtual

Can be overwritten by subclasses to implement their own import logic.

The overwritten method should call this method if it didn't import the decl on its own.

Definition at line 8400 of file ASTImporter.cpp.

References clang::TypeVisitor< ImplClass, RetTy >::Visit().

Referenced by Import().

◆ importInto()

template<typename ImportT >
LLVM_NODISCARD llvm::Error clang::ASTImporter::importInto ( ImportT &  To,
const ImportT &  From 
)
inline

Import the given object, returns the result.

Parameters
ToImport the object into this variable.
FromObject to import.
Returns
Error information (success or error).

Definition at line 335 of file ASTImporter.h.

References Import().

Referenced by Import().

◆ isMinimalImport()

bool clang::ASTImporter::isMinimalImport ( ) const
inline

Whether the importer will perform a minimal import, creating to-be-completed forward declarations when possible.

Definition at line 325 of file ASTImporter.h.

References clang::Minimal.

Referenced by getStructuralEquivalenceKind(), clang::ASTNodeImporter::ImportDeclContext(), and clang::ASTNodeImporter::shouldForceImportDeclContext().

◆ IsStructurallyEquivalent()

bool ASTImporter::IsStructurallyEquivalent ( QualType  From,
QualType  To,
bool  Complain = true 
)

◆ MapImported()

Decl * ASTImporter::MapImported ( Decl From,
Decl To 
)

◆ RegisterImportedDecl()

void ASTImporter::RegisterImportedDecl ( Decl FromD,
Decl ToD 
)

Definition at line 8406 of file ASTImporter.cpp.

References MapImported().

◆ returnWithErrorInTest()

virtual bool clang::ASTImporter::returnWithErrorInTest ( )
inlineprotectedvirtual

Used only in unittests to verify the behaviour of the error handling.

Definition at line 297 of file ASTImporter.h.

◆ setImportDeclError()

void ASTImporter::setImportDeclError ( Decl From,
ImportError  Error 
)

Mark (newly) imported declaration with error.

Definition at line 9802 of file ASTImporter.cpp.

Referenced by Import().

◆ setODRHandling()

void clang::ASTImporter::setODRHandling ( ODRHandlingType  T)
inline

Definition at line 327 of file ASTImporter.h.

◆ ToDiag()

DiagnosticBuilder ASTImporter::ToDiag ( SourceLocation  Loc,
unsigned  DiagID 
)

Friends And Related Function Documentation

◆ ASTNodeImporter

friend class ASTNodeImporter
friend

Definition at line 91 of file ASTImporter.h.

Referenced by Import(), and ImportContext().


The documentation for this class was generated from the following files: