[PATCH] D79895: Add a new warning to warn when passing uninitialized variables as const reference parameters to a function

2020-06-23 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment. In D79895#2110345 , @nick wrote: > > We didn't see it in the code bases I work with, so is boost a special case, > > or an example of a common practice? > > I do not have resources to make such statistics, but there are

[PATCH] D79895: Add a new warning to warn when passing uninitialized variables as const reference parameters to a function

2020-06-23 Thread Nikita Kniazev via Phabricator via cfe-commits
nick added a comment. > We didn't see it in the code bases I work with, so is boost a special case, > or an example of a common practice? I do not have resources to make such statistics, but there are compilers where casting to void is not enough to suppress the warning.

[PATCH] D79895: Add a new warning to warn when passing uninitialized variables as const reference parameters to a function

2020-06-23 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment. In D79895#2109414 , @nick wrote: > > I feel like doing interprocedural analysis for this is overkill. What is > > the benefit of boost::ignore_unused(foo); rather than the more common > > (void) foo;? Any examples? > > > > > I

[PATCH] D79895: Add a new warning to warn when passing uninitialized variables as const reference parameters to a function

2020-06-23 Thread Nikita Kniazev via Phabricator via cfe-commits
nick added a comment. > I feel like doing interprocedural analysis for this is overkill. What is the > benefit of boost::ignore_unused(foo); rather than the more common (void) > foo;? Any examples? > I haven't seen boost::ignore_unused before. In my experience, the idiomatic > way of

[PATCH] D79895: Add a new warning to warn when passing uninitialized variables as const reference parameters to a function

2020-06-23 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment. In D79895#2107604 , @nick wrote: > This diagnostic bring headaches because frequently `-Wunused-variable` > suppression is done via no-op pseudo-consuming function like > `boost::ignore_unused` >

[PATCH] D79895: Add a new warning to warn when passing uninitialized variables as const reference parameters to a function

2020-06-22 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment. In D79895#2107796 , @nick wrote: > > This warning can be turned off by the flag > > `-Wno-uninitialized-const-reference`. > > Suggesting to turn off the warning should be the last resort. I am pointing > to the false positives

[PATCH] D79895: Add a new warning to warn when passing uninitialized variables as const reference parameters to a function

2020-06-22 Thread Nikita Kniazev via Phabricator via cfe-commits
nick added a comment. > This warning can be turned off by the flag > `-Wno-uninitialized-const-reference`. Suggesting to turn off the warning should be the last resort. I am pointing to the false positives for large existing code bases from `-Wall` diagnostic. > I don't think we can just make

[PATCH] D79895: Add a new warning to warn when passing uninitialized variables as const reference parameters to a function

2020-06-22 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu added a comment. In D79895#2107604 , @nick wrote: > This diagnostic bring headaches because frequently `-Wunused-variable` > suppression is done via no-op pseudo-consuming function like > `boost::ignore_unused` >

[PATCH] D79895: Add a new warning to warn when passing uninitialized variables as const reference parameters to a function

2020-06-22 Thread Nikita Kniazev via Phabricator via cfe-commits
nick added a comment. This diagnostic bring headaches because frequently `-Wunused-variable` suppression is done via no-op pseudo-consuming function like `boost::ignore_unused` . Particularly, it fires in Boost

[PATCH] D79895: Add a new warning to warn when passing uninitialized variables as const reference parameters to a function

2020-06-04 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu added a comment. In D79895#2073698 , @sylvestre.ledru wrote: > @zequanwu could you please update the release notes? thanks > https://github.com/llvm/llvm-project/blob/master/clang/docs/ReleaseNotes.rst Done. Repository: rG LLVM Github

[PATCH] D79895: Add a new warning to warn when passing uninitialized variables as const reference parameters to a function

2020-06-04 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added a comment. @zequanwu could you please update the release notes? thanks https://github.com/llvm/llvm-project/blob/master/clang/docs/ReleaseNotes.rst Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D79895/new/

[PATCH] D79895: Add a new warning to warn when passing uninitialized variables as const reference parameters to a function

2020-06-02 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu marked an inline comment as done. zequanwu added inline comments. Comment at: clang/lib/Analysis/UninitializedValues.cpp:676 + Value v = vals[vd]; + if (isUninitialized(v)) +handler.handleConstRefUseOfUninitVariable(vd, getUninitUse(ex, vd, v));

[PATCH] D79895: Add a new warning to warn when passing uninitialized variables as const reference parameters to a function

2020-06-02 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments. Comment at: clang/lib/Analysis/UninitializedValues.cpp:676 + Value v = vals[vd]; + if (isUninitialized(v)) +handler.handleConstRefUseOfUninitVariable(vd, getUninitUse(ex, vd, v)); This should use isAlwaysUninit. I fixed it in

[PATCH] D79895: Add a new warning to warn when passing uninitialized variables as const reference parameters to a function

2020-06-02 Thread Zequan Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes. Closed by commit rG170b6869b563: [Clang] Add a new warning to warn when passing uninitialized variables as const… (authored by zequanwu). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION

[PATCH] D79895: Add a new warning to warn when passing uninitialized variables as const reference parameters to a function

2020-06-02 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu updated this revision to Diff 267922. zequanwu added a comment. Rebase and address comments. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D79895/new/ https://reviews.llvm.org/D79895 Files: clang/include/clang/Analysis/Analyses/UninitializedValues.h

[PATCH] D79895: Add a new warning to warn when passing uninitialized variables as const reference parameters to a function

2020-06-02 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision. hans added a comment. Very nice! I only have minor comments. Also I'm curious to see what this will find in Chromium. I guess we'll find out :-) Comment at: clang/include/clang/Analysis/Analyses/UninitializedValues.h:118 + + virtual void

[PATCH] D79895: Add a new warning to warn when passing uninitialized variables as const reference parameters to a function

2020-05-26 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu added a comment. @rsmith Are you okay with this patch? CHANGES SINCE LAST ACTION https://reviews.llvm.org/D79895/new/ https://reviews.llvm.org/D79895 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[PATCH] D79895: Add a new warning to warn when passing uninitialized variables as const reference parameters to a function

2020-05-21 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu updated this revision to Diff 265605. zequanwu marked 2 inline comments as done. zequanwu added a comment. rename parameter `uses` to `um` CHANGES SINCE LAST ACTION https://reviews.llvm.org/D79895/new/ https://reviews.llvm.org/D79895 Files:

[PATCH] D79895: Add a new warning to warn when passing uninitialized variables as const reference parameters to a function

2020-05-21 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu added inline comments. Comment at: clang/lib/Sema/AnalysisBasedWarnings.cpp:1590-1600 +// flush all const reference uses diags +for (const auto : constRefUses) { + const VarDecl *vd = P.first; + const MappedType = P.second; + + UsesVec *vec =

[PATCH] D79895: Add a new warning to warn when passing uninitialized variables as const reference parameters to a function

2020-05-21 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks accepted this revision. aeubanks added a comment. This revision is now accepted and ready to land. One last nit, otherwise lgtm. But I'm not super familiar with this area, it'd be good to get another review from somebody more familiar. Comment at:

[PATCH] D79895: Add a new warning to warn when passing uninitialized variables as const reference parameters to a function

2020-05-19 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu marked an inline comment as done. zequanwu added a comment. In D79895#2042992 , @xbolva00 wrote: > Can you provide some compile time data with warning enabled/disabled? I compiled the test case with warning enabled and disabled. Since it is

[PATCH] D79895: Add a new warning to warn when passing uninitialized variables as const reference parameters to a function

2020-05-19 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu updated this revision to Diff 264976. zequanwu marked 3 inline comments as done. zequanwu added a comment. Fix typo. Diagnose self-init warning if the self-init variable is used as const reference later. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D79895/new/

[PATCH] D79895: Add a new warning to warn when passing uninitialized variables as const reference parameters to a function

2020-05-19 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu marked an inline comment as done. zequanwu added inline comments. Comment at: clang/lib/Sema/AnalysisBasedWarnings.cpp:1518 UsesMap uses; + UsesMap constRefUses; rsmith wrote: > zequanwu wrote: > > rnk wrote: > > > If possible, it would be nice to

[PATCH] D79895: Add a new warning to warn when passing uninitialized variables as const reference parameters to a function

2020-05-18 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment. Can you provide some compile time data with warning enabled/disabled? CHANGES SINCE LAST ACTION https://reviews.llvm.org/D79895/new/ https://reviews.llvm.org/D79895 ___ cfe-commits mailing list

[PATCH] D79895: Add a new warning to warn when passing uninitialized variables as const reference parameters to a function

2020-05-18 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments. Comment at: clang/lib/Sema/AnalysisBasedWarnings.cpp:1518 UsesMap uses; + UsesMap constRefUses; zequanwu wrote: > rnk wrote: > > If possible, it would be nice to avoid having a second map. > I use second map to let the new

[PATCH] D79895: Add a new warning to warn when passing uninitialized variables as const reference parameters to a function

2020-05-18 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu added inline comments. Comment at: clang/lib/Sema/AnalysisBasedWarnings.cpp:1518 UsesMap uses; + UsesMap constRefUses; rnk wrote: > If possible, it would be nice to avoid having a second map. I use second map to let the new warning be orthogonal

[PATCH] D79895: Add a new warning to warn when passing uninitialized variables as const reference parameters to a function

2020-05-18 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments. Comment at: clang/lib/Sema/AnalysisBasedWarnings.cpp:1518 UsesMap uses; + UsesMap constRefUses; If possible, it would be nice to avoid having a second map. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D79895/new/

[PATCH] D79895: Add a new warning to warn when passing uninitialized variables as const reference parameters to a function

2020-05-18 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added inline comments. Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:2110 +def warn_uninit_const_reference : Warning< + "variable %0 is uninitialized when passes as a const reference parameter " + "here">, InGroup, DefaultIgnore;

[PATCH] D79895: Add a new warning to warn when passing uninitialized variables as const reference parameters to a function

2020-05-15 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu updated this revision to Diff 264300. zequanwu added a comment. Since the new warning is controlled by `-Wuninitialized`, I disabled it in existing test case and added a separate test case for `-Wuninitialized-const-reference`. CHANGES SINCE LAST ACTION