diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2010-11-18 20:06:41 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2010-11-18 20:06:41 +0000 |
commit | d00406486421143c5e4eb79f9ce97e30442b1ab2 (patch) | |
tree | eb2ff8461358578c978f17ddfa7f597b9f6a1022 /clang/lib/Frontend/ASTMerge.cpp | |
parent | 4fadc5b20a3afbad542e0841692dc851d0507136 (diff) | |
download | bcm5719-llvm-d00406486421143c5e4eb79f9ce97e30442b1ab2.tar.gz bcm5719-llvm-d00406486421143c5e4eb79f9ce97e30442b1ab2.zip |
Refactoring of Diagnostic class.
-Move the stuff of Diagnostic related to creating/querying diagnostic IDs into a new DiagnosticIDs class.
-DiagnosticIDs can be shared among multiple Diagnostics for multiple translation units.
-The rest of the state in Diagnostic object is considered related and tied to one translation unit.
-Have Diagnostic point to the SourceManager that is related with. Diagnostic can now accept just a
SourceLocation instead of a FullSourceLoc.
-Reflect the changes to various interfaces.
llvm-svn: 119730
Diffstat (limited to 'clang/lib/Frontend/ASTMerge.cpp')
-rw-r--r-- | clang/lib/Frontend/ASTMerge.cpp | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/clang/lib/Frontend/ASTMerge.cpp b/clang/lib/Frontend/ASTMerge.cpp index f2708463430..7c8763d09d9 100644 --- a/clang/lib/Frontend/ASTMerge.cpp +++ b/clang/lib/Frontend/ASTMerge.cpp @@ -38,21 +38,18 @@ void ASTMergeAction::ExecuteAction() { CI.getASTContext().getLangOptions()); CI.getDiagnostics().SetArgToStringFn(&FormatASTNodeDiagnosticArgument, &CI.getASTContext()); - llvm::IntrusiveRefCntPtr<Diagnostic> Diags(&CI.getDiagnostics()); + llvm::IntrusiveRefCntPtr<DiagnosticIDs> + DiagIDs(CI.getDiagnostics().getDiagnosticIDs()); for (unsigned I = 0, N = ASTFiles.size(); I != N; ++I) { + llvm::IntrusiveRefCntPtr<Diagnostic> + Diags(new Diagnostic(DiagIDs, CI.getDiagnostics().getClient(), + /*ShouldOwnClient=*/false)); ASTUnit *Unit = ASTUnit::LoadFromASTFile(ASTFiles[I], Diags, CI.getFileSystemOpts(), false); if (!Unit) continue; - // Reset the argument -> string function so that it has the AST - // context we want, since the Sema object created by - // LoadFromASTFile will override it. - CI.getDiagnostics().SetArgToStringFn(&FormatASTNodeDiagnosticArgument, - &CI.getASTContext()); - - ASTImporter Importer(CI.getDiagnostics(), - CI.getASTContext(), + ASTImporter Importer(CI.getASTContext(), CI.getFileManager(), CI.getFileSystemOpts(), Unit->getASTContext(), @@ -72,6 +69,15 @@ void ASTMergeAction::ExecuteAction() { Importer.Import(*D); } + // Aggregate the number of warnings/errors from all diagnostics so + // that at CompilerInstance::ExecuteAction we can report the total numbers. + // FIXME: This is hacky, maybe keep track of total number of warnings/errors + // in DiagnosticClient and have CompilerInstance query that ? + CI.getDiagnostics().setNumWarnings(CI.getDiagnostics().getNumWarnings() + + Diags->getNumWarnings()); + CI.getDiagnostics().setNumErrors(CI.getDiagnostics().getNumErrors() + + Diags->getNumErrors()); + delete Unit; } |