[PATCH] D114317: [clang-tidy][WIP] Do not run perfect alias checks

Carlos Galvez via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 16 07:59:11 PST 2021


carlosgalvezp added inline comments.


================
Comment at: clang-tools-extra/clang-tidy/ClangTidyModule.h:25-26
 
+#define CLANG_TIDY_REGISTER_CHECK(Factory, CheckType, CheckName)               \
+  Factory.registerCheck<CheckType>(CheckName, #CheckType)
+
----------------
aaron.ballman wrote:
> I'm not 100% sold that this macro carries its weight. I almost think the registration code is easier to read without it, but not enough to suggest a change yet. Curious if others have feelings here.
I'm not loving it either, to be honest, but I couldn't think of anything better that wouldn't cause developer friction. I've looked into RTTI (banned in LLVM) and hand-made LLVM RRTI, which I think would be quite a burden for check developers since they'd need to add a new enum to the list, implement a getClass() method, etc (IIUC).

Previous attempts as this problem created a different register function like:

```
Factory.registerCheck("foo-check", misc::PrimaryCheck, "misc-check")
```

Which I don't like much because the developer needs to spend time digging through the code and docs to see what is the name of the check it's aliasing, which is error-prone and can easily get out of sync in the future. 

With this macro, all of this is automated and always in sync. But again, if someone has some cleverer magic that would work here I'd love to bring it in :) 

Since replacing existing lines with the macro is a pretty big change, I'll wait until I get OK from reviewers to avoid spending time if in the end we go for another solution.


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

https://reviews.llvm.org/D114317



More information about the cfe-commits mailing list