Made a small fix to readability-delete-null-pointer check such that it includes class members.
Details
Details
- Reviewers
aaron.ballman alexfh JDevlieghere malcolm.parsons - Commits
- rG6ff978fd54f0: [clang-tidy] Fix for bug 31838: readability-delete-null-pointer does not work…
rCTE294912: [clang-tidy] Fix for bug 31838: readability-delete-null-pointer does not work…
rL294912: [clang-tidy] Fix for bug 31838: readability-delete-null-pointer does not work…
Diff Detail
Diff Detail
- Repository
- rL LLVM
Event Timeline
clang-tidy/readability/DeleteNullPointerCheck.cpp | ||
---|---|---|
46 ↗ | (On Diff #87688) | nit: Will has(anyOf(DeleteExpr, DeleteMemberExpr)) work? |
test/clang-tidy/readability-delete-null-pointer.cpp | ||
69 ↗ | (On Diff #87688) | nit: I'd put this line closer to the line with the warning (or right before it), e.g. // CHECK-MESSAGES: :[[@LINE+1]]:... if (mp) delete mp; |
71 ↗ | (On Diff #87688) | This doesn't check that the if is deleted. It will pass if the check doesn't do any replacements. One way to properly check this is to add a unique comment after the if and match it with an anchor to the start of line: if (mp) // should be deleted 1 delete mp; // CHECK-FIXES: {{^ }}// should be deleted 1 // CHECK-FIXES-NEXT: delete mp; or alternatively: // next line should be deleted if (mp) delete mp; // CHECK-FIXES: // next line should be deleted // CHECK-FIXES-NEXT: {{^ }}delete mp; |
clang-tidy/readability/DeleteNullPointerCheck.cpp | ||
---|---|---|
46 ↗ | (On Diff #87688) | I could swear that I had tried that. It seems like the obvious way to do it. It worked, though. |
test/clang-tidy/readability-delete-null-pointer.cpp | ||
---|---|---|
67 ↗ | (On Diff #87829) | This should match the comment to verify the if is deleted. |
Comment Actions
Added comment in CHECK-FIX to ensure the line we are referring to is uniquely identified.