[PATCH] D82425: [SemaCXX] Fix false positive of -Wuninitialized-const-reference in empty function body.
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 6 12:54:03 PDT 2020
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.
LGTM despite my enduring sadness that Boost elected to use this totally bizarre approach to silencing unused variable diagnostics when far better-supported options have existed for so long.
================
Comment at: clang/lib/Analysis/UninitializedValues.cpp:435
if ((*I)->getType().isConstQualified())
- classify((*I), ConstRefUse);
+ if (!hasTrivialBody(CE))
+ classify((*I), ConstRefUse);
----------------
zequanwu wrote:
> nick wrote:
> > zequanwu wrote:
> > > aaron.ballman wrote:
> > > > This can be hoisted out of the loop so that we don't have to check the same thing on every argument.
> > > The `DeclRefExpr` needs to be set to `Ignore` like `VisitCastExpr` does. Otherwise, it maybe classified to `Init` by `isTrackedVar` in `ClassifyRefs::get`.
> > Could not the empty body check be done in `reportConstRefUse`, after `isUninitialized`?
> No, `reportConstRefUse` doesn't know if the called function has trivial body or not.
You made the change I was looking for -- I just needed the `hasTrivialBody()` call hoisted since that was invariant within the loop body.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D82425/new/
https://reviews.llvm.org/D82425
More information about the cfe-commits
mailing list