From a4a90cabfa15c900016a7cfaea51a6d4e8ebf4db Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Fri, 3 May 2013 22:58:43 +0000 Subject: When building a module, forward diagnostics to the outer diagnostic consumer. Previously, we would clone the current diagnostic consumer to produce a new diagnostic consumer to use when building a module. The problem here is that we end up losing diagnostics for important diagnostic consumers, such as serialized diagnostics (where we'd end up with two diagnostic consumers writing the same output file). With forwarding, the diagnostics from all of the different modules being built get forwarded to the one serialized-diagnostic consumer and are emitted in a sane way. Fixes . git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181067 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Basic/Diagnostic.h | 20 ++++++++++++++++++++ include/clang/Lex/ModuleMap.h | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/clang/Basic/Diagnostic.h b/include/clang/Basic/Diagnostic.h index 032763672b..2d9d288964 100644 --- a/include/clang/Basic/Diagnostic.h +++ b/include/clang/Basic/Diagnostic.h @@ -1319,6 +1319,26 @@ class IgnoringDiagConsumer : public DiagnosticConsumer { } }; +/// \brief Diagnostic consumer that forwards diagnostics along to an +/// existing, already-initialized diagnostic consumer. +/// +class ForwardingDiagnosticConsumer : public DiagnosticConsumer { + DiagnosticConsumer &Target; + +public: + ForwardingDiagnosticConsumer(DiagnosticConsumer &Target) : Target(Target) {} + + virtual ~ForwardingDiagnosticConsumer(); + + virtual void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel, + const Diagnostic &Info); + virtual void clear(); + + virtual bool IncludeInDiagnosticCounts() const; + + virtual DiagnosticConsumer *clone(DiagnosticsEngine &Diags) const; +}; + // Struct used for sending info about how a type should be printed. struct TemplateDiffTypes { intptr_t FromType; diff --git a/include/clang/Lex/ModuleMap.h b/include/clang/Lex/ModuleMap.h index 33c92f59a4..dc75f1803c 100644 --- a/include/clang/Lex/ModuleMap.h +++ b/include/clang/Lex/ModuleMap.h @@ -161,7 +161,7 @@ public: /// \param LangOpts Language options for this translation unit. /// /// \param Target The target for this translation unit. - ModuleMap(FileManager &FileMgr, const DiagnosticConsumer &DC, + ModuleMap(FileManager &FileMgr, DiagnosticConsumer &DC, const LangOptions &LangOpts, const TargetInfo *Target, HeaderSearch &HeaderInfo); -- cgit v1.2.3-18-g5258