Page MenuHomePhabricator

[clang-tidy] Add clang tidy check I.2 to cppcoreguidelines
Needs ReviewPublic

Authored by vingeldal on Thu, Nov 14, 11:32 AM.



Cpp Core Guideline I.2, a.k.a "Avoid non-const global variables"
For detailed documentation, see:

Event Timeline

vingeldal created this revision.Thu, Nov 14, 11:32 AM
Herald added a project: Restricted Project. · View Herald TranscriptThu, Nov 14, 11:32 AM
JonasToth added inline comments.Thu, Nov 14, 5:11 PM

This matcher already exists either as global matcher or in some other check. please refactor it out.


const fixing is a complicated issue. I would rather not do this now, as there is currently a patch in flight that does the general case.
If you really want it, there is a util for that in clang-tidy/util/ that is able to do some const-fixing.


Please describe the check with one sentence and sync that with the check documentation.


Please adjust the documentation here as well :)


Please add test-cases for pointers and references of builtins (int and the like) and classes/structs/enums/unions, function pointers and member function/data pointers.
We need to consider template variables as well (i think a c++14 feature).

I am not sure about the consteval support in clang for c++20, but for each feature from a newer standard its better to have a additional test-file that will use this standard.

Hi vingeldal,

thanks for you contribution and welcome to LLVM :)
If you have any questions or the like, feel free to ask!

Best Regards, Jonas