Replace x.reset(y.release()); with x = std::move(y);
If y is rvalue, replace with x = y; instead
Details
- Reviewers
alexfh
Diff Detail
Event Timeline
Thank you for the check!
Looks generally fine, but needs some polishing to match LLVM style.
clang-tidy/misc/UniqueptrResetRelease.cpp | ||
---|---|---|
14 | Please remove commented lines. | |
39 | You're already using ast_matchers, so you can avoid it here. | |
40 | Please use CamelCase for local variables. | |
55 | In LLVM style single-statement if/for/... bodies don't need braces (and should not be on the same line with the if/for/...). | |
68 | Clang warnings don't start with a capital letter. We try to move to this style in clang-tidy as well. | |
68 | Maybe "prefer ptr1 = std::move(ptr2); ..."? It would be more wordy, but also clearer, I think. | |
74 | LLVM style: one space before comments, please. | |
clang-tidy/misc/UniqueptrResetRelease.h | ||
28 | Unfortunately, delegated constructors are not implemented in some of the compilers supported by Clang (VS2012). You need to manually delegate the constructor. | |
29 | Here and below: in LLVM style names of local variables and function parameters should start with a capital letter. | |
test/clang-tidy/uniqueptr-reset-release.cpp | ||
4 | check_clang_tidy.sh calls FileCheck with -implicit-check-not='warning:|error:', so this is superfluous. | |
35 | You can omit the " [misc-uniqueptr-reset-release]" part in all the messages except for the first one. It will make the test slightly more readable. |
I don't have commit rights, I didn't submit that many patches so far :)
Please commit.
Committed as r223460 with a few minor changes:
Renamed the test file to be closer to the check name, re-formatted the test to LLVM style and made the CHECK-MESSAGES lines shorter.
test/clang-tidy/uniqueptr-reset-release.cpp | ||
---|---|---|
37 | The message for this case shouldn't mention std::move. Can you fix this? |
Unfortunately, delegated constructors are not implemented in some of the compilers supported by Clang (VS2012). You need to manually delegate the constructor.