[clang] e4b3fc1 - Get rid of -Wunused warnings in release build, NFC.

Haojian Wu via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 16 00:54:23 PDT 2020


On Mon, 15 Jun 2020 at 18:29, David Blaikie <dblaikie at gmail.com> wrote:

> I don't think the comment's adding value here - it should be fairly
> clear from the context that the whole loop only exists for some
> assertions.
>
> Also: Could you remove the "(void)" casts now that the whole thing's
> wrapped in NDEBUG?
>

oops, I think this is coincident, there were two patches at the same time
to fix the issue.
Cleaned it up in  e00dcf61a2f4397c0525db7133503b80d8ecf5ac.


> (an alternative way of phrasing this that doesn't require the #ifdef
> would be using nested llvm::all_of calls, but that would mean the
> assertion firing wouldn't point to a particular mismatched pair, just
> that overall the data structures were mismatched - if you think that
> this isn't especially likely/wouldn't be super hard to debug with
> that, maybe the assert would be more compact/tidier?
>
> assert(llvm::all_of(Dependencies, [&](const auto &DepPair) {
>   return llvm::all_of(WeakDependencies, [&](const auto &WeakDepPair) {
>     return WeakDepPair != DepPair && WeakDepPair.first !=
> DepPair.second && WeakDepPair.second != DepPair.second;
>   }
> }) && "...");
>

I'm not the author of this code, defer the decision to the author Kirstóf,
dkszelethus at gmail.com.


> On Fri, Jun 12, 2020 at 6:45 AM Haojian Wu via cfe-commits
> <cfe-commits at lists.llvm.org> wrote:
> >
> >
> > Author: Haojian Wu
> > Date: 2020-06-12T15:42:29+02:00
> > New Revision: e4b3fc18d33199e2081d300f14687d81be48b6a0
> >
> > URL:
> https://github.com/llvm/llvm-project/commit/e4b3fc18d33199e2081d300f14687d81be48b6a0
> > DIFF:
> https://github.com/llvm/llvm-project/commit/e4b3fc18d33199e2081d300f14687d81be48b6a0.diff
> >
> > LOG: Get rid of -Wunused warnings in release build, NFC.
> >
> > Added:
> >
> >
> > Modified:
> >     clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
> >
> > Removed:
> >
> >
> >
> >
> ################################################################################
> > diff  --git a/clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
> b/clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
> > index c2ca9c12b025..4a7e0d91ea23 100644
> > --- a/clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
> > +++ b/clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
> > @@ -285,6 +285,7 @@ CheckerRegistry::CheckerRegistry(
> >    resolveDependencies<true>();
> >    resolveDependencies<false>();
> >
> > +#ifndef NDEBUG // avoid -Wunused warnings in release build.
> >    for (auto &DepPair : Dependencies) {
> >      for (auto &WeakDepPair : WeakDependencies) {
> >        // Some assertions to enforce that strong dependencies are
> relations in
> > @@ -298,6 +299,7 @@ CheckerRegistry::CheckerRegistry(
> >               "A strong dependency mustn't be a weak dependency as
> well!");
> >      }
> >    }
> > +#endif
> >
> >    resolveCheckerAndPackageOptions();
> >
> >
> >
> >
> > _______________________________________________
> > cfe-commits mailing list
> > cfe-commits at lists.llvm.org
> > https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200616/58ab5011/attachment.html>


More information about the cfe-commits mailing list