brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.5 KiB · 7455a2e Raw
60 lines · plain
1.. title:: clang-tidy - bugprone-suspicious-missing-comma2 3bugprone-suspicious-missing-comma4=================================5 6String literals placed side-by-side are concatenated at translation phase 67(after the preprocessor). This feature is used to represent long string8literal on multiple lines.9 10For instance, the following declarations are equivalent:11 12.. code-block:: c++13 14  const char* A[] = "This is a test";15  const char* B[] = "This" " is a "    "test";16 17A common mistake done by programmers is to forget a comma between two string18literals in an array initializer list.19 20.. code-block:: c++21 22  const char* Test[] = {23    "line 1",24    "line 2"     // Missing comma!25    "line 3",26    "line 4",27    "line 5"28  };29 30The array contains the string "line 2line3" at offset 1 (i.e. Test[1]). Clang31won't generate warnings at compile time.32 33This check may warn incorrectly on cases like:34 35.. code-block:: c++36 37  const char* SupportedFormat[] = {38    "Error %s",39    "Code " PRIu64,   // May warn here.40    "Warning %s",41  };42 43Options44-------45 46.. option::  SizeThreshold47 48   An unsigned integer specifying the minimum size of a string literal to be49   considered by the check. Default is ``5U``.50 51.. option::  RatioThreshold52 53   A string specifying the maximum threshold ratio [0, 1.0] of suspicious string54   literals to be considered. Default is ``".2"``.55 56.. option::  MaxConcatenatedTokens57 58   An unsigned integer specifying the maximum number of concatenated tokens.59   Default is ``5U``.60