brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.1 KiB · 224ad21 Raw
49 lines · plain
1.. title:: clang-tidy - misc-use-internal-linkage2 3misc-use-internal-linkage4=========================5 6Detects variables and functions that can be marked as static or moved into7an anonymous namespace to enforce internal linkage.8 9Static functions and variables are scoped to a single file. Marking functions10and variables as static helps to better remove dead code. In addition, it gives11the compiler more information and allows for more aggressive optimizations.12 13Example:14 15.. code-block:: c++16 17  int v1; // can be marked as static18 19  void fn1() {} // can be marked as static20 21  namespace {22    // already in anonymous namespace23    int v2;24    void fn2();25  }26  // already declared as extern27  extern int v2;28 29  void fn3(); // without function body in all declaration, maybe external linkage30  void fn3();31 32  // export declarations33  export void fn4() {}34  export namespace t { void fn5() {} }35  export int v2;36 37Options38-------39 40.. option:: FixMode41 42  Selects what kind of a fix the check should provide. The default is `UseStatic`.43 44  - `None`45    Don't fix automatically.46 47  - `UseStatic`48    Add ``static`` for internal linkage variable and function.49