[PATCH] D112646: [clang-tidy] Add `readability-container-contains` check

Adrian Vogelsgesang via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 26 09:25:55 PST 2021


avogelsgesang added inline comments.


================
Comment at: clang-tools-extra/test/clang-tidy/checkers/readability-container-contains.cpp:189
+    // NO-WARNING.
+    // CHECK-FIXES: if (MyMap.count(0))
+    return nullptr;
----------------
whisperity wrote:
> If a fix is not generated, why is this line here?
I added this test expectation to make sure that the line is kept unchanged. 

I followed https://clang.llvm.org/extra/clang-tidy/Contributing.html#testing-checks:

> In particular, CHECK-FIXES: can be used to check that code was not modified by fix-its, by checking that it is present unchanged in the fixed code.

Based on this, I thought it is best practice to also check that places which I expect to stay unmodified are actually left unmodified. But I am not sure what the expectations in the clang-tidy code base are and whether those "the code stays unmodified" checks are actually encouraged or discouraged.
So just say the word and I am happy to remove this test expectation...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112646



More information about the cfe-commits mailing list