[PATCH] D82728: [clang] Add -Wsuggest-override

David Blaikie via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 7 15:09:14 PDT 2020


dblaikie added a comment.

In D82728#2137061 <https://reviews.llvm.org/D82728#2137061>, @logan-5 wrote:

> In D82728#2137021 <https://reviews.llvm.org/D82728#2137021>, @dblaikie wrote:
>
> > I think it might be nice to make the -Wno-inconsistent-missing-override -Wsuggest-override situation a bit better (by having it still do the same thing as -Wsuggest-override) but I don't feel /too/ strongly about it.
>
>
> So, ironing this out would mean the code would need this structure:
>
>   if (Inconsistent && IsWarningEnabled(-Winconsistent-missing-override))
>        Emit(-Winconsistent-missing-override);
>    else
>        Emit(-Wsuggest-override);
>
> The issue is that I wasn't able to find a way to ask if a warning is enabled and make a control flow decision based on that. If there is an API for doing this, it's hidden well. :) So I fell back to just doing `if (Inconsistent)` instead, which has this quirk if the inconsistent version of the warning is disabled.


Oh, yep, there's a way - it's usually used for performance-costly warnings, to not spend the resources computing the warning if it's disabled anyway.

Here's an arbitrary example: https://github.com/llvm-mirror/clang/blob/master/lib/Sema/SemaDecl.cpp#L7237


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82728/new/

https://reviews.llvm.org/D82728





More information about the cfe-commits mailing list