Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 50 additions & 2 deletions interpreter/llvm/src/tools/clang/lib/AST/ASTImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,11 @@ namespace clang {
// FIXME: DependentDecltypeType
QualType VisitRecordType(const RecordType *T);
QualType VisitEnumType(const EnumType *T);
// FIXME: TemplateTypeParmType
QualType VisitTemplateTypeParmType(const TemplateTypeParmType *T);
// FIXME: SubstTemplateTypeParmType
QualType VisitTemplateSpecializationType(const TemplateSpecializationType *T);
QualType VisitElaboratedType(const ElaboratedType *T);
QualType VisitInjectedClassNameType(const InjectedClassNameType *T);
// FIXME: DependentNameType
// FIXME: DependentTemplateSpecializationType
QualType VisitObjCInterfaceType(const ObjCInterfaceType *T);
Expand Down Expand Up @@ -144,6 +145,7 @@ namespace clang {
Decl *VisitCXXConversionDecl(CXXConversionDecl *D);
Decl *VisitFieldDecl(FieldDecl *D);
Decl *VisitIndirectFieldDecl(IndirectFieldDecl *D);
Decl *VisitAccessSpecDecl(AccessSpecDecl *D);
Decl *VisitObjCIvarDecl(ObjCIvarDecl *D);
Decl *VisitVarDecl(VarDecl *D);
Decl *VisitImplicitParamDecl(ImplicitParamDecl *D);
Expand Down Expand Up @@ -1724,6 +1726,18 @@ QualType ASTNodeImporter::VisitEnumType(const EnumType *T) {
return Importer.getToContext().getTagDeclType(ToDecl);
}

QualType ASTNodeImporter::VisitTemplateTypeParmType(const TemplateTypeParmType *T) {
TemplateTypeParmDecl *ToDecl
= dyn_cast_or_null<TemplateTypeParmDecl>(Importer.Import(T->getDecl()));
if (!ToDecl)
return QualType();

return Importer.getToContext().getTemplateTypeParmType(T->getDepth(),
T->getIndex(),
T->isParameterPack(),
ToDecl);
}

QualType ASTNodeImporter::VisitTemplateSpecializationType(
const TemplateSpecializationType *T) {
TemplateName ToTemplate = Importer.Import(T->getTemplateName());
Expand Down Expand Up @@ -1765,6 +1779,15 @@ QualType ASTNodeImporter::VisitElaboratedType(const ElaboratedType *T) {
ToQualifier, ToNamedType);
}

QualType ASTNodeImporter::VisitInjectedClassNameType(const InjectedClassNameType *T) {
CXXRecordDecl *ToDecl
= dyn_cast_or_null<CXXRecordDecl>(Importer.Import(T->getDecl()));
if (!ToDecl)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not:

if (CXXRecordDecl* ToDecl = dyn_cast<CXXRecordDecl>(Importer.Import(T->getDecl())
  Importer.getToContext().getTagDeclType(ToDecl);
return QualType();

return QualType();

return Importer.getToContext().getTagDeclType(ToDecl);
}

QualType ASTNodeImporter::VisitObjCInterfaceType(const ObjCInterfaceType *T) {
ObjCInterfaceDecl *Class
= dyn_cast_or_null<ObjCInterfaceDecl>(Importer.Import(T->getDecl()));
Expand Down Expand Up @@ -2850,6 +2873,31 @@ static unsigned getFieldIndex(Decl *F) {
return Index;
}

Decl *ASTNodeImporter::VisitAccessSpecDecl(AccessSpecDecl *D) {

SourceLocation Loc = Importer.Import(D->getLocation());
SourceLocation ColonLoc = Importer.Import(D->getColonLoc());

// Import the context of this declaration.
DeclContext *DC = Importer.ImportContext(D->getDeclContext());
if (!DC)
return nullptr;

AccessSpecDecl *accessSpecDecl
= AccessSpecDecl::Create(Importer.getToContext(), D->getAccess(),
DC, Loc, ColonLoc);

if (!accessSpecDecl)
return nullptr;

// Lexical DeclContext and Semantic DeclContext
// is always the same for the accessSpec.
accessSpecDecl->setLexicalDeclContext(DC);
DC->addDeclInternal(accessSpecDecl);

return accessSpecDecl;
}

Decl *ASTNodeImporter::VisitFieldDecl(FieldDecl *D) {
// Import the major distinguishing characteristics of a variable.
DeclContext *DC, *LexicalDC;
Expand Down Expand Up @@ -4073,7 +4121,7 @@ Decl *ASTNodeImporter::VisitClassTemplateDecl(ClassTemplateDecl *D) {

if (DTemplated->isCompleteDefinition() &&
!D2Templated->isCompleteDefinition()) {
// FIXME: Import definition!
ImportDefinition(DTemplated, D2Templated);
}

return D2;
Expand Down