forked from OSchip/llvm-project
Implemented support for testing the ASTImporter's
ability to generate code that CodeGen likes. Test cases can use this functionality by calling // RUN: %clang_cc1 -emit-obj -o /dev/null -ast-merge %t.1.ast -ast-merge %t.2.ast %s llvm-svn: 236011
This commit is contained in:
parent
20b0ce3abd
commit
61ea0571ac
|
@ -79,6 +79,11 @@ namespace clang {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Initialize(ASTContext &Ctx) override {
|
void Initialize(ASTContext &Ctx) override {
|
||||||
|
if (Context) {
|
||||||
|
assert(Context == &Ctx);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Context = &Ctx;
|
Context = &Ctx;
|
||||||
|
|
||||||
if (llvm::TimePassesIsEnabled)
|
if (llvm::TimePassesIsEnabled)
|
||||||
|
|
|
@ -57,6 +57,7 @@ void ASTMergeAction::ExecuteAction() {
|
||||||
/*MinimalImport=*/false);
|
/*MinimalImport=*/false);
|
||||||
|
|
||||||
TranslationUnitDecl *TU = Unit->getASTContext().getTranslationUnitDecl();
|
TranslationUnitDecl *TU = Unit->getASTContext().getTranslationUnitDecl();
|
||||||
|
CI.getASTConsumer().Initialize(CI.getASTContext());
|
||||||
for (auto *D : TU->decls()) {
|
for (auto *D : TU->decls()) {
|
||||||
// Don't re-import __va_list_tag, __builtin_va_list.
|
// Don't re-import __va_list_tag, __builtin_va_list.
|
||||||
if (const auto *ND = dyn_cast<NamedDecl>(D))
|
if (const auto *ND = dyn_cast<NamedDecl>(D))
|
||||||
|
@ -64,7 +65,12 @@ void ASTMergeAction::ExecuteAction() {
|
||||||
if (II->isStr("__va_list_tag") || II->isStr("__builtin_va_list"))
|
if (II->isStr("__va_list_tag") || II->isStr("__builtin_va_list"))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Importer.Import(D);
|
Decl *ToD = Importer.Import(D);
|
||||||
|
|
||||||
|
if (ToD) {
|
||||||
|
DeclGroupRef DGR(ToD);
|
||||||
|
CI.getASTConsumer().HandleTopLevelDecl(DGR);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue