brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.1 KiB · 3f6cee9 Raw
58 lines · plain
1.. title:: clang-tidy - bugprone-reserved-identifier2 3bugprone-reserved-identifier4============================5 6`cert-dcl37-c` and `cert-dcl51-cpp` redirect here as an alias for this check.7 8Checks for usages of identifiers reserved for use by the implementation.9 10The C and C++ standards both reserve the following names for such use:11 12- identifiers that begin with an underscore followed by an uppercase letter;13- identifiers in the global namespace that begin with an underscore.14 15The C standard additionally reserves names beginning with a double underscore,16while the C++ standard strengthens this to reserve names with a double17underscore occurring anywhere.18 19Violating the naming rules above results in undefined behavior.20 21.. code-block:: c++22 23  namespace NS {24    void __f(); // name is not allowed in user code25    using _Int = int; // same with this26    #define cool__macro // also this27  }28  int _g(); // disallowed in global namespace only29 30The check can also be inverted, i.e. it can be configured to flag any31identifier that is *not* a reserved identifier. This mode is for use by e.g.32standard library implementors, to ensure they don't infringe on the user33namespace.34 35This check does not (yet) check for other reserved names, e.g. macro names36identical to language keywords, and names specifically reserved by language37standards, e.g. C++ 'zombie names' and C future library directions.38 39This check corresponds to CERT C Coding Standard rule `DCL37-C. Do not declare40or define a reserved identifier41<https://wiki.sei.cmu.edu/confluence/display/c/DCL37-C.+Do+not+declare+or+define+a+reserved+identifier>`_42as well as its C++ counterpart, `DCL51-CPP. Do not declare or define a reserved43identifier44<https://wiki.sei.cmu.edu/confluence/display/cplusplus/DCL51-CPP.+Do+not+declare+or+define+a+reserved+identifier>`_.45 46Options47-------48 49.. option:: Invert50 51   If `true`, inverts the check, i.e. flags names that are not reserved.52   Default is `false`.53 54.. option:: AllowedIdentifiers55 56   Semicolon-separated list of regular expressions that the check ignores. Default is an57   empty list.58