diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-02-09 22:37:58 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-02-09 22:37:58 +0000 |
commit | 6b2a4745311e5283e6d42def33570a9a4e063199 (patch) | |
tree | 9489ddc657ac6bd590d9d8ef0750a331c785c6ab /clang/lib/Frontend/ASTMerge.cpp | |
parent | b618f66c5fdc3c273bbbf2a514e4a98ed691afc6 (diff) | |
download | llvm-6b2a4745311e5283e6d42def33570a9a4e063199.zip llvm-6b2a4745311e5283e6d42def33570a9a4e063199.tar.gz llvm-6b2a4745311e5283e6d42def33570a9a4e063199.tar.bz2 |
Hook up the diagnostics-argument printer when merging AST files, so
that we get readable diagnostics such as:
error: external variable 'x1' declared with incompatible types in
different translation units ('double *' vs. 'float **')
However, there is no translation of source locations, yet.
llvm-svn: 95704
Diffstat (limited to 'clang/lib/Frontend/ASTMerge.cpp')
-rw-r--r-- | clang/lib/Frontend/ASTMerge.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/clang/lib/Frontend/ASTMerge.cpp b/clang/lib/Frontend/ASTMerge.cpp index 649af9e..e88d295 100644 --- a/clang/lib/Frontend/ASTMerge.cpp +++ b/clang/lib/Frontend/ASTMerge.cpp @@ -10,6 +10,7 @@ #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; @@ -31,15 +32,20 @@ bool ASTMergeAction::BeginSourceFileAction(CompilerInstance &CI, 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(), @@ -51,8 +57,7 @@ void ASTMergeAction::ExecuteAction() { if (VD->getIdentifier() && *VD->getIdentifier()->getNameStart() == 'x') { Decl *Merged = Importer.Import(VD); - if (Merged) - Merged->dump(); + (void)Merged; } } |