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:
Sean Callanan 2015-04-28 18:24:12 +00:00
parent 20b0ce3abd
commit 61ea0571ac
2 changed files with 12 additions and 1 deletions

View File

@ -79,6 +79,11 @@ namespace clang {
}
void Initialize(ASTContext &Ctx) override {
if (Context) {
assert(Context == &Ctx);
return;
}
Context = &Ctx;
if (llvm::TimePassesIsEnabled)

View File

@ -57,6 +57,7 @@ void ASTMergeAction::ExecuteAction() {
/*MinimalImport=*/false);
TranslationUnitDecl *TU = Unit->getASTContext().getTranslationUnitDecl();
CI.getASTConsumer().Initialize(CI.getASTContext());
for (auto *D : TU->decls()) {
// Don't re-import __va_list_tag, __builtin_va_list.
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"))
continue;
Importer.Import(D);
Decl *ToD = Importer.Import(D);
if (ToD) {
DeclGroupRef DGR(ToD);
CI.getASTConsumer().HandleTopLevelDecl(DGR);
}
}
}