forked from OSchip/llvm-project
Implement AST import for C++ member functions, including constructors, destructors, and conversions. Unfortunately, this cannot be tested yet, since we don't have C++ PCH support.
llvm-svn: 96741
This commit is contained in:
parent
f18a2c7dd1
commit
00eace1958
|
@ -91,6 +91,10 @@ namespace {
|
||||||
Decl *VisitRecordDecl(RecordDecl *D);
|
Decl *VisitRecordDecl(RecordDecl *D);
|
||||||
Decl *VisitEnumConstantDecl(EnumConstantDecl *D);
|
Decl *VisitEnumConstantDecl(EnumConstantDecl *D);
|
||||||
Decl *VisitFunctionDecl(FunctionDecl *D);
|
Decl *VisitFunctionDecl(FunctionDecl *D);
|
||||||
|
Decl *VisitCXXMethodDecl(CXXMethodDecl *D);
|
||||||
|
Decl *VisitCXXConstructorDecl(CXXConstructorDecl *D);
|
||||||
|
Decl *VisitCXXDestructorDecl(CXXDestructorDecl *D);
|
||||||
|
Decl *VisitCXXConversionDecl(CXXConversionDecl *D);
|
||||||
Decl *VisitFieldDecl(FieldDecl *D);
|
Decl *VisitFieldDecl(FieldDecl *D);
|
||||||
Decl *VisitObjCIvarDecl(ObjCIvarDecl *D);
|
Decl *VisitObjCIvarDecl(ObjCIvarDecl *D);
|
||||||
Decl *VisitVarDecl(VarDecl *D);
|
Decl *VisitVarDecl(VarDecl *D);
|
||||||
|
@ -1855,11 +1859,33 @@ Decl *ASTNodeImporter::VisitFunctionDecl(FunctionDecl *D) {
|
||||||
|
|
||||||
// Create the imported function.
|
// Create the imported function.
|
||||||
TypeSourceInfo *TInfo = Importer.Import(D->getTypeSourceInfo());
|
TypeSourceInfo *TInfo = Importer.Import(D->getTypeSourceInfo());
|
||||||
FunctionDecl *ToFunction
|
FunctionDecl *ToFunction = 0;
|
||||||
= FunctionDecl::Create(Importer.getToContext(), DC, Loc,
|
if (CXXConstructorDecl *FromConstructor = dyn_cast<CXXConstructorDecl>(D)) {
|
||||||
|
ToFunction = CXXConstructorDecl::Create(Importer.getToContext(),
|
||||||
|
cast<CXXRecordDecl>(DC),
|
||||||
|
Loc, Name, T, TInfo,
|
||||||
|
FromConstructor->isExplicit(),
|
||||||
|
D->isInlineSpecified(),
|
||||||
|
D->isImplicit());
|
||||||
|
} else if (isa<CXXDestructorDecl>(D)) {
|
||||||
|
ToFunction = CXXDestructorDecl::Create(Importer.getToContext(),
|
||||||
|
cast<CXXRecordDecl>(DC),
|
||||||
|
Loc, Name, T,
|
||||||
|
D->isInlineSpecified(),
|
||||||
|
D->isImplicit());
|
||||||
|
} else if (CXXConversionDecl *FromConversion
|
||||||
|
= dyn_cast<CXXConversionDecl>(D)) {
|
||||||
|
ToFunction = CXXConversionDecl::Create(Importer.getToContext(),
|
||||||
|
cast<CXXRecordDecl>(DC),
|
||||||
|
Loc, Name, T, TInfo,
|
||||||
|
D->isInlineSpecified(),
|
||||||
|
FromConversion->isExplicit());
|
||||||
|
} else {
|
||||||
|
ToFunction = FunctionDecl::Create(Importer.getToContext(), DC, Loc,
|
||||||
Name, T, TInfo, D->getStorageClass(),
|
Name, T, TInfo, D->getStorageClass(),
|
||||||
D->isInlineSpecified(),
|
D->isInlineSpecified(),
|
||||||
D->hasWrittenPrototype());
|
D->hasWrittenPrototype());
|
||||||
|
}
|
||||||
ToFunction->setLexicalDeclContext(LexicalDC);
|
ToFunction->setLexicalDeclContext(LexicalDC);
|
||||||
Importer.Imported(D, ToFunction);
|
Importer.Imported(D, ToFunction);
|
||||||
LexicalDC->addDecl(ToFunction);
|
LexicalDC->addDecl(ToFunction);
|
||||||
|
@ -1876,6 +1902,22 @@ Decl *ASTNodeImporter::VisitFunctionDecl(FunctionDecl *D) {
|
||||||
return ToFunction;
|
return ToFunction;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Decl *ASTNodeImporter::VisitCXXMethodDecl(CXXMethodDecl *D) {
|
||||||
|
return VisitFunctionDecl(D);
|
||||||
|
}
|
||||||
|
|
||||||
|
Decl *ASTNodeImporter::VisitCXXConstructorDecl(CXXConstructorDecl *D) {
|
||||||
|
return VisitCXXMethodDecl(D);
|
||||||
|
}
|
||||||
|
|
||||||
|
Decl *ASTNodeImporter::VisitCXXDestructorDecl(CXXDestructorDecl *D) {
|
||||||
|
return VisitCXXMethodDecl(D);
|
||||||
|
}
|
||||||
|
|
||||||
|
Decl *ASTNodeImporter::VisitCXXConversionDecl(CXXConversionDecl *D) {
|
||||||
|
return VisitCXXMethodDecl(D);
|
||||||
|
}
|
||||||
|
|
||||||
Decl *ASTNodeImporter::VisitFieldDecl(FieldDecl *D) {
|
Decl *ASTNodeImporter::VisitFieldDecl(FieldDecl *D) {
|
||||||
// Import the major distinguishing characteristics of a variable.
|
// Import the major distinguishing characteristics of a variable.
|
||||||
DeclContext *DC, *LexicalDC;
|
DeclContext *DC, *LexicalDC;
|
||||||
|
|
Loading…
Reference in New Issue