[patch] Check for isDiagnosticEnabled even if we have a dig handler

Duncan P. N. Exon Smith dexonsmith at apple.com
Tue Mar 3 12:42:58 PST 2015


> On 2015-Mar-03, at 12:25, Rafael EspĂ­ndola <rafael.espindola at gmail.com> wrote:
> 
> Currently if there is a diagnostic handler it gets passed every
> remark. This means that the gold plugin can only choose to print all
> or none of them.
> 
> This patch move the check for isDiagnosticEnabled earlier which lets
> the gold plugin handle things like -pass-remarks=inline.
> 
> Cheers,
> Rafael

> diff --git a/lib/IR/LLVMContext.cpp b/lib/IR/LLVMContext.cpp
> index b6d95c4..fc9d987 100644
> --- a/lib/IR/LLVMContext.cpp
> +++ b/lib/IR/LLVMContext.cpp
> @@ -189,6 +189,9 @@ static bool isDiagnosticEnabled(const DiagnosticInfo &DI) {
>  }
>  
>  void LLVMContext::diagnose(const DiagnosticInfo &DI) {
> +  if (!isDiagnosticEnabled(DI))
> +    return;
> +
>    // If there is a report handler, use it.
>    if (pImpl->DiagnosticHandler) {
>      if (!pImpl->RespectDiagnosticFilters || isDiagnosticEnabled(DI))

We had the same problem in libLTO, and I added `RespectDiagnosticFilters` in
r218784 to avoid breaking anyone using the old behaviour.  Maybe that wasn't
important -- I may have been too conservative? -- but we should be consistent.
(Maybe I did this because of `clang`... does it have its own filters?)

> @@ -196,9 +199,6 @@ void LLVMContext::diagnose(const DiagnosticInfo &DI) {
>      return;
>    }
>  
> -  if (!isDiagnosticEnabled(DI))
> -    return;
> -
>    // Otherwise, print the message with a prefix based on the severity.
>    std::string MsgStorage;
>    raw_string_ostream Stream(MsgStorage);






More information about the llvm-commits mailing list