Extend the check to detect patterns like 'ptr.get() == nullptr'
It detects == and != when any argument is a ptr.get() and the other is a
nullptr.
Only supports standard smart pointer types std::unique_ptr and std::shared_ptr.
Does not support the case 'ptr.get() == other.get()' yet.
Details
- Reviewers
djasper klimek-test
Diff Detail
Event Timeline
clang-tidy/misc/RedundantSmartptrGet.cpp | ||
---|---|---|
60 | There might be a missing test here (s/shard/shared/) |
clang-tidy/misc/RedundantSmartptrGet.cpp | ||
---|---|---|
60 | Trying again to see whether the mail gets through... |
clang-tidy/misc/RedundantSmartptrGet.cpp | ||
---|---|---|
60 | And trying again... |
clang-tidy/misc/RedundantSmartptrGet.cpp | ||
---|---|---|
60 | Yet another try... |
clang-tidy/misc/RedundantSmartptrGet.cpp | ||
---|---|---|
60 | And again... |
clang-tidy/misc/RedundantSmartptrGet.cpp | ||
---|---|---|
60 | And finally... |
Ok, very sorry for having hijacked this thread... It should all work now, and I'll let you be... :)
Fixed the typo on shared_ptr and added a shared_ptr to the test.
Fixed the -fix.cpp test to actually check the output.
FileCheck can match the CHECK: lines with themselves if you don't remove them from the input.
Move the checking logic into shell scripts.
The test will now have one only RUN: line calling the appropriate script.
Two minor comments, otherwise looks good!
clang-tidy/misc/RedundantSmartptrGet.cpp | ||
---|---|---|
81 | Always add a line break after the "if (...)" in LLVM style. | |
test/clang-tidy/check_clang_tidy_fix.sh | ||
4 | I think with this we can get rid of the unit tests entirely. (I will prepare a follow up patch). Nice! | |
test/clang-tidy/check_clang_tidy_output.sh | ||
12 | Also set --disable_checks=''. And same in the other wrapper script. (I think we might also want to change how those flags behave, but until then, this is the right thing to do..) |
test/clang-tidy/check_clang_tidy_output.sh | ||
---|---|---|
12 | -disable-checks that is.. |
Another couple of notes, otherwise looks good!
test/clang-tidy/check_clang_tidy_output.sh | ||
---|---|---|
11 | Why not use static compilation database instead of generating compile_commands.json? clang-tidy -checks=${CHECK_TO_RUN} ${INPUT_FILE} -- -std=c++11 | FileCheck ${INPUT_FILE} | |
13 | This being on a line of its own without indentation looks confusing. Could you put the whole pipeline on a single line or use indentation here (and put the pipe on the next line)? clang-tidy ... \ | FileCheck ... |
Thanks! Another couple of comments, though.
test/clang-tidy/check_clang_tidy_fix.sh | ||
---|---|---|
9 | I'd leave the grep as it was in the test, so that it filters out RUN: lines as well, and it only filters out comments: grep -Ev "// *[A-Z-]+:" ... We'll have some checks for comments, so filtering out special comments can be important there. | |
test/clang-tidy/check_clang_tidy_output.sh | ||
8 | nit: I'd format this still a bit differently (where's my sh-format? ;), four spaces on the continuation line, and each pipe component from a new line with 2 spaces indentation: clang-tidy --checks=${CHECK_TO_RUN} --disable-checks="" ${INPUT_FILE} \ -- --std=c++11 \ | FileCheck ${INPUT_FILE} |
There might be a missing test here (s/shard/shared/)