1 .. title:: clang-tidy - bugprone-reserved-identifier
3 bugprone-reserved-identifier
4 ============================
6 `cert-dcl37-c` and `cert-dcl51-cpp` redirect here as an alias for this check.
8 Checks for usages of identifiers reserved for use by the implementation.
10 The C and C++ standards both reserve the following names for such use:
12 - identifiers that begin with an underscore followed by an uppercase letter;
13 - identifiers in the global namespace that begin with an underscore.
15 The C standard additionally reserves names beginning with a double underscore,
16 while the C++ standard strengthens this to reserve names with a double
17 underscore occurring anywhere.
19 Violating the naming rules above results in undefined behavior.
24 void __f(); // name is not allowed in user code
25 using _Int = int; // same with this
26 #define cool__macro // also this
28 int _g(); // disallowed in global namespace only
30 The check can also be inverted, i.e. it can be configured to flag any
31 identifier that is _not_ a reserved identifier. This mode is for use by e.g.
32 standard library implementors, to ensure they don't infringe on the user
35 This check does not (yet) check for other reserved names, e.g. macro names
36 identical to language keywords, and names specifically reserved by language
37 standards, e.g. C++ 'zombie names' and C future library directions.
39 This check corresponds to CERT C Coding Standard rule `DCL37-C. Do not declare
40 or define a reserved identifier
41 <https://wiki.sei.cmu.edu/confluence/display/c/DCL37-C.+Do+not+declare+or+define+a+reserved+identifier>`_
42 as well as its C++ counterpart, `DCL51-CPP. Do not declare or define a reserved
44 <https://wiki.sei.cmu.edu/confluence/display/cplusplus/DCL51-CPP.+Do+not+declare+or+define+a+reserved+identifier>`_.
51 If `true`, inverts the check, i.e. flags names that are not reserved.
54 .. option:: AllowedIdentifiers
56 Semicolon-separated list of regular expressions that the check ignores. Default is an