[PATCH] D145581: [clang-tidy] In C++17, callee is guaranteed to be sequenced before arguments.

Piotr Zegar via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 8 08:21:26 PST 2023


PiotrZSL added inline comments.


================
Comment at: clang-tools-extra/test/clang-tidy/checkers/bugprone/use-after-move.cpp:1296
 
+// In a function call, the expression that determines the callee is sequenced
+// before the arguments.
----------------
This entire file tests only C++17 and later, when std::move is C++11 feature.
Add separate test file for C++11 (or even better split this one between C++11 and C++17)

Scenario to test in C++11, should warn ?
```
a->foo(std::move(a));
```


================
Comment at: clang-tools-extra/test/clang-tidy/checkers/bugprone/use-after-move.cpp:1304
+  std::unique_ptr<A> a;
+  a->foo(std::move(a));
+}
----------------
What about scenario like this:

```
b.foo(a->saveBIntoAAndReturnBool(std::move(b)));
```

Is first "b" still guaranteed to be alive after std::move ?


================
Comment at: clang-tools-extra/test/clang-tidy/checkers/bugprone/use-after-move.cpp:1305
+  a->foo(std::move(a));
+}
+} // namespace CalleeSequencedBeforeArguments
----------------
I didn't found any test for correct warning in this case:

```
std::unique_ptr<A> getArg(std::unique_ptr<A>);
getArg(std::move(a))->foo(std::move(a));
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145581



More information about the cfe-commits mailing list