#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/FrontendActions.h"
#include "clang/AST/ASTContext.h"
+#include "clang/AST/ASTDiagnostic.h"
#include "clang/AST/ASTImporter.h"
using namespace clang;
void ASTMergeAction::ExecuteAction() {
CompilerInstance &CI = getCompilerInstance();
-
+ CI.getDiagnostics().SetArgToStringFn(&FormatASTNodeDiagnosticArgument,
+ &CI.getASTContext());
for (unsigned I = 0, N = ASTFiles.size(); I != N; ++I) {
- ASTUnit *Unit = ASTUnit::LoadFromPCHFile(ASTFiles[I], CI.getDiagnostics(),
+ Diagnostic ASTDiags(CI.getDiagnostics().getClient());
+
+ ASTUnit *Unit = ASTUnit::LoadFromPCHFile(ASTFiles[I], ASTDiags,
false, true);
if (!Unit)
continue;
+ ASTDiags.SetArgToStringFn(&FormatASTNodeDiagnosticArgument,
+ &Unit->getASTContext());
ASTImporter Importer(CI.getASTContext(), CI.getDiagnostics(),
- Unit->getASTContext(), CI.getDiagnostics());
+ Unit->getASTContext(), ASTDiags);
TranslationUnitDecl *TU = Unit->getASTContext().getTranslationUnitDecl();
for (DeclContext::decl_iterator D = TU->decls_begin(),
if (VD->getIdentifier() &&
*VD->getIdentifier()->getNameStart() == 'x') {
Decl *Merged = Importer.Import(VD);
- if (Merged)
- Merged->dump();
+ (void)Merged;
}
}
// RUN: %clang_cc1 -emit-pch -o %t.2.ast %S/Inputs/var2.c
// RUN: %clang_cc1 -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only %s 2>&1 | FileCheck %s
-// CHECK: declared with incompatible types
+// CHECK: error: external variable 'x1' declared with incompatible types in different translation units ('double *' vs. 'float **')