[PATCH] D58818: [clang-tidy] added cppcoreguidelines-use-raii-locks check
Jonas Toth via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Mar 3 11:19:21 PST 2019
JonasToth added inline comments.
================
Comment at: test/clang-tidy/cppcoreguidelines-use-raii-locks.cpp:90
+ for (auto i = 0; i < 3; i++) {
+ m.lock();
+ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use RAII
----------------
lewmpk wrote:
> JonasToth wrote:
> > I got another one that I think defeats the analysis:
> >
> > ```
> > while (true)
> > {
> >
> > my_label:
> > m.lock();
> >
> > if (some_condition)
> > goto my_label;
> >
> > m.unlock();
> > }
> > ```
> > Usage of `goto` can interfer and make the situation more complicated. I am not asking you to implement that correctly (not sure if even possible with pure clang-tidy) but I think a pathological example should be documented for the user.
> why would this defeat the analysis?
Because `goto` allows you to reorder you code-locations, so the ordering of what comes before what is not so ez.
Repository:
rCTE Clang Tools Extra
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D58818/new/
https://reviews.llvm.org/D58818
More information about the cfe-commits
mailing list