diff --git a/cxx-sensors/src/main/resources/clangtidy.xml b/cxx-sensors/src/main/resources/clangtidy.xml index 5e416ee6ed..73f33f19db 100644 --- a/cxx-sensors/src/main/resources/clangtidy.xml +++ b/cxx-sensors/src/main/resources/clangtidy.xml @@ -3,7 +3,7 @@ C and C++ rules from * https://clang.llvm.org/extra/clang-tidy/checks/list.html * https://clang-analyzer.llvm.org/available_checks.html - * last update: llvmorg-15-init-2831-geb3e09c9bf1d (git describe) + * last update: llvmorg-16-init-15404-g61be26154924 (git describe) --> @@ -72,7 +72,7 @@ int result = absl::ToUnixSeconds(t) + x; // Suggestion - Addition in the absl::Time domain int result = absl::ToUnixSeconds(t + absl::Seconds(x));

References

-

clang.llvm.org

]]> +

clang.llvm.org

]]> INFO CODE_SMELL @@ -105,7 +105,7 @@ if (x < absl::ToInt64Microseconds(d)) ... // Suggested - Compare in the absl::Duration domain instead if (absl::Microseconds(x) < d) ...

References

-

clang.llvm.org

]]> +

clang.llvm.org

]]> INFO CODE_SMELL @@ -136,7 +136,7 @@ double x = static_cast<double>(absl::ToInt64Seconds(d)); double x = absl::ToDoubleSeconds(d);

Note: In the second example, the suggested fix could yield a different result, as the conversion to integer could truncate. In practice, this is very rare, and you should use absl::Trunc to perform this operation explicitly instead.

References

-

clang.llvm.org

]]> +

clang.llvm.org

]]> INFO CODE_SMELL @@ -165,7 +165,7 @@ double dsec2 = absl::ToDoubleSeconds(d); // GOOD: No truncation. assert(dsec1 == 3.5 && dsec2 == 3.5);

This check looks for uses of absl::Duration division that is done in a floating-point context, and recommends the use of a function that returns a floating-point value.

References

-

clang.llvm.org

]]> +

clang.llvm.org

]]> INFO CODE_SMELL @@ -194,7 +194,7 @@ absl::Duration d = absl::Seconds(static_cast<double>(10)); // Suggested - Remove the explicit cast absl::Duration d = absl::Seconds(10);

References

-

clang.llvm.org

]]> +

clang.llvm.org

]]> INFO CODE_SMELL @@ -231,7 +231,7 @@ absl::Duration d = absl::Hours(0); // Suggested = Use absl::ZeroDuration instead absl::Duration d = absl::ZeroDuration();

References

-

clang.llvm.org

]]> +

clang.llvm.org

]]> INFO CODE_SMELL @@ -262,7 +262,7 @@ double result = absl::ToDoubleSeconds(d1) - absl::ToDoubleSeconds(d2); double result = absl::ToDoubleSeconds(d1 - d2);

Note: As with other clang-tidy checks, it is possible that multiple fixes may overlap (as in the case of nested expressions), so not all occurrences can be transformed in one run. In particular, this may occur for nested subtraction expressions. Running clang-tidy multiple times will find and fix these overlaps.

References

-

clang.llvm.org

]]> +

clang.llvm.org

]]> INFO CODE_SMELL @@ -311,7 +311,7 @@ absl::Duration d2 = absl::Seconds(absl::ToInt64Seconds(d1) * 2); absl::Duration d2 = d1 * 2;

Note: Converting to an integer and back to an absl::Duration might be a truncating operation if the value is not aligned to the scale of conversion. In the rare case where this is the intended result, callers should use absl::Trunc to truncate explicitly.

References

-

clang.llvm.org

]]> +

clang.llvm.org

]]> INFO CODE_SMELL @@ -351,7 +351,7 @@ for (auto piece : absl::StrSplit(str, absl::MaxSplits("B", 1))) { // overload of absl::StrSplit() to be used. for (auto piece : absl::StrSplit(str, absl::MaxSplits('B', 1))) {

References

-

clang.llvm.org

]]> +

clang.llvm.org

]]> INFO CODE_SMELL @@ -360,7 +360,9 @@ for (auto piece : absl::StrSplit(str, absl::MaxSplits('B', 1))) { abseil-no-internal-dependencies abseil-no-internal-dependencies - subl.. title:: clang-tidy - abseil-no-internal-dependencies

+ +

clang-tidy - abseil-no-internal-dependencies

+

abseil-no-internal-dependencies

Warns if code using Abseil depends on internal details. If something is in a namespace that includes the word "internal", code is not allowed to depend upon it because it's an implementation detail. They cannot friend it, include it, you mention it or refer to it in any way. Doing so violates Abseil's compatibility guidelines and may result in breakage. See https://abseil.io/about/compatibility for more information.

The following cases will result in warnings:

@@ -373,7 +375,7 @@ class foo { absl::memory_internal::MakeUniqueResult(); // warning triggered on this line

References

-

clang.llvm.org

]]> +

clang.llvm.org

]]>
INFO CODE_SMELL @@ -394,7 +396,7 @@ absl::memory_internal::MakeUniqueResult();

will be prompted with a warning.

See the full Abseil compatibility guidelines for more information.

References

-

clang.llvm.org

]]> +

clang.llvm.org

]]> INFO CODE_SMELL @@ -422,7 +424,7 @@ absl::StrAppend(&s, absl::StrCat("E", "F", "G" absl::StrAppend(&s, "E", "F", "G"); //after

References

-

clang.llvm.org

]]> +

clang.llvm.org

]]> MINOR CODE_SMELL @@ -442,7 +444,7 @@ absl::StrAppend(&s, "E", "F", "G");
a = absl::StrCat(a, b); // Use absl::StrAppend(&a, b) instead.

Does not diagnose cases where absl::StrCat() is used as a template argument for a functor.

References

-

clang.llvm.org

]]> +

clang.llvm.org

]]> MINOR CODE_SMELL @@ -479,7 +481,7 @@ if (absl::StartsWith(s, "Hello World")) { /* do something */ }<

The location of Abseil's strings/match.h. Defaults to absl/strings/match.h.

References

-

clang.llvm.org

]]> +

clang.llvm.org

]]> MINOR CODE_SMELL @@ -522,7 +524,7 @@ if (absl::StrContains(a, "Hello World")) { /* do something */ }

The location of Abseil's strings/match.h. Defaults to absl/strings/match.h.

References

-

clang.llvm.org

]]> +

clang.llvm.org

]]> INFO CODE_SMELL @@ -546,7 +548,7 @@ if (x < absl::ToUnixSeconds(t)) ... // Suggested - Compare in the absl::Time domain instead if (absl::FromUnixSeconds(x) < t) ...

References

-

clang.llvm.org

]]> +

clang.llvm.org

]]> INFO CODE_SMELL @@ -583,7 +585,7 @@ int i = x - absl::ToUnixSeconds(t); // Suggestion - Perform subtraction in the Time domain instead. int i = absl::ToInt64Seconds(absl::FromUnixSeconds(x) - t);

References

-

clang.llvm.org

]]> +

clang.llvm.org

]]> INFO CODE_SMELL @@ -610,7 +612,7 @@ absl::Duration d = absl::Milliseconds(static_cast<int64_t>(a)); d *= static_cast<int64_t>(a);

Note that this check always adds a cast to int64_t in order to preserve the current behavior of user code. It is possible that this uncovers unintended behavior due to types implicitly convertible to a floating-point type.

References

-

clang.llvm.org

]]> +

clang.llvm.org

]]> INFO CODE_SMELL @@ -639,7 +641,7 @@ for (int i = 0; i < 100; ++i) { }

Based on the Altera SDK for OpenCL: Best Practices Guide.

References

-

clang.llvm.org

]]> +

clang.llvm.org

]]> INFO CODE_SMELL @@ -656,7 +658,7 @@ for (int i = 0; i < 100; ++i) {

Such kernel file names cause the offline compiler to generate intermediate design files that have the same names as certain internal files, which leads to a compilation error.

Based on the Guidelines for Naming the Kernel section in the Intel FPGA SDK for OpenCL Pro Edition: Programming Guide.

References

-

clang.llvm.org

]]> +

clang.llvm.org

]]> INFO CODE_SMELL @@ -706,7 +708,7 @@ void __kernel barrier_with_id(__global int * foo, int size) {

Defines the version of the Altera Offline Compiler. Defaults to 1600 (corresponding to version 16.00).

References

-

clang.llvm.org

]]> +

clang.llvm.org

]]> INFO CODE_SMELL @@ -759,7 +761,7 @@ struct badly_aligned_example { char c; // 1 byte } __attribute__((packed)) __attribute__((aligned(32)));

References

-

clang.llvm.org

]]> +

clang.llvm.org

]]> INFO CODE_SMELL @@ -851,7 +853,7 @@ while (i < someVector.size()) {

In practice, this refers to the integer value of the upper bound within the loop statement's condition expression.

References

-

clang.llvm.org

]]> +

clang.llvm.org

]]> INFO CODE_SMELL @@ -872,7 +874,7 @@ while (i < someVector.size()) { accept4(sockfd, addr, addrlen, SOCK_CLOEXEC);

References

-

clang.llvm.org

]]> +

clang.llvm.org

]]> INFO CODE_SMELL @@ -893,7 +895,7 @@ accept4(sockfd, addr, addrlen, SOCK_CLOEXEC); accept4(sockfd, addr, addrlen, SOCK_NONBLOCK | SOCK_CLOEXEC);

References

-

clang.llvm.org

]]> +

clang.llvm.org

]]> MINOR VULNERABILITY @@ -916,7 +918,7 @@ accept4(sockfd, addr, addrlen, SOCK_NONBLOCK | SOCK_CLOEXEC); int fd = open(path, O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, mode);

References

-

clang.llvm.org

]]> +

clang.llvm.org

]]> INFO CODE_SMELL @@ -937,7 +939,7 @@ int fd = open(path, O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, mode);

References

-

clang.llvm.org

]]> +

clang.llvm.org

]]> MINOR VULNERABILITY @@ -960,7 +962,7 @@ int fd = fcntl(oldfd, F_DUPFD_CLOEXEC); epoll_create1(EPOLL_CLOEXEC);

References

-

clang.llvm.org

]]> +

clang.llvm.org

]]> MINOR VULNERABILITY @@ -983,7 +985,7 @@ epoll_create1(EPOLL_CLOEXEC); epoll_create1(EPOLL_CLOEXEC);

References

-

clang.llvm.org

]]> +

clang.llvm.org

]]> MINOR VULNERABILITY @@ -1006,7 +1008,7 @@ epoll_create1(EPOLL_CLOEXEC); fopen("fn", "re");

References

-

clang.llvm.org

]]> +

clang.llvm.org

]]> MINOR VULNERABILITY @@ -1029,7 +1031,7 @@ fopen("fn", "re"); inotify_init1(IN_CLOEXEC);

References

-

clang.llvm.org

]]> +

clang.llvm.org

]]> MINOR VULNERABILITY @@ -1052,7 +1054,7 @@ inotify_init1(IN_CLOEXEC); inotify_init1(IN_NONBLOCK | IN_CLOEXEC);

References

-

clang.llvm.org

]]> +

clang.llvm.org

]]> MINOR VULNERABILITY @@ -1075,7 +1077,7 @@ inotify_init1(IN_NONBLOCK | IN_CLOEXEC); memfd_create(name, MFD_ALLOW_SEALING | MFD_CLOEXEC);

References

-

clang.llvm.org

]]> +

clang.llvm.org

]]> MINOR VULNERABILITY @@ -1102,7 +1104,7 @@ open("filename", O_RDWR | O_CLOEXEC); open64("filename", O_RDWR | O_CLOEXEC); openat(0, "filename", O_RDWR | O_CLOEXEC);

References

-

clang.llvm.org

]]> +

clang.llvm.org

]]> MINOR VULNERABILITY @@ -1123,7 +1125,7 @@ openat(0, "filename", O_RDWR | O_CLOEXEC);

Suggested replacement:

pipe2(pipefd, O_CLOEXEC);

References

-

clang.llvm.org

]]> +

clang.llvm.org

]]> INFO CODE_SMELL @@ -1142,7 +1144,7 @@ openat(0, "filename", O_RDWR | O_CLOEXEC);

Suggested replacement:

pipe2(pipefd, O_NONBLOCK | O_CLOEXEC);

References

-

clang.llvm.org

]]> +

clang.llvm.org

]]> INFO CODE_SMELL @@ -1163,7 +1165,7 @@ openat(0, "filename", O_RDWR | O_CLOEXEC); socket(domain, type, SOCK_STREAM | SOCK_CLOEXEC);

References

-

clang.llvm.org

]]> +

clang.llvm.org

]]> MINOR VULNERABILITY @@ -1197,7 +1199,7 @@ while (TEMP_FAILURE_RETRY(read(STDIN_FILENO, cs, sizeof(cs))) != 0) {

A comma-separated list of the names of retry macros to be checked.

References

-

clang.llvm.org

]]> +

clang.llvm.org

]]> INFO CODE_SMELL @@ -1219,7 +1221,7 @@ auto wstr = boost::lexical_cast<std::wstring>(2137LL); auto str = std::to_string(42); auto wstr = std::to_wstring(2137LL);

References

-

clang.llvm.org

]]> +

clang.llvm.org

]]> INFO CODE_SMELL @@ -1343,7 +1345,7 @@ foo(nullptr); foo(/*Value=*/nullptr);

References

-

clang.llvm.org

]]> +

clang.llvm.org

]]> MINOR BUG @@ -1374,7 +1376,7 @@ foo(/*Value=*/nullptr);

A semicolon-separated list of the names of functions or methods to be considered as not having side-effects. Regular expressions are accepted, e.g. [Rr]ef(erence)?$ matches every type with suffix Ref, ref, Reference and reference. The default is empty. If a name in the list contains the sequence :: it is matched against the qualified typename (i.e. namespace::Type, otherwise it is matched against only the type name (i.e. Type).

References

-

clang.llvm.org

]]> +

clang.llvm.org

]]> MINOR BUG @@ -1395,7 +1397,7 @@ foo(/*Value=*/nullptr);

This check corresponds to the CERT C Coding Standard rule POS44-C. Do not use signals to terminate threads.

References

-

clang.llvm.org

]]> +

clang.llvm.org

]]> MINOR BUG @@ -1417,7 +1419,7 @@ if (p) { // Never used in a pointer-specific way. }

References

-

clang.llvm.org

]]> +

clang.llvm.org

]]> MINOR BUG @@ -1476,7 +1478,7 @@ default:

Unlike if statements, the check does not detect chains of conditional operators.

Note: This check also reports situations where branches become identical only after preprocessing.

References

-

clang.llvm.org

]]> +

clang.llvm.org

]]> INFO CODE_SMELL @@ -1504,7 +1506,7 @@ class X2 : public Copyable { };

The check also suggests a fix-its in some cases.

References

-

clang.llvm.org

]]> +

clang.llvm.org

]]> MINOR BUG @@ -1543,7 +1545,7 @@ string_view f() {

A semicolon-separated list of class names that should be treated as handles. By default only std::basic_string_view and std::experimental::basic_string_view are considered.

References

-

clang.llvm.org

]]> +

clang.llvm.org

]]> MINOR BUG @@ -1567,7 +1569,7 @@ string_view f() { }

When synchronization of static initialization is disabled, if two threads both call foo for the first time, there is the possibility that k will be double initialized, creating a race condition.

References

-

clang.llvm.org

]]> +

clang.llvm.org

]]> INFO CODE_SMELL @@ -1697,7 +1699,7 @@ void strs(String Str, StringView SV) { /* ... */ } // Diagnosed: StringView implicitly converts to and from a buffer. void cStr(StringView SV, const char *Buf() { /* ... */ }

References

-

clang.llvm.org

]]> +

clang.llvm.org

]]> INFO CODE_SMELL @@ -1732,7 +1734,7 @@ void cStr(StringView SV, const char *Buf() { /* ... */ }

Comma separated list containing type names which are not counted as thrown exceptions in the check. Default value is an empty string.

References

-

clang.llvm.org

]]> +

clang.llvm.org

]]> MINOR BUG @@ -1759,7 +1761,7 @@ return std::accumulate(std::begin(a), std::end(a), 0);
auto a = {65536LL * 65536 * 65536};
 return std::accumulate(std::begin(a), std::end(a), 0);

References

-

clang.llvm.org

]]> +

clang.llvm.org

]]> MAJOR CODE_SMELL @@ -1783,7 +1785,7 @@ nb::A a; // 'A' found in another namespace 'nb::'

This check can only generate warnings, but it can't suggest a fix at this point.

References

-

clang.llvm.org

]]> +

clang.llvm.org

]]> MINOR BUG @@ -1825,7 +1827,7 @@ public:

Background

For deciding whether a constructor is guarded with enable_if, we consider the types of the constructor parameters, the default values of template type parameters and the types of non-type template parameters with a default literal value. If any part of these types is std::enable_if or std::enable_if_t, we assume the constructor is guarded.

References

-

clang.llvm.org

]]> +

clang.llvm.org

]]> MINOR BUG @@ -1872,7 +1874,7 @@ char ptr_subscript(char *base, int a, int b) { return base[a * b]; // warning: result of multiplication in type 'int' is used as a pointer offset after an implicit widening conversion to type 'ssize_t' }

References

-

clang.llvm.org

]]> +

clang.llvm.org

]]> INFO CODE_SMELL @@ -1896,7 +1898,7 @@ xs.erase(std::remove(xs.begin(), xs.end(), 10)); ... xs.erase(std::remove(xs.begin(), xs.end(), 10), xs.end());

References

-

clang.llvm.org

]]> +

clang.llvm.org

]]> MINOR BUG @@ -1919,7 +1921,7 @@ xs.erase(std::remove(xs.begin(), xs.end(), 10), xs.end());
  • It is incorrect. The number 0.499999975 (smallest representable float number below 0.5) rounds to 1.0. Even worse behavior for negative numbers where both -0.5f and -1.4f both round to 0.0.
  • References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MAJOR BUG @@ -1948,7 +1950,7 @@ while (i < 10) { ++j; }

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR CODE_SMELL @@ -1992,7 +1994,7 @@ d = 1 << (i / 2); d = 9 + intFunc(6 * i / 32); d = (int)(i / 32) - 8;

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR BUG @@ -2020,7 +2022,7 @@ Now called from operator()
    Called from FancyFunction
     Now called from FancyFunction

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR BUG @@ -2040,7 +2042,7 @@ Now called from FancyFunction

    When the replacement list has an expression, it is recommended to surround it with parentheses. This ensures that the macro result is evaluated completely before it is used.

    It is also recommended to surround macro arguments in the replacement list with parentheses. This ensures that the argument value is calculated properly.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR BUG @@ -2057,7 +2059,7 @@ Now called from FancyFunction

    bugprone-macro-repeated-side-effects

    Checks for repeated argument with side effects in macros.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR BUG @@ -2090,7 +2092,7 @@ Now called from FancyFunction char *c = (char*) malloc(strlen((str + 1))); }

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MAJOR BUG @@ -2113,7 +2115,7 @@ Now called from FancyFunction

    The suggested fix is to add the integer expression to the argument of malloc and not to its result. In the example above the fix would be

    char *p = (char*) malloc(n + 10);

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MAJOR BUG @@ -2155,7 +2157,7 @@ Now called from FancyFunction

    If true, enables detection of implicit casts. Default is false.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MAJOR CODE_SMELL @@ -2188,7 +2190,7 @@ foo(s);

    If foo() is called on an lvalue (as in the example above), then T is deduced to be an lvalue reference. In the example, T is deduced to be std::string &. The type of the argument t therefore becomes std::string& &&; by the reference collapsing rules, this collapses to std::string&.

    This means that the foo(s) call passes s as an lvalue reference, and foo() ends up moving s and thereby placing it into an indeterminate state.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR BUG @@ -2209,7 +2211,7 @@ foo(s); if (do_increment) INCREMENT_TWO(a, b); // (b)++ will be executed unconditionally.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR BUG @@ -2234,7 +2236,7 @@ if (do_increment) });

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -2302,7 +2304,7 @@ if (do_increment)

    The value true specifies that the target environment is considered to implement '_s' suffixed memory and string handler functions which are safer than older versions (e.g. 'memcpy_s()'). The default value is true.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR BUG @@ -2332,7 +2334,7 @@ struct C: public B { // warning: qualified name A::foo refers to a member overridden in subclass; did you mean 'B'? [bugprone-parent-virtual-call] };

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MAJOR CODE_SMELL @@ -2353,7 +2355,7 @@ struct C: public B {

    This will never happen as the return value is always non-negative. A simple fix could be:

    if (posix_fadvise(...) > 0) {

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR BUG @@ -2422,7 +2424,7 @@ if (onFire) { } }

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR BUG @@ -2452,7 +2454,7 @@ if (onFire) { #define cool__macro // also this } int _g(); // disallowed in global namespace only -

    The check can also be inverted, i.e. it can be configured to flag any identifier that is not a reserved identifier. This mode is for use by e.g. standard library implementors, to ensure they don't infringe on the user namespace.

    +

    The check can also be inverted, i.e. it can be configured to flag any identifier that is _not a reserved identifier. This mode is for use by e.g. standard library implementors, to ensure they don't infringe on the user namespace.

    This check does not (yet) check for other reserved names, e.g. macro names identical to language keywords, and names specifically reserved by language standards, e.g. C++ 'zombie names' and C future library directions.

    This check corresponds to CERT C Coding Standard rule DCL37-C. Do not declare or define a reserved identifier as well as its C++ counterpart, DCL51-CPP. Do not declare or define a reserved identifier.

    Options

    @@ -2465,7 +2467,7 @@ int _g(); // disallowed in global namespace only

    Semicolon-separated list of names that the check ignores. Default is an empty list.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR CODE_SMELL @@ -2493,8 +2495,9 @@ struct S { std::shared_ptr<Foo> x(new Foo[10]); // no replacement in this case // ^ warning: shared pointer to non-array is initialized with array [bugprone-shared-ptr-array-mismatch] }; +

    This check partially covers the CERT C++ Coding Standard rule MEM51-CPP. Properly deallocate dynamically allocated resources However, only the std::shared_ptr case is detected by this check.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -2507,15 +2510,37 @@ struct S {

    clang-tidy - bugprone-signal-handler

    bugprone-signal-handler

    -

    Finds functions registered as signal handlers that call non asynchronous-safe functions. Any function that cannot be determined to be an asynchronous-safe function call is assumed to be non-asynchronous-safe by the checker, including user functions for which only the declaration is visible. User function calls with visible definition are checked recursively. The check handles only C code. Only the function names are considered and the fact that the function is a system-call, but no other restrictions on the arguments passed to the functions (the signal call is allowed without restrictions).

    -

    This check corresponds to the CERT C Coding Standard rule SIG30-C. Call only asynchronous-safe functions within signal handlers and has an alias name cert-sig30-c.

    +

    Finds specific constructs in signal handler functions that can cause undefined behavior. The rules for what is allowed differ between C++ language versions.

    +

    Checked signal handler rules for C:

    + +

    Checked signal handler rules for up to and including C++14:

    + +

    The check is disabled on C++17 and later.

    +

    Asnychronous-safety is determined by comparing the function's name against a set of known functions. In addition, the function must come from a system header include and in a global namespace. The (possible) arguments passed to the function are not checked. Any function that cannot be determined to be asynchronous-safe is assumed to be non-asynchronous-safe by the check, including user functions for which only the declaration is visible. Calls to user-defined functions with visible definitions are checked recursively.

    +

    This check implements the CERT C Coding Standard rule SIG30-C. Call only asynchronous-safe functions within signal handlers and the rule MSC54-CPP. A signal handler must be a plain old function. It has the alias names cert-sig30-c and cert-msc54-cpp.

    +

    Options

    AsyncSafeFunctionSet

    -

    Selects which set of functions is considered as asynchronous-safe (and therefore allowed in signal handlers). Value minimal selects a minimal set that is defined in the CERT SIG30-C rule and includes functions abort(), _Exit(), quick_exit() and signal(). Value POSIX selects a larger set of functions that is listed in POSIX.1-2017 (see this link for more information). The function quick_exit is not included in the shown list. It is assumable that the reason is that the list was not updated for C11. The checker includes quick_exit in the set of safe functions. Functions registered as exit handlers are not checked.

    -

    Default is POSIX.

    +

    Selects which set of functions is considered as asynchronous-safe (and therefore allowed in signal handlers). It can be set to the following values:

    +
    +
    minimal
    +

    Selects a minimal set that is defined in the CERT SIG30-C rule. and includes functions abort(), _Exit(), quick_exit() and signal().

    +
    +
    POSIX
    +

    Selects a larger set of functions that is listed in POSIX.1-2017 (see this link for more information). The following functions are included: _Exit, _exit, abort, accept, access, aio_error, aio_return, aio_suspend, alarm, bind, cfgetispeed, cfgetospeed, cfsetispeed, cfsetospeed, chdir, chmod, chown, clock_gettime, close, connect, creat, dup, dup2, execl, execle, execv, execve, faccessat, fchdir, fchmod, fchmodat, fchown, fchownat, fcntl, fdatasync, fexecve, ffs, fork, fstat, fstatat, fsync, ftruncate, futimens, getegid, geteuid, getgid, getgroups, getpeername, getpgrp, getpid, getppid, getsockname, getsockopt, getuid, htonl, htons, kill, link, linkat, listen, longjmp, lseek, lstat, memccpy, memchr, memcmp, memcpy, memmove, memset, mkdir, mkdirat, mkfifo, mkfifoat, mknod, mknodat, ntohl, ntohs, open, openat, pause, pipe, poll, posix_trace_event, pselect, pthread_kill, pthread_self, pthread_sigmask, quick_exit, raise, read, readlink, readlinkat, recv, recvfrom, recvmsg, rename, renameat, rmdir, select, sem_post, send, sendmsg, sendto, setgid, setpgid, setsid, setsockopt, setuid, shutdown, sigaction, sigaddset, sigdelset, sigemptyset, sigfillset, sigismember, siglongjmp, signal, sigpause, sigpending, sigprocmask, sigqueue, sigset, sigsuspend, sleep, sockatmark, socket, socketpair, stat, stpcpy, stpncpy, strcat, strchr, strcmp, strcpy, strcspn, strlen, strncat, strncmp, strncpy, strnlen, strpbrk, strrchr, strspn, strstr, strtok_r, symlink, symlinkat, tcdrain, tcflow, tcflush, tcgetattr, tcgetpgrp, tcsendbreak, tcsetattr, tcsetpgrp, time, timer_getoverrun, timer_gettime, timer_settime, times, umask, uname, unlink, unlinkat, utime, utimensat, utimes, wait, waitpid, wcpcpy, wcpncpy, wcscat, wcschr, wcscmp, wcscpy, wcscspn, wcslen, wcsncat, wcsncmp, wcsncpy, wcsnlen, wcspbrk, wcsrchr, wcsspn, wcsstr, wcstok, wmemchr, wmemcmp, wmemcpy, wmemmove, wmemset, write

    +

    The function quick_exit is not included in the POSIX list but it is included here in the set of safe functions.

    +
    +
    +

    The default value is POSIX.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR BUG @@ -2537,7 +2562,7 @@ struct S {

    It depends on the actual platform whether plain char is handled as signed char by default and so it is caught by this check or not. To change the default behavior you can use -funsigned-char and -fsigned-char compilation options.

    Currently, this check warns in the following cases: - signed char is assigned to an integer variable - signed char and unsigned char are compared with equality/inequality operator - signed char is converted to an integer in the array subscript

    See also: STR34-C. Cast characters to unsigned char before converting to larger integer sizes

    -

    A good example from the CERT description when a char variable is used to read from a file that might contain non-ASCII characters. The problem comes up when the code uses the -1 integer value as EOF, while the 255 character code is also stored as -1 in two's complement form of char type. See a simple example of this bellow. This code stops not only when it reaches the end of the file, but also when it gets a character with the 255 code.

    +

    A good example from the CERT description when a char variable is used to read from a file that might contain non-ASCII characters. The problem comes up when the code uses the -1 integer value as EOF, while the 255 character code is also stored as -1 in two's complement form of char type. See a simple example of this below. This code stops not only when it reaches the end of the file, but also when it gets a character with the 255 code.

    #define EOF (-1)
     
     int read(void) {
    @@ -2582,7 +2607,7 @@ int read(void) {
     

    When true, the check will warn on signed char/unsigned char comparisons, otherwise these comparisons are ignored. By default, this option is set to true.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR BUG @@ -2611,7 +2636,7 @@ int c = sizeof(array_of_strings) / sizeof(array_of_strings[0]); // no warning, d std::array<int, 3> std_array; int d = sizeof(std_array); // no warning, probably intended.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR BUG @@ -2720,8 +2745,12 @@ void getInt(int* dst) {

    WarnOnSizeOfCompareToConstant

    When true, the check will warn on an expression like sizeof(expr) <= k for a suspicious constant k while k is 0 or greater than 0x8000. Default is true.

    +
    +

    WarnOnSizeOfPointerToAggregate

    +

    When true, the check will warn on an expression like sizeof(expr) where the expression is a pointer to aggregate. Default is `true.

    +

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MAJOR CODE_SMELL @@ -2755,7 +2784,7 @@ void getInt(int* dst) {

    This check corresponds to the CERT C++ Coding Standard rule CON54-CPP. Wrap functions that can spuriously wake up in a loop. and CERT C Coding Standard rule CON36-C. Wrap functions that can spuriously wake up in a loop.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR BUG @@ -2797,7 +2826,7 @@ std::string_view("test", 0);

    Semicolon-delimited list of class names to apply this check to. By default ::std::basic_string applies to std::string and std::wstring. Set to e.g. ::std::basic_string;llvm::StringRef;QString to perform this check on custom classes.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR BUG @@ -2828,7 +2857,7 @@ s = std::to_string(x);
    std::string s;
     s = static_cast<char>(6);

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR BUG @@ -2855,7 +2884,7 @@ const char* Bytes[] = "\x03\0x02\0x01\0x00\0xFF\0xFF\0xFF";

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MAJOR BUG @@ -2911,7 +2940,7 @@ accepts_sv({nullptr, 0}); // B

    The source pattern with trailing comment "B" selects the (const CharT*, size_type) constructor which is perfectly valid, since the length argument is 0. It is not changed by this ClangTidy check.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -2982,7 +3011,7 @@ flag |=

    Default value: 0. When non-null the suspicious bitmask usage will be investigated additionally to the different enum usage check.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -3011,7 +3040,7 @@ flag |=

    Default value: "c;cc;cpp;cxx" Likewise, a semicolon-separated list of filename extensions of implementation files.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR BUG @@ -3034,7 +3063,7 @@ flag |=

    See also: EXP42-C. Do not compare padding data and FLP37-C. Do not use object representations to compare floating-point values

    This check is also related to and partially overlaps the CERT C++ Coding Standard rules OOP57-CPP. Prefer special member functions and overloaded operators to C Standard Library functions and EXP62-CPP. Do not access the bits of an object representation that are not part of the object's value representation

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -3076,7 +3105,7 @@ flag |= memset(ip, 0, 1); // OK }

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR BUG @@ -3124,7 +3153,7 @@ const char* B[] = "This" " is a " "test";An unsigned integer specifying the maximum number of concatenated tokens. Default is 5U.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MAJOR CODE_SMELL @@ -3165,7 +3194,7 @@ Token t = readNextToken(); Token t = readNextToken();

    In this case the check will assume that you know what you are doing, and will not raise a warning.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MAJOR BUG @@ -3207,7 +3236,7 @@ if (strcmp(...) != 0) // Won't warn

    A string specifying the comma-separated names of the extra string comparison functions. Default is an empty string. The check will detect the following string comparison functions: __builtin_memcmp, __builtin_strcasecmp, __builtin_strcmp, __builtin_strncasecmp, __builtin_strncmp, _mbscmp, _mbscmp_l, _mbsicmp, _mbsicmp_l, _mbsnbcmp, _mbsnbcmp_l, _mbsnbicmp, _mbsnbicmp_l, _mbsncmp, _mbsncmp_l, _mbsnicmp, _mbsnicmp_l, _memicmp, _memicmp_l, _stricmp, _stricmp_l, _strnicmp, _strnicmp_l, _wcsicmp, _wcsicmp_l, _wcsnicmp, _wcsnicmp_l, lstrcmp, lstrcmpi, memcmp, memicmp, strcasecmp, strcmp, strcmpi, stricmp, strncasecmp, strncmp, strnicmp, wcscasecmp, wcscmp, wcsicmp, wcsncmp, wcsnicmp, wmemcmp.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR BUG @@ -3224,7 +3253,7 @@ if (strcmp(...) != 0) // Won't warn

    bugprone-swapped-arguments

    Finds potentially swapped arguments by looking at implicit conversions.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR BUG @@ -3247,7 +3276,7 @@ do { // some other code } while(false);

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MAJOR CODE_SMELL @@ -3271,7 +3300,7 @@ do { } }

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR BUG @@ -3307,7 +3336,7 @@ do { for (int i = 0; i < size; ++i) {} // warning with MagnitudeBitsUpperLimit = 31 on a system where int is 32-bit }

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR BUG @@ -3324,7 +3353,7 @@ do {

    bugprone-undefined-memory-manipulation

    Finds calls of memory manipulation functions memset(), memcpy() and memmove() on not TriviallyCopyable objects resulting in undefined behavior.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MAJOR BUG @@ -3342,7 +3371,7 @@ do {

    Finds creation of temporary objects in constructors that look like a function call to another constructor of the same class.

    The user most likely meant to use a delegating constructor or base class initializer.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR BUG @@ -3389,7 +3418,7 @@ int *f3() noexcept { return p; }

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -3488,7 +3517,7 @@ public:

    When true, the check will warn only if the container class of the copy assignment operator has any suspicious fields (pointer or C array). This option is set to true by default.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR BUG @@ -3518,7 +3547,7 @@ public:
  • Ignore objects returned from a call.
  • References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MAJOR CODE_SMELL @@ -3546,9 +3575,9 @@ public:
  • std::basic_string::empty() and std::vector::empty(). Not using the return value often indicates that the programmer confused the function with clear().
  • -

    cert-err33-c is an alias of this check that checks a fixed and large set of standard library functions.

    +

    cert-err33-c is an alias of this check that checks a fixed and large set of standard library functions.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MAJOR CODE_SMELL @@ -3665,7 +3694,7 @@ s.str = "Lorem ipsum"; s.i = 99;

    The check will not consider s to be reinitialized after the last line; instead, the line that assigns to s.str will be flagged as a use-after-move. This is intentional as this pattern of reinitializing a struct is error-prone. For example, if an additional member variable is added to S, it is easy to forget to add the reinitialization for this additional member. Instead, it is safer to assign to the entire struct in one go, and this will also avoid the use-after-move warning.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MAJOR BUG @@ -3691,7 +3720,7 @@ struct Derived : Base { // warning: 'Derived::funk' has a similar name and the same signature as virtual method 'Base::func'; did you mean to override it? };

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR CODE_SMELL @@ -3705,13 +3734,13 @@ struct Derived : Base {

    clang-tidy - cert-con36-c

    -
    +

    cert-con36-c

    -

    The cert-con36-c check is an alias, please see bugprone-spuriously-wake-up-functions for more information.

    +

    The cert-con36-c check is an alias, please see bugprone-spuriously-wake-up-functions for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -3723,13 +3752,13 @@ struct Derived : Base {

    clang-tidy - cert-con54-cpp

    -
    +

    cert-con54-cpp

    -

    The cert-con54-cpp check is an alias, please see bugprone-spuriously-wake-up-functions for more information.

    +

    The cert-con54-cpp check is an alias, please see bugprone-spuriously-wake-up-functions for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -3741,13 +3770,13 @@ struct Derived : Base {

    clang-tidy - cert-dcl03-c

    -
    +

    cert-dcl03-c

    -

    The cert-dcl03-c check is an alias, please see misc-static-assert for more information.

    +

    The cert-dcl03-c check is an alias, please see misc-static-assert for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR CODE_SMELL @@ -3761,13 +3790,13 @@ struct Derived : Base {

    clang-tidy - cert-dcl16-c

    -
    +

    cert-dcl16-c

    -

    The cert-dcl16-c check is an alias, please see readability-uppercase-literal-suffix for more information.

    +

    The cert-dcl16-c check is an alias, please see readability-uppercase-literal-suffix for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -3784,7 +3813,7 @@ struct Derived : Base {

    The object returned by a postfix increment or decrement operator is supposed to be a snapshot of the object's value prior to modification. With such an implementation, any modifications made to the resulting object from calling operator++(int) would be modifying a temporary object. Thus, such an implementation of a postfix increment or decrement operator should instead return a const object, prohibiting accidental mutation of a temporary object. Similarly, it is unexpected for the postfix operator to return a reference to its previous state, and any subsequent modifications would be operating on a stale object.

    This check corresponds to the CERT C++ Coding Standard recommendation DCL21-CPP. Overloaded postfix increment and decrement operators should return a const object. However, all of the CERT recommendations have been removed from public view, and so their justification for the behavior of this check requires an account on their wiki to view.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MAJOR CODE_SMELL @@ -3798,13 +3827,13 @@ struct Derived : Base {

    clang-tidy - cert-dcl37-c

    -
    +

    cert-dcl37-c

    -

    The cert-dcl37-c check is an alias, please see bugprone-reserved-identifier for more information.

    +

    The cert-dcl37-c check is an alias, please see bugprone-reserved-identifier for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -3820,7 +3849,7 @@ struct Derived : Base {

    This check flags all function definitions (but not declarations) of C-style variadic functions.

    This check corresponds to the CERT C++ Coding Standard rule DCL50-CPP. Do not define a C-style variadic function.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR CODE_SMELL @@ -3834,13 +3863,13 @@ struct Derived : Base {

    clang-tidy - cert-dcl51-cpp

    -
    +

    cert-dcl51-cpp

    -

    The cert-dcl51-cpp check is an alias, please see bugprone-reserved-identifier for more information.

    +

    The cert-dcl51-cpp check is an alias, please see bugprone-reserved-identifier for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -3852,13 +3881,13 @@ struct Derived : Base {

    clang-tidy - cert-dcl54-cpp

    -
    +

    cert-dcl54-cpp

    -

    The cert-dcl54-cpp check is an alias, please see misc-new-delete-overloads for more information.

    +

    The cert-dcl54-cpp check is an alias, please see misc-new-delete-overloads for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR CODE_SMELL @@ -3873,14 +3902,45 @@ struct Derived : Base {

    clang-tidy - cert-dcl58-cpp

    cert-dcl58-cpp

    -

    Modification of the std or posix namespace can result in undefined behavior. This check warns for such modifications.

    +

    Modification of the std or posix namespace can result in undefined behavior. This check warns for such modifications. The std (or posix) namespace is allowed to be extended with (class or function) template specializations that depend on an user-defined type (a type that is not defined in the standard system headers).

    +

    The check detects the following (user provided) declarations in namespace std or posix:

    +

    Examples:

    namespace std {
    -  int x; // May cause undefined behavior.
    +  int x; // warning: modification of 'std' namespace can result in undefined behavior [cert-dcl58-cpp]
    +}
    +namespace posix::a { // warning: modification of 'posix' namespace can result in undefined behavior
    +}
    +template <>
    +struct ::std::hash<long> { // warning: modification of 'std' namespace can result in undefined behavior
    +  unsigned long operator()(const long &K) const {
    +    return K;
    +  }
    +};
    +struct MyData { long data; };
    +template <>
    +struct ::std::hash<MyData> { // no warning: specialization with user-defined type
    +  unsigned long operator()(const MyData &K) const {
    +    return K.data;
    +  }
    +};
    +namespace std {
    +  template <>
    +  void swap<bool>(bool &a, bool &b); // warning: modification of 'std' namespace can result in undefined behavior
    +  template <>
    +  bool less<void>::operator()<MyData &&, MyData &&>(MyData &&, MyData &&) const { // warning: modification of 'std' namespace can result in undefined behavior
    +    return true;
    +  }
     }

    This check corresponds to the CERT C++ Coding Standard rule DCL58-CPP. Do not modify the standard namespaces.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MAJOR CODE_SMELL @@ -3894,13 +3954,13 @@ struct Derived : Base {

    clang-tidy - cert-dcl59-cpp

    -
    +

    cert-dcl59-cpp

    -

    The cert-dcl59-cpp check is an alias, please see google-build-namespaces for more information.

    +

    The cert-dcl59-cpp check is an alias, please see google-build-namespaces for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -3916,7 +3976,7 @@ struct Derived : Base {

    This check flags calls to system(), popen(), and _popen(), which execute a command processor. It does not flag calls to system() with a null pointer argument, as such a call checks for the presence of a command processor but does not actually attempt to execute a command.

    This check corresponds to the CERT C Coding Standard rule ENV33-C. Do not call system().

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -3928,14 +3988,14 @@ struct Derived : Base {

    clang-tidy - cert-err09-cpp

    -
    +

    cert-err09-cpp

    -

    The cert-err09-cpp check is an alias, please see misc-throw-by-value-catch-by-reference for more information.

    +

    The cert-err09-cpp check is an alias, please see misc-throw-by-value-catch-by-reference for more information.

    This check corresponds to the CERT C++ Coding Standard recommendation ERR09-CPP. Throw anonymous temporaries. However, all of the CERT recommendations have been removed from public view, and so their justification for the behavior of this check requires an account on their wiki to view.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR BUG @@ -3950,7 +4010,7 @@ struct Derived : Base {

    clang-tidy - cert-err33-c

    cert-err33-c

    -

    Warns on unused function return values. Many of the standard library functions return a value that indicates if the call was successful. Ignoring the returned value can cause unexpected behavior if an error has occured. The following functions are checked:

    +

    Warns on unused function return values. Many of the standard library functions return a value that indicates if the call was successful. Ignoring the returned value can cause unexpected behavior if an error has occurred. The following functions are checked:

    -

    This check is an alias of check bugprone-unused-return-value with a fixed set of functions.

    +

    This check is an alias of check bugprone-unused-return-value with a fixed set of functions.

    The check corresponds to a part of CERT C Coding Standard rule ERR33-C. Detect and handle standard library errors. The list of checked functions is taken from the rule, with following exception:

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -4164,7 +4224,7 @@ void func(const char *buff) { }

    This check corresponds to the CERT C Coding Standard rule ERR34-C. Detect errors when converting a string to a number.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR CODE_SMELL @@ -4182,7 +4242,7 @@ void func(const char *buff) {

    This check flags all call expressions involving setjmp() and longjmp().

    This check corresponds to the CERT C++ Coding Standard rule ERR52-CPP. Do not use setjmp() or longjmp().

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -4198,7 +4258,7 @@ void func(const char *buff) {

    This check flags all static or thread_local variable declarations where the initializer for the object may throw an exception.

    This check corresponds to the CERT C++ Coding Standard rule ERR58-CPP. Handle all exceptions thrown before main() begins executing.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -4214,7 +4274,7 @@ void func(const char *buff) {

    This check flags all throw expressions where the exception object is not nothrow copy constructible.

    This check corresponds to the CERT C++ Coding Standard rule ERR60-CPP. Exception objects must be nothrow copy constructible.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR CODE_SMELL @@ -4228,13 +4288,13 @@ void func(const char *buff) {

    clang-tidy - cert-err61-cpp

    -
    +

    cert-err61-cpp

    -

    The cert-err61-cpp check is an alias, please see misc-throw-by-value-catch-by-reference for more information.

    +

    The cert-err61-cpp check is an alias, please see misc-throw-by-value-catch-by-reference for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR BUG @@ -4245,12 +4305,12 @@ void func(const char *buff) { cert-exp42-c cert-exp42-c - +

    cert-exp42-c

    -

    The cert-exp42-c check is an alias, please see bugprone-suspicious-memory-comparison for more information.

    +

    The cert-exp42-c check is an alias, please see bugprone-suspicious-memory-comparison for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -4262,13 +4322,13 @@ void func(const char *buff) {

    clang-tidy - cert-fio38-c

    -
    +

    cert-fio38-c

    -

    The cert-fio38-c check is an alias, please see misc-non-copyable-objects for more information.

    +

    The cert-fio38-c check is an alias, please see misc-non-copyable-objects for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MAJOR CODE_SMELL @@ -4286,7 +4346,7 @@ void func(const char *buff) {

    This check flags for loops where the induction expression has a floating-point type.

    This check corresponds to the CERT C Coding Standard rule FLP30-C. Do not use floating-point variables as loop counters.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR CODE_SMELL @@ -4297,12 +4357,12 @@ void func(const char *buff) { cert-flp37-c cert-flp37-c - +

    cert-flp37-c

    -

    The cert-flp37-c check is an alias, please see bugprone-suspicious-memory-comparison for more information.

    +

    The cert-flp37-c check is an alias, please see bugprone-suspicious-memory-comparison for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -4318,7 +4378,7 @@ void func(const char *buff) {

    This check flags uses of default operator new where the type has extended alignment (an alignment greater than the fundamental alignment). (The default operator new is guaranteed to provide the correct alignment if the requested alignment is less or equal to the fundamental alignment). Only cases are detected (by design) where the operator new is not user-defined and is not a placement new (the reason is that in these cases we assume that the user provided the correct memory allocation).

    This check corresponds to the CERT C++ Coding Standard rule MEM57-CPP. Avoid using default operator new for over-aligned types.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR CODE_SMELL @@ -4332,13 +4392,13 @@ void func(const char *buff) {

    clang-tidy - cert-msc30-c

    -
    +

    cert-msc30-c

    -

    The cert-msc30-c check is an alias, please see cert-msc50-cpp for more information.

    +

    The cert-msc30-c check is an alias, please see cert-msc50-cpp for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -4350,13 +4410,13 @@ void func(const char *buff) {

    clang-tidy - cert-msc32-c

    -
    +

    cert-msc32-c

    -

    The cert-msc32-c check is an alias, please see cert-msc51-cpp for more information.

    +

    The cert-msc32-c check is an alias, please see cert-msc51-cpp for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -4371,7 +4431,7 @@ void func(const char *buff) {

    cert-msc50-cpp

    Pseudorandom number generators use mathematical algorithms to produce a sequence of numbers with good statistical properties, but the numbers produced are not genuinely random. The std::rand() function takes a seed (number), runs a mathematical operation on it and returns the result. By manipulating the seed the result can be predictable. This check warns for the usage of std::rand().

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -4404,7 +4464,7 @@ void func(const char *buff) {

    A comma-separated list of the type names which are disallowed. Default values are time_t, std::time_t.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -4416,14 +4476,14 @@ void func(const char *buff) {

    clang-tidy - cert-oop11-cpp

    -
    +

    cert-oop11-cpp

    -

    The cert-oop11-cpp check is an alias, please see performance-move-constructor-init for more information.

    +

    The cert-oop11-cpp check is an alias, please see performance-move-constructor-init for more information.

    This check corresponds to the CERT C++ Coding Standard recommendation OOP11-CPP. Do not copy-initialize members or base classes from a move constructor. However, all of the CERT recommendations have been removed from public view, and so their justification for the behavior of this check requires an account on their wiki to view.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR CODE_SMELL @@ -4437,13 +4497,13 @@ void func(const char *buff) {

    clang-tidy - cert-oop54-cpp

    -
    +

    cert-oop54-cpp

    -

    The cert-oop54-cpp check is an alias, please see bugprone-unhandled-self-assignment for more information.

    +

    The cert-oop54-cpp check is an alias, please see bugprone-unhandled-self-assignment for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -4474,7 +4534,7 @@ void func(const char *buff) {

    This check corresponds to the CERT C++ Coding Standard rule OOP57-CPP. Prefer special member functions and overloaded operators to C Standard Library functions.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR CODE_SMELL @@ -4492,7 +4552,7 @@ void func(const char *buff) {

    Finds assignments to the copied object and its direct or indirect members in copy constructors and copy assignment operators.

    This check corresponds to the CERT C Coding Standard rule OOP58-CPP. Copy operations must not mutate the source object.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR CODE_SMELL @@ -4506,13 +4566,13 @@ void func(const char *buff) {

    clang-tidy - cert-pos44-c

    -
    +

    cert-pos44-c

    -

    The cert-pos44-c check is an alias, please see bugprone-bad-signal-to-kill-thread for more information.

    +

    The cert-pos44-c check is an alias, please see bugprone-bad-signal-to-kill-thread for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -4524,13 +4584,13 @@ void func(const char *buff) {

    clang-tidy - cert-pos47-c

    -
    +

    cert-pos47-c

    -

    The cert-pos47-c check is an alias, please see concurrency-thread-canceltype-asynchronous for more information.

    +

    The cert-pos47-c check is an alias, please see concurrency-thread-canceltype-asynchronous for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -4542,13 +4602,13 @@ void func(const char *buff) {

    clang-tidy - cert-sig30-c

    -
    +

    cert-sig30-c

    -

    The cert-sig30-c check is an alias, please see bugprone-signal-handler for more information.

    +

    The cert-sig30-c check is an alias, please see bugprone-signal-handler for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -4560,13 +4620,13 @@ void func(const char *buff) {

    clang-tidy - cert-str34-c

    -
    +

    cert-str34-c

    -

    The cert-str34-c check is an alias, please see bugprone-signed-char-misuse for more information.

    +

    The cert-str34-c check is an alias, please see bugprone-signed-char-misuse for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -4584,7 +4644,7 @@ void func(const char *buff) {

    clang-analyzer-core.CallAndMessage

    The clang-analyzer-core.CallAndMessage check is an alias, please see Clang Static Analyzer Available Checkers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -4602,7 +4662,7 @@ void func(const char *buff) {

    clang-analyzer-core.DivideZero

    The clang-analyzer-core.DivideZero check is an alias, please see Clang Static Analyzer Available Checkers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -4617,7 +4677,7 @@ void func(const char *buff) {

    clang-analyzer-core.DynamicTypePropagation

    Generate dynamic type information

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -4635,7 +4695,7 @@ void func(const char *buff) {

    clang-analyzer-core.NonNullParamChecker

    The clang-analyzer-core.NonNullParamChecker check is an alias, please see Clang Static Analyzer Available Checkers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -4653,7 +4713,7 @@ void func(const char *buff) {

    clang-analyzer-core.NullDereference

    The clang-analyzer-core.NullDereference check is an alias, please see Clang Static Analyzer Available Checkers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -4671,7 +4731,7 @@ void func(const char *buff) {

    clang-analyzer-core.StackAddressEscape

    The clang-analyzer-core.StackAddressEscape check is an alias, please see Clang Static Analyzer Available Checkers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -4689,7 +4749,7 @@ void func(const char *buff) {

    clang-analyzer-core.UndefinedBinaryOperatorResult

    The clang-analyzer-core.UndefinedBinaryOperatorResult check is an alias, please see Clang Static Analyzer Available Checkers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -4707,7 +4767,7 @@ void func(const char *buff) {

    clang-analyzer-core.uninitialized.ArraySubscript

    The clang-analyzer-core.uninitialized.ArraySubscript check is an alias, please see Clang Static Analyzer Available Checkers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -4725,7 +4785,7 @@ void func(const char *buff) {

    clang-analyzer-core.uninitialized.Assign

    The clang-analyzer-core.uninitialized.Assign check is an alias, please see Clang Static Analyzer Available Checkers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -4743,7 +4803,7 @@ void func(const char *buff) {

    clang-analyzer-core.uninitialized.Branch

    The clang-analyzer-core.uninitialized.Branch check is an alias, please see Clang Static Analyzer Available Checkers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -4758,7 +4818,7 @@ void func(const char *buff) {

    clang-analyzer-core.uninitialized.CapturedBlockVariable

    Check for blocks that capture uninitialized values

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -4776,7 +4836,7 @@ void func(const char *buff) {

    clang-analyzer-core.uninitialized.UndefReturn

    The clang-analyzer-core.uninitialized.UndefReturn check is an alias, please see Clang Static Analyzer Available Checkers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -4794,7 +4854,7 @@ void func(const char *buff) {

    clang-analyzer-core.VLASize

    The clang-analyzer-core.VLASize check is an alias, please see Clang Static Analyzer Available Checkers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -4809,7 +4869,7 @@ void func(const char *buff) {

    clang-analyzer-cplusplus.InnerPointer

    Check for inner pointers of C++ containers used after re/deallocation

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -4827,7 +4887,7 @@ void func(const char *buff) {

    clang-analyzer-cplusplus.Move

    The clang-analyzer-cplusplus.Move check is an alias, please see Clang Static Analyzer Available Checkers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -4845,7 +4905,7 @@ void func(const char *buff) {

    clang-analyzer-cplusplus.NewDelete

    The clang-analyzer-cplusplus.NewDelete check is an alias, please see Clang Static Analyzer Available Checkers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -4863,7 +4923,7 @@ void func(const char *buff) {

    clang-analyzer-cplusplus.NewDeleteLeaks

    The clang-analyzer-cplusplus.NewDeleteLeaks check is an alias, please see Clang Static Analyzer Available Checkers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -4881,7 +4941,7 @@ void func(const char *buff) {

    clang-analyzer-deadcode.DeadStores

    The clang-analyzer-deadcode.DeadStores check is an alias, please see Clang Static Analyzer Available Checkers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -4899,7 +4959,7 @@ void func(const char *buff) {

    clang-analyzer-nullability.NullableDereferenced

    The clang-analyzer-nullability.NullableDereferenced check is an alias, please see Clang Static Analyzer Available Checkers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -4917,7 +4977,7 @@ void func(const char *buff) {

    clang-analyzer-nullability.NullablePassedToNonnull

    The clang-analyzer-nullability.NullablePassedToNonnull check is an alias, please see Clang Static Analyzer Available Checkers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -4932,7 +4992,7 @@ void func(const char *buff) {

    clang-analyzer-nullability.NullableReturnedFromNonnull

    Warns when a nullable pointer is returned from a function that has _Nonnull return type.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -4950,7 +5010,7 @@ void func(const char *buff) {

    clang-analyzer-nullability.NullPassedToNonnull

    The clang-analyzer-nullability.NullPassedToNonnull check is an alias, please see Clang Static Analyzer Available Checkers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -4968,7 +5028,7 @@ void func(const char *buff) {

    clang-analyzer-nullability.NullReturnedFromNonnull

    The clang-analyzer-nullability.NullReturnedFromNonnull check is an alias, please see Clang Static Analyzer Available Checkers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -4986,7 +5046,7 @@ void func(const char *buff) {

    clang-analyzer-optin.cplusplus.UninitializedObject

    The clang-analyzer-optin.cplusplus.UninitializedObject check is an alias, please see Clang Static Analyzer Available Checkers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -5004,7 +5064,7 @@ void func(const char *buff) {

    clang-analyzer-optin.cplusplus.VirtualCall

    The clang-analyzer-optin.cplusplus.VirtualCall check is an alias, please see Clang Static Analyzer Available Checkers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -5022,7 +5082,7 @@ void func(const char *buff) {

    clang-analyzer-optin.mpi.MPI-Checker

    The clang-analyzer-optin.mpi.MPI-Checker check is an alias, please see Clang Static Analyzer Available Checkers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -5040,7 +5100,7 @@ void func(const char *buff) {

    clang-analyzer-optin.osx.cocoa.localizability.EmptyLocalizationContextChecker

    The clang-analyzer-optin.osx.cocoa.localizability.EmptyLocalizationContextChecker check is an alias, please see Clang Static Analyzer Available Checkers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -5058,7 +5118,7 @@ void func(const char *buff) {

    clang-analyzer-optin.osx.cocoa.localizability.NonLocalizedStringChecker

    The clang-analyzer-optin.osx.cocoa.localizability.NonLocalizedStringChecker check is an alias, please see Clang Static Analyzer Available Checkers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -5073,7 +5133,7 @@ void func(const char *buff) {

    clang-analyzer-optin.osx.OSObjectCStyleCast

    Checker for C-style casts of OSObjects

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -5088,7 +5148,7 @@ void func(const char *buff) {

    clang-analyzer-optin.performance.GCDAntipattern

    Check for performance anti-patterns when using Grand Central Dispatch

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -5103,7 +5163,7 @@ void func(const char *buff) {

    clang-analyzer-optin.performance.Padding

    Check for excessively padded structs.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -5118,7 +5178,7 @@ void func(const char *buff) {

    clang-analyzer-optin.portability.UnixAPI

    Finds implementation-defined behavior in UNIX/Posix functions

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -5136,7 +5196,7 @@ void func(const char *buff) {

    clang-analyzer-osx.API

    The clang-analyzer-osx.API check is an alias, please see Clang Static Analyzer Available Checkers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -5154,7 +5214,7 @@ void func(const char *buff) {

    clang-analyzer-osx.cocoa.AtSync

    The clang-analyzer-osx.cocoa.AtSync check is an alias, please see Clang Static Analyzer Available Checkers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -5169,7 +5229,7 @@ void func(const char *buff) {

    clang-analyzer-osx.cocoa.AutoreleaseWrite

    Warn about potentially crashing writes to autoreleasing objects from different autoreleasing pools in Objective-C

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -5187,7 +5247,7 @@ void func(const char *buff) {

    clang-analyzer-osx.cocoa.ClassRelease

    The clang-analyzer-osx.cocoa.ClassRelease check is an alias, please see Clang Static Analyzer Available Checkers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -5205,7 +5265,7 @@ void func(const char *buff) {

    clang-analyzer-osx.cocoa.Dealloc

    The clang-analyzer-osx.cocoa.Dealloc check is an alias, please see Clang Static Analyzer Available Checkers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -5223,7 +5283,7 @@ void func(const char *buff) {

    clang-analyzer-osx.cocoa.IncompatibleMethodTypes

    The clang-analyzer-osx.cocoa.IncompatibleMethodTypes check is an alias, please see Clang Static Analyzer Available Checkers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -5238,7 +5298,7 @@ void func(const char *buff) {

    clang-analyzer-osx.cocoa.Loops

    Improved modeling of loops using Cocoa collection types

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -5253,7 +5313,7 @@ void func(const char *buff) {

    clang-analyzer-osx.cocoa.MissingSuperCall

    Warn about Objective-C methods that lack a necessary call to super

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -5271,7 +5331,7 @@ void func(const char *buff) {

    clang-analyzer-osx.cocoa.NilArg

    The clang-analyzer-osx.cocoa.NilArg check is an alias, please see Clang Static Analyzer Available Checkers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -5286,7 +5346,7 @@ void func(const char *buff) {

    clang-analyzer-osx.cocoa.NonNilReturnValue

    Model the APIs that are guaranteed to return a non-nil value

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -5304,7 +5364,7 @@ void func(const char *buff) {

    clang-analyzer-osx.cocoa.NSAutoreleasePool

    The clang-analyzer-osx.cocoa.NSAutoreleasePool check is an alias, please see Clang Static Analyzer Available Checkers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -5322,7 +5382,7 @@ void func(const char *buff) {

    clang-analyzer-osx.cocoa.NSError

    The clang-analyzer-osx.cocoa.NSError check is an alias, please see Clang Static Analyzer Available Checkers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -5340,7 +5400,7 @@ void func(const char *buff) {

    clang-analyzer-osx.cocoa.ObjCGenerics

    The clang-analyzer-osx.cocoa.ObjCGenerics check is an alias, please see Clang Static Analyzer Available Checkers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -5358,7 +5418,7 @@ void func(const char *buff) {

    clang-analyzer-osx.cocoa.RetainCount

    The clang-analyzer-osx.cocoa.RetainCount check is an alias, please see Clang Static Analyzer Available Checkers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -5373,7 +5433,7 @@ void func(const char *buff) {

    clang-analyzer-osx.cocoa.RunLoopAutoreleaseLeak

    Check for leaked memory in autorelease pools that will never be drained

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -5391,7 +5451,7 @@ void func(const char *buff) {

    clang-analyzer-osx.cocoa.SelfInit

    The clang-analyzer-osx.cocoa.SelfInit check is an alias, please see Clang Static Analyzer Available Checkers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -5409,7 +5469,7 @@ void func(const char *buff) {

    clang-analyzer-osx.cocoa.SuperDealloc

    The clang-analyzer-osx.cocoa.SuperDealloc check is an alias, please see Clang Static Analyzer Available Checkers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -5427,7 +5487,7 @@ void func(const char *buff) {

    clang-analyzer-osx.cocoa.UnusedIvars

    The clang-analyzer-osx.cocoa.UnusedIvars check is an alias, please see Clang Static Analyzer Available Checkers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -5445,7 +5505,7 @@ void func(const char *buff) {

    clang-analyzer-osx.cocoa.VariadicMethodTypes

    The clang-analyzer-osx.cocoa.VariadicMethodTypes check is an alias, please see Clang Static Analyzer Available Checkers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -5463,7 +5523,7 @@ void func(const char *buff) {

    clang-analyzer-osx.coreFoundation.CFError

    The clang-analyzer-osx.coreFoundation.CFError check is an alias, please see Clang Static Analyzer Available Checkers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -5481,7 +5541,7 @@ void func(const char *buff) {

    clang-analyzer-osx.coreFoundation.CFNumber

    The clang-analyzer-osx.coreFoundation.CFNumber check is an alias, please see Clang Static Analyzer Available Checkers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -5499,7 +5559,7 @@ void func(const char *buff) {

    clang-analyzer-osx.coreFoundation.CFRetainRelease

    The clang-analyzer-osx.coreFoundation.CFRetainRelease check is an alias, please see Clang Static Analyzer Available Checkers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -5517,7 +5577,7 @@ void func(const char *buff) {

    clang-analyzer-osx.coreFoundation.containers.OutOfBounds

    The clang-analyzer-osx.coreFoundation.containers.OutOfBounds check is an alias, please see Clang Static Analyzer Available Checkers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -5535,7 +5595,7 @@ void func(const char *buff) {

    clang-analyzer-osx.coreFoundation.containers.PointerSizedValues

    The clang-analyzer-osx.coreFoundation.containers.PointerSizedValues check is an alias, please see Clang Static Analyzer Available Checkers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -5550,7 +5610,7 @@ void func(const char *buff) {

    clang-analyzer-osx.MIG

    Find violations of the Mach Interface Generator calling convention

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -5565,7 +5625,7 @@ void func(const char *buff) {

    clang-analyzer-osx.NumberObjectConversion

    Check for erroneous conversions of objects representing numbers into numbers

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -5580,7 +5640,7 @@ void func(const char *buff) {

    clang-analyzer-osx.ObjCProperty

    Check for proper uses of Objective-C properties

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -5595,7 +5655,7 @@ void func(const char *buff) {

    clang-analyzer-osx.OSObjectRetainCount

    Check for leaks and improper reference count management for OSObject

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -5613,7 +5673,7 @@ void func(const char *buff) {

    clang-analyzer-osx.SecKeychainAPI

    The clang-analyzer-osx.SecKeychainAPI check is an alias, please see Clang Static Analyzer Available Checkers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -5631,7 +5691,7 @@ void func(const char *buff) {

    clang-analyzer-security.FloatLoopCounter

    The clang-analyzer-security.FloatLoopCounter check is an alias, please see Clang Static Analyzer Available Checkers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -5649,7 +5709,7 @@ void func(const char *buff) {

    clang-analyzer-security.insecureAPI.bcmp

    The clang-analyzer-security.insecureAPI.bcmp check is an alias, please see Clang Static Analyzer Available Checkers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -5667,7 +5727,7 @@ void func(const char *buff) {

    clang-analyzer-security.insecureAPI.bcopy

    The clang-analyzer-security.insecureAPI.bcopy check is an alias, please see Clang Static Analyzer Available Checkers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -5685,7 +5745,7 @@ void func(const char *buff) {

    clang-analyzer-security.insecureAPI.bzero

    The clang-analyzer-security.insecureAPI.bzero check is an alias, please see Clang Static Analyzer Available Checkers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -5703,7 +5763,7 @@ void func(const char *buff) {

    clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling

    The clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling check is an alias, please see Clang Static Analyzer Available Checkers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -5721,7 +5781,7 @@ void func(const char *buff) {

    clang-analyzer-security.insecureAPI.getpw

    The clang-analyzer-security.insecureAPI.getpw check is an alias, please see Clang Static Analyzer Available Checkers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -5739,7 +5799,7 @@ void func(const char *buff) {

    clang-analyzer-security.insecureAPI.gets

    The clang-analyzer-security.insecureAPI.gets check is an alias, please see Clang Static Analyzer Available Checkers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -5757,7 +5817,7 @@ void func(const char *buff) {

    clang-analyzer-security.insecureAPI.mkstemp

    The clang-analyzer-security.insecureAPI.mkstemp check is an alias, please see Clang Static Analyzer Available Checkers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -5775,7 +5835,7 @@ void func(const char *buff) {

    clang-analyzer-security.insecureAPI.mktemp

    The clang-analyzer-security.insecureAPI.mktemp check is an alias, please see Clang Static Analyzer Available Checkers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -5793,7 +5853,7 @@ void func(const char *buff) {

    clang-analyzer-security.insecureAPI.rand

    The clang-analyzer-security.insecureAPI.rand check is an alias, please see Clang Static Analyzer Available Checkers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -5811,7 +5871,7 @@ void func(const char *buff) {

    clang-analyzer-security.insecureAPI.strcpy

    The clang-analyzer-security.insecureAPI.strcpy check is an alias, please see Clang Static Analyzer Available Checkers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -5829,7 +5889,7 @@ void func(const char *buff) {

    clang-analyzer-security.insecureAPI.UncheckedReturn

    The clang-analyzer-security.insecureAPI.UncheckedReturn check is an alias, please see Clang Static Analyzer Available Checkers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -5847,7 +5907,7 @@ void func(const char *buff) {

    clang-analyzer-security.insecureAPI.vfork

    The clang-analyzer-security.insecureAPI.vfork check is an alias, please see Clang Static Analyzer Available Checkers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -5865,7 +5925,7 @@ void func(const char *buff) {

    clang-analyzer-unix.API

    The clang-analyzer-unix.API check is an alias, please see Clang Static Analyzer Available Checkers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -5883,7 +5943,7 @@ void func(const char *buff) {

    clang-analyzer-unix.cstring.BadSizeArg

    The clang-analyzer-unix.cstring.BadSizeArg check is an alias, please see Clang Static Analyzer Available Checkers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -5901,7 +5961,7 @@ void func(const char *buff) {

    clang-analyzer-unix.cstring.NullArg

    The clang-analyzer-unix.cstring.NullArg check is an alias, please see Clang Static Analyzer Available Checkers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -5919,7 +5979,7 @@ void func(const char *buff) {

    clang-analyzer-unix.Malloc

    The clang-analyzer-unix.Malloc check is an alias, please see Clang Static Analyzer Available Checkers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -5937,7 +5997,7 @@ void func(const char *buff) {

    clang-analyzer-unix.MallocSizeof

    The clang-analyzer-unix.MallocSizeof check is an alias, please see Clang Static Analyzer Available Checkers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -5955,7 +6015,7 @@ void func(const char *buff) {

    clang-analyzer-unix.MismatchedDeallocator

    The clang-analyzer-unix.MismatchedDeallocator check is an alias, please see Clang Static Analyzer Available Checkers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -5973,7 +6033,7 @@ void func(const char *buff) {

    clang-analyzer-unix.Vfork

    The clang-analyzer-unix.Vfork check is an alias, please see Clang Static Analyzer Available Checkers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -5988,7 +6048,7 @@ void func(const char *buff) {

    clang-analyzer-valist.CopyToSelf

    Check for va_lists which are copied onto itself.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -6003,7 +6063,7 @@ void func(const char *buff) {

    clang-analyzer-valist.Uninitialized

    Check for usages of uninitialized (or already released) va_lists.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -6018,7 +6078,7 @@ void func(const char *buff) {

    clang-analyzer-valist.Unterminated

    Check for va_lists which are not released by a va_end call.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -6050,7 +6110,7 @@ sleep(1); // implementation may use SIGALRM

    If you want to identify thread-unsafe API for at least one libc or unsure which libc will be used, use any (default).

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -6069,7 +6129,7 @@ sleep(1); // implementation may use SIGALRM

    This check corresponds to the CERT C Coding Standard rule POS47-C. Do not use threads that can be canceled asynchronously.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -6081,13 +6141,13 @@ sleep(1); // implementation may use SIGALRM

    clang-tidy - cppcoreguidelines-avoid-c-arrays

    -
    +

    cppcoreguidelines-avoid-c-arrays

    -

    The cppcoreguidelines-avoid-c-arrays check is an alias, please see modernize-avoid-c-arrays for more information.

    +

    The cppcoreguidelines-avoid-c-arrays check is an alias, please see modernize-avoid-c-arrays for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -6130,7 +6190,7 @@ early_exit: some_operation();

    All other uses of goto are diagnosed in C++.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MAJOR CODE_SMELL @@ -6144,13 +6204,13 @@ some_operation();

    clang-tidy - cppcoreguidelines-avoid-magic-numbers

    -
    +

    cppcoreguidelines-avoid-magic-numbers

    -

    The cppcoreguidelines-avoid-magic-numbers check is an alias, please see readability-magic-numbers for more information.

    +

    The cppcoreguidelines-avoid-magic-numbers check is an alias, please see readability-magic-numbers for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -6189,7 +6249,7 @@ private: };

    Variables: a, c, c_ptr1, c_ptr2, c_const_ptr and c_reference, will all generate warnings since they are either: a globally accessible variable and non-const, a pointer or reference providing global access to non-const data or both.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -6201,13 +6261,13 @@ private:

    clang-tidy - cppcoreguidelines-c-copy-assignment-signature

    -
    +

    cppcoreguidelines-c-copy-assignment-signature

    -

    The cppcoreguidelines-c-copy-assignment-signature check is an alias, please see misc-unconventional-assign-operator for more information.

    +

    The cppcoreguidelines-c-copy-assignment-signature check is an alias, please see misc-unconventional-assign-operator for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR CODE_SMELL @@ -6221,13 +6281,13 @@ private:

    clang-tidy - cppcoreguidelines-explicit-virtual-functions

    -
    +

    cppcoreguidelines-explicit-virtual-functions

    -

    The cppcoreguidelines-explicit-virtual-functions check is an alias, please see modernize-use-override for more information.

    +

    The cppcoreguidelines-explicit-virtual-functions check is an alias, please see modernize-use-override for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -6281,7 +6341,7 @@ void function() {

    A string specifying the header to include to get the definition of NAN. Default is <math.h>.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR CODE_SMELL @@ -6300,7 +6360,7 @@ void function() {

    This rule is part of the "Interfaces" profile of the C++ Core Guidelines, see https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Ri-global-init

    Note that currently this does not flag calls to non-constexpr functions, and therefore globals could still be accessed from functions themselves.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MAJOR CODE_SMELL @@ -6354,7 +6414,7 @@ test.cpp:3:9: warning: variadic macro 'F2' used; consider using a 'c

    Boolean flag to toggle ignoring command-line-defined macros. Default value is true.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -6430,7 +6490,7 @@ test.cpp:3:9: warning: variadic macro 'F2' used; consider using a 'c

    You may have encountered messages like "narrowing conversion from 'unsigned int' to signed type 'int' is implementation-defined". The C/C++ standard does not mandate two's complement for signed integers, and so the compiler is free to define what the semantics are for converting an unsigned integer to signed integer. Clang's implementation uses the two's complement format.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MAJOR CODE_SMELL @@ -6471,7 +6531,7 @@ struct some_struct* s = (struct some_struct*) malloc(sizeof(struct some_struct))

    Semicolon-separated list of fully qualified names of memory allocation functions. Defaults to ::realloc.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -6483,13 +6543,13 @@ struct some_struct* s = (struct some_struct*) malloc(sizeof(struct some_struct))

    clang-tidy - cppcoreguidelines-non-private-member-variables-in-classes

    -
    +

    cppcoreguidelines-non-private-member-variables-in-classes

    -

    The cppcoreguidelines-non-private-member-variables-in-classes check is an alias, please see misc-non-private-member-variables-in-classes for more information.

    +

    The cppcoreguidelines-non-private-member-variables-in-classes check is an alias, please see misc-non-private-member-variables-in-classes for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -6615,7 +6675,7 @@ Owner2 = Owner1; // Conceptual Leak of initial resource of Owner2! Owner1 = nullptr;

    The semantic of a gsl::owner<T*> is mostly like a std::unique_ptr<T>, therefore assignment of two gsl::owner<T*> is considered a move, which requires that the resource Owner2 must have been released before the assignment. This kind of condition could be caught in later improvements of this check with flowsensitive analysis. Currently, the Clang Static Analyzer catches this bug for dynamic memory, but not for general types of resources.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MAJOR CODE_SMELL @@ -6634,7 +6694,7 @@ Owner1 = nullptr;

    This check implements C.49 from the CppCoreGuidelines.

    If the language version is C++ 11 or above, the constructor is the default constructor of the class, the field is not a bitfield (only in case of earlier language version than C++ 20), furthermore the assigned value is a literal, negated literal or enum constant then the preferred place of the initialization is at the class member declaration.

    This latter rule is C.48 from CppCoreGuidelines.

    -

    Please note, that this check does not enforce this latter rule for initializations already implemented as member initializers. For that purpose see check modernize-use-default-member-init.

    +

    Please note, that this check does not enforce this latter rule for initializations already implemented as member initializers. For that purpose see check modernize-use-default-member-init.

    Example 1

    class C {
       int n;
    @@ -6690,7 +6750,7 @@ public:
       }
     };

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR CODE_SMELL @@ -6709,7 +6769,7 @@ public:

    Pointers should not be used as arrays. span<T> is a bounds-checked, safe alternative to using pointers to access arrays.

    This rule is part of the "Bounds safety" profile of the C++ Core Guidelines, see https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Pro-bounds-decay.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -6735,7 +6795,7 @@ public:

    A string specifying which include-style is used, llvm or google. Default is llvm.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -6752,7 +6812,7 @@ public:

    Pointers should only refer to single objects, and pointer arithmetic is fragile and easy to get wrong. span<T> is a bounds-checked, safe type for accessing arrays of data.

    This rule is part of the "Bounds safety" profile of the C++ Core Guidelines, see https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Pro-bounds-arithmetic.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -6769,7 +6829,7 @@ public:

    Modifying a variable that was declared const is undefined behavior, even with const_cast.

    This rule is part of the "Type safety" profile of the C++ Core Guidelines, see https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Pro-type-constcast.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -6786,7 +6846,7 @@ public:

    Use of these casts can violate type safety and cause the program to access a variable that is actually of type X to be accessed as if it were of an unrelated type Z. Note that a C-style (T)expression cast means to perform the first of the following that is possible: a const_cast, a static_cast, a static_cast followed by a const_cast, a reinterpret_cast, or a reinterpret_cast followed by a const_cast. This rule bans (T)expression only when used to perform an unsafe cast.

    This rule is part of the "Type safety" profile of the C++ Core Guidelines, see https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Pro-type-cstylecast.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -6814,7 +6874,7 @@ public:

    This rule is part of the "Type safety" profile of the C++ Core Guidelines, corresponding to rule Type.6. See https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Pro-type-memberinit.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR CODE_SMELL @@ -6833,7 +6893,7 @@ public:

    Use of these casts can violate type safety and cause the program to access a variable that is actually of type X to be accessed as if it were of an unrelated type Z.

    This rule is part of the "Type safety" profile of the C++ Core Guidelines, see https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Pro-type-reinterpretcast.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -6850,7 +6910,7 @@ public:

    Use of these casts can violate type safety and cause the program to access a variable that is actually of type X to be accessed as if it were of an unrelated type Z.

    This rule is part of the "Type safety" profile of the C++ Core Guidelines, see https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Pro-type-downcast.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -6867,7 +6927,7 @@ public:

    Reading from a union member assumes that member was the last one written, and writing to a union member assumes another member with a nontrivial destructor had its destructor called. This is fragile because it cannot generally be enforced to be safe in the language and so relies on programmer discipline to get it right.

    This rule is part of the "Type safety" profile of the C++ Core Guidelines, see https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Pro-type-unions.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -6885,7 +6945,7 @@ public:

    Passing to varargs assumes the correct type will be read. This is fragile because it cannot generally be enforced to be safe in the language and so relies on programmer discipline to get it right.

    This rule is part of the "Type safety" profile of the C++ Core Guidelines, see https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Pro-type-varargs.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -6910,7 +6970,7 @@ D d; use(d); // Slice.

    See the relevant C++ Core Guidelines sections for details: https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#es63-dont-slice https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#c145-access-polymorphic-objects-through-pointers-and-references

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MAJOR CODE_SMELL @@ -6957,7 +7017,7 @@ use(d); // Slice. };

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR CODE_SMELL @@ -7000,7 +7060,7 @@ public: virtual ~Bar(){} };

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -7022,7 +7082,7 @@ public:

    The corresponding information about the problem of OSSpinlock: https://blog.postmates.com/why-spinlocks-are-bad-on-ios-b69fc5221058

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -7040,7 +7100,7 @@ public:

    Programmers have also been known to make dispatch_once_t variables be members of structs or classes, with the intent to lazily perform some expensive struct or class member initialization only once; however, this violates the libdispatch requirements.

    See the discussion section of Apple's dispatch_once documentation for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -7061,7 +7121,7 @@ public: foo(0); // no warning

    See the features disallowed in Fuchsia at https://fuchsia.googlesource.com/zircon/+/master/docs/cxx.md

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -7080,7 +7140,7 @@ foo(0); // no warning

    will cause a warning.

    See the features disallowed in Fuchsia at https://fuchsia.googlesource.com/zircon/+/master/docs/cxx.md

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -7092,13 +7152,13 @@ foo(0); // no warning

    clang-tidy - fuchsia-header-anon-namespaces

    -
    +

    fuchsia-header-anon-namespaces

    -

    The fuchsia-header-anon-namespaces check is an alias, please see google-build-namespace for more information.

    +

    The fuchsia-header-anon-namespaces check is an alias, please see google-build-namespace for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -7143,7 +7203,7 @@ class Good_Child1 : public Interface_A, Interface_B { };

    See the features disallowed in Fuchsia at https://fuchsia.googlesource.com/zircon/+/master/docs/cxx.md

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -7164,7 +7224,7 @@ B &operator=(const B &Other); // No warning B &operator=(B &&Other) // No warning

    See the features disallowed in Fuchsia at https://fuchsia.googlesource.com/zircon/+/master/docs/cxx.md

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -7209,7 +7269,7 @@ extern int get_i(); static C(get_i()) // Warning, as the constructor is dynamically initialized

    See the features disallowed in Fuchsia at https://fuchsia.googlesource.com/zircon/+/master/docs/cxx.md

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR CODE_SMELL @@ -7244,7 +7304,7 @@ auto fn(const T1 &lhs, const T2 &rhs) -> decltype(lhs + rhs) { }

    See the features disallowed in Fuchsia at https://fuchsia.googlesource.com/zircon/+/master/docs/cxx.md

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -7262,7 +7322,7 @@ auto fn(const T1 &lhs, const T2 &rhs) -> decltype(lhs + rhs) {
    class B : public virtual A {};   // warning

    See the features disallowed in Fuchsia at https://fuchsia.googlesource.com/zircon/+/master/docs/cxx.md

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -7279,7 +7339,7 @@ auto fn(const T1 &lhs, const T2 &rhs) -> decltype(lhs + rhs) {

    G++ 4.6 in C++11 mode fails badly if make_pair's template arguments are specified explicitly, and such use isn't intended in any case.

    Corresponding cpplint.py check name: build/explicit_make_pair.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -7302,7 +7362,7 @@ auto fn(const T1 &lhs, const T2 &rhs) -> decltype(lhs + rhs) {

    A comma-separated list of filename extensions of header files (the filename extensions should not include "." prefix). Default is "h,hh,hpp,hxx". For header files without an extension, use an empty string (if there are no other desired extensions) or leave an empty element in the list. e.g., "h,hh,hpp,hxx," (note the trailing comma).

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -7324,7 +7384,7 @@ auto fn(const T1 &lhs, const T2 &rhs) -> decltype(lhs + rhs) { using namespace foo;

    Corresponding cpplint.py check name: build/namespaces.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -7340,7 +7400,7 @@ using namespace foo;

    Checks that default arguments are not given for virtual methods.

    See https://google.github.io/styleguide/cppguide.html#Default_Arguments

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -7381,7 +7441,7 @@ bool f() { ...

    See https://google.github.io/styleguide/cppguide.html#Explicit_Constructors

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -7402,7 +7462,7 @@ bool f() {

    A comma-separated list of filename extensions of header files (the filename extensions should not contain "." prefix). Default is "h". For header files without an extension, use an empty string (if there are no other desired extensions) or leave an empty element in the list. e.g., "h,hh,hpp,hxx," (note the trailing comma).

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -7425,7 +7485,7 @@ Foo *bar = [Foo new]; Foo *bar = [[Foo alloc] init];

    This check corresponds to the Google Objective-C Style Guide rule Do Not Use +new.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -7458,7 +7518,7 @@ Foo *bar = [[Foo alloc] init]; }

    The corresponding style guide rule: https://google.github.io/styleguide/objcguide.html#avoid-throwing-exceptions

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -7481,7 +7541,7 @@ bool IsNegative(int i) { return i < 0; }
    static bool IsPositive(int i) { return i > 0; }
     bool *ABCIsNegative(int i) { return i < 0; }

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -7509,7 +7569,7 @@ bool *ABCIsNegative(int i) { return i < 0; }
    static NSString* __anotherString = @"world";

    The check will give a warning message but will not be able to suggest a fix. The user needs to fix it on their own.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -7534,11 +7594,11 @@ bool *ABCIsNegative(int i) { return i < 0; }

    For example:

    TEST(TestCaseName, Illegal_TestName) {}
     TEST(Illegal_TestCaseName, TestName) {}
    -

    would trigger the check. Underscores are not allowed in test names nor test case names.

    -

    The DISABLED_ prefix, which may be used to disable individual tests, is ignored when checking test names, but the rest of the rest of the test name is still checked.

    +

    would trigger the check. Underscores are not allowed in test names nor test case names.

    +

    The DISABLED_ prefix, which may be used to disable individual tests, is ignored when checking test names, but the rest of the rest of the test name is still checked.

    This check does not propose any fixes.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -7550,13 +7610,13 @@ TEST(Illegal_TestCaseName, TestName) {}

    clang-tidy - google-readability-braces-around-statements

    -
    +

    google-readability-braces-around-statements

    -

    The google-readability-braces-around-statements check is an alias, please see readability-braces-around-statements for more information.

    +

    The google-readability-braces-around-statements check is an alias, please see readability-braces-around-statements for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -7574,7 +7634,7 @@ TEST(Illegal_TestCaseName, TestName) {}

    Corresponding cpplint.py check name: readability/casting.

    This check is similar to -Wold-style-cast, but it suggests automated fixes in some cases. The reported locations should not be different from the ones generated by -Wold-style-cast.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -7586,13 +7646,13 @@ TEST(Illegal_TestCaseName, TestName) {}

    clang-tidy - google-readability-function-size

    -
    +

    google-readability-function-size

    -

    The google-readability-function-size check is an alias, please see readability-function-size for more information.

    +

    The google-readability-function-size check is an alias, please see readability-function-size for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -7604,13 +7664,13 @@ TEST(Illegal_TestCaseName, TestName) {}

    clang-tidy - google-readability-namespace-comments

    -
    +

    google-readability-namespace-comments

    -

    The google-readability-namespace-comments check is an alias, please see llvm-namespace-comment for more information.

    +

    The google-readability-namespace-comments check is an alias, please see llvm-namespace-comment for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -7627,7 +7687,7 @@ TEST(Illegal_TestCaseName, TestName) {}

    The relevant style guide section is https://google.github.io/styleguide/cppguide.html#TODO_Comments.

    Corresponding cpplint.py check: readability/todo

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -7657,7 +7717,7 @@ TEST(Illegal_TestCaseName, TestName) {}

    A string specifying the type suffix. Default is an empty string.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -7674,7 +7734,7 @@ TEST(Illegal_TestCaseName, TestName) {}

    https://google.github.io/styleguide/cppguide.html#Operator_Overloading

    Corresponding cpplint.py check name: runtime/operator.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -7714,7 +7774,7 @@ public: TYPED_TEST_SUITE(BarTest, BarTypes);

    For better consistency of user code, the check renames both virtual and non-virtual member functions with matching names in derived types. The check tries to provide only a warning when a fix cannot be made safely, as is the case with some template and macro uses.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -7726,13 +7786,13 @@ TYPED_TEST_SUITE(BarTest, BarTypes);

    clang-tidy - hicpp-avoid-c-arrays

    -
    +

    hicpp-avoid-c-arrays

    -

    The hicpp-avoid-c-arrays check is an alias, please see modernize-avoid-c-arrays for more information.

    +

    The hicpp-avoid-c-arrays check is an alias, please see modernize-avoid-c-arrays for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -7745,10 +7805,10 @@ TYPED_TEST_SUITE(BarTest, BarTypes);

    clang-tidy - hicpp-avoid-goto

    hicpp-avoid-goto

    -

    The hicpp-avoid-goto check is an alias to cppcoreguidelines-avoid-goto. Rule 6.3.1 High Integrity C++ requires that goto only skips parts of a block and is not used for other reasons.

    +

    The hicpp-avoid-goto check is an alias to cppcoreguidelines-avoid-goto. Rule 6.3.1 High Integrity C++ requires that goto only skips parts of a block and is not used for other reasons.

    Both coding guidelines implement the same exception to the usage of goto.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MAJOR CODE_SMELL @@ -7762,13 +7822,13 @@ TYPED_TEST_SUITE(BarTest, BarTypes);

    clang-tidy - hicpp-braces-around-statements

    -
    +

    hicpp-braces-around-statements

    -

    The hicpp-braces-around-statements check is an alias, please see readability-braces-around-statements for more information. It enforces the rule 6.1.1.

    +

    The hicpp-braces-around-statements check is an alias, please see readability-braces-around-statements for more information. It enforces the rule 6.1.1.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -7780,13 +7840,13 @@ TYPED_TEST_SUITE(BarTest, BarTypes);

    clang-tidy - hicpp-deprecated-headers

    -
    +

    hicpp-deprecated-headers

    -

    The hicpp-deprecated-headers check is an alias, please see modernize-deprecated-headers for more information. It enforces the rule 1.3.3.

    +

    The hicpp-deprecated-headers check is an alias, please see modernize-deprecated-headers for more information. It enforces the rule 1.3.3.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -7818,7 +7878,7 @@ void throwing2() noexcept(false) { throw std::exception(); }

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -7830,19 +7890,19 @@ void throwing2() noexcept(false) {

    clang-tidy - hicpp-explicit-conversions

    -
    +

    hicpp-explicit-conversions

    -

    This check is an alias for google-explicit-constructor. Used to enforce parts of rule 5.4.1. This check will enforce that constructors and conversion operators are marked explicit. Other forms of casting checks are implemented in other places. The following checks can be used to check for more forms of casting:

    +

    This check is an alias for google-explicit-constructor. Used to enforce parts of rule 5.4.1. This check will enforce that constructors and conversion operators are marked explicit. Other forms of casting checks are implemented in other places. The following checks can be used to check for more forms of casting:

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MAJOR CODE_SMELL @@ -7856,18 +7916,18 @@ void throwing2() noexcept(false) {

    clang-tidy - hicpp-function-size

    -
    +

    hicpp-function-size

    -

    This check is an alias for readability-function-size. Useful to enforce multiple sections on function complexity.

    +

    This check is an alias for readability-function-size. Useful to enforce multiple sections on function complexity.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -7879,14 +7939,14 @@ void throwing2() noexcept(false) {

    clang-tidy - hicpp-invalid-access-moved

    -
    +

    hicpp-invalid-access-moved

    -

    This check is an alias for bugprone-use-after-move.

    +

    This check is an alias for bugprone-use-after-move.

    Implements parts of the rule 8.4.1 to check if moved-from objects are accessed.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MAJOR BUG @@ -7900,13 +7960,13 @@ void throwing2() noexcept(false) {

    clang-tidy - hicpp-member-init

    -
    +

    hicpp-member-init

    -

    This check is an alias for cppcoreguidelines-pro-type-member-init. Implements the check for rule 12.4.2 to initialize class members in the right order.

    +

    This check is an alias for cppcoreguidelines-pro-type-member-init. Implements the check for rule 12.4.2 to initialize class members in the right order.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MAJOR CODE_SMELL @@ -7920,13 +7980,13 @@ void throwing2() noexcept(false) {

    clang-tidy - hicpp-move-const-arg

    -
    +

    hicpp-move-const-arg

    -

    The hicpp-move-const-arg check is an alias, please see performance-move-const-arg for more information. It enforces the rule 17.3.1.

    +

    The hicpp-move-const-arg check is an alias, please see performance-move-const-arg for more information. It enforces the rule 17.3.1.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR CODE_SMELL @@ -8001,7 +8061,7 @@ switch(i) {}

    Boolean flag that activates a warning for missing else branches. Default is false.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -8013,14 +8073,14 @@ switch(i) {}

    clang-tidy - hicpp-named-parameter

    -
    +

    hicpp-named-parameter

    -

    This check is an alias for readability-named-parameter.

    +

    This check is an alias for readability-named-parameter.

    Implements rule 8.2.1.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -8032,13 +8092,13 @@ switch(i) {}

    clang-tidy - hicpp-new-delete-operators

    -
    +

    hicpp-new-delete-operators

    -

    This check is an alias for misc-new-delete-overloads. Implements rule 12.3.1 to ensure the new and delete operators have the correct signature.

    +

    This check is an alias for misc-new-delete-overloads. Implements rule 12.3.1 to ensure the new and delete operators have the correct signature.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -8050,13 +8110,13 @@ switch(i) {}

    clang-tidy - hicpp-no-array-decay

    -
    +

    hicpp-no-array-decay

    -

    The hicpp-no-array-decay check is an alias, please see cppcoreguidelines-pro-bounds-array-to-pointer-decay for more information. It enforces the rule 4.1.1.

    +

    The hicpp-no-array-decay check is an alias, please see cppcoreguidelines-pro-bounds-array-to-pointer-decay for more information. It enforces the rule 4.1.1.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -8072,7 +8132,7 @@ switch(i) {}

    Check for assembler statements. No fix is offered.

    Inline assembler is forbidden by the High Integrity C++ Coding Standard as it restricts the portability of code.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -8084,13 +8144,13 @@ switch(i) {}

    clang-tidy - hicpp-no-malloc

    -
    +

    hicpp-no-malloc

    -

    The hicpp-no-malloc check is an alias, please see cppcoreguidelines-no-malloc for more information. It enforces the rule 5.3.2.

    +

    The hicpp-no-malloc check is an alias, please see cppcoreguidelines-no-malloc for more information. It enforces the rule 5.3.2.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -8102,13 +8162,13 @@ switch(i) {}

    clang-tidy - hicpp-noexcept-move

    -
    +

    hicpp-noexcept-move

    -

    This check is an alias for performance-noexcept-move-constructor. Checks rule 12.5.4 to mark move assignment and move construction noexcept.

    +

    This check is an alias for performance-noexcept-move-constructor. Checks rule 12.5.4 to mark move assignment and move construction noexcept.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MAJOR CODE_SMELL @@ -8131,7 +8191,7 @@ switch(i) {}

    If this option is set to true, the check will not warn on bitwise operations with positive integer literals, e.g. ~0, 2 << 1, etc. Default value is false.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -8143,13 +8203,13 @@ switch(i) {}

    clang-tidy - hicpp-special-member-functions

    -
    +

    hicpp-special-member-functions

    -

    This check is an alias for cppcoreguidelines-special-member-functions. Checks that special member functions have the correct signature, according to rule 12.5.7.

    +

    This check is an alias for cppcoreguidelines-special-member-functions. Checks that special member functions have the correct signature, according to rule 12.5.7.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MAJOR CODE_SMELL @@ -8163,13 +8223,13 @@ switch(i) {}

    clang-tidy - hicpp-static-assert

    -
    +

    hicpp-static-assert

    -

    The hicpp-static-assert check is an alias, please see misc-static-assert for more information. It enforces the rule 7.1.10.

    +

    The hicpp-static-assert check is an alias, please see misc-static-assert for more information. It enforces the rule 7.1.10.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR CODE_SMELL @@ -8183,11 +8243,11 @@ switch(i) {}

    clang-tidy - hicpp-undelegated-constructor

    -
    +

    hicpp-undelegated-constructor

    -

    This check is an alias for bugprone-undelegated-constructor. Partially implements rule 12.4.5 to find misplaced constructor calls inside a constructor.

    +

    This check is an alias for bugprone-undelegated-constructor. Partially implements rule 12.4.5 to find misplaced constructor calls inside a constructor.

    struct Ctor {
       Ctor();
       Ctor(int);
    @@ -8201,7 +8261,7 @@ switch(i) {}
    } };

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR BUG @@ -8215,13 +8275,13 @@ switch(i) {}

    clang-tidy - hicpp-uppercase-literal-suffix

    -
    +

    hicpp-uppercase-literal-suffix

    -

    The hicpp-uppercase-literal-suffix check is an alias, please see readability-uppercase-literal-suffix for more information.

    +

    The hicpp-uppercase-literal-suffix check is an alias, please see readability-uppercase-literal-suffix for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -8233,13 +8293,13 @@ switch(i) {}

    clang-tidy - hicpp-use-auto

    -
    +

    hicpp-use-auto

    -

    The hicpp-use-auto check is an alias, please see modernize-use-auto for more information. It enforces the rule 7.1.8.

    +

    The hicpp-use-auto check is an alias, please see modernize-use-auto for more information. It enforces the rule 7.1.8.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -8251,13 +8311,13 @@ switch(i) {}

    clang-tidy - hicpp-use-emplace

    -
    +

    hicpp-use-emplace

    -

    The hicpp-use-emplace check is an alias, please see modernize-use-emplace for more information. It enforces the rule 17.4.2.

    +

    The hicpp-use-emplace check is an alias, please see modernize-use-emplace for more information. It enforces the rule 17.4.2.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -8269,13 +8329,13 @@ switch(i) {}

    clang-tidy - hicpp-use-equals-defaults

    -
    +

    hicpp-use-equals-default

    -

    This check is an alias for modernize-use-equals-default. Implements rule 12.5.1 to explicitly default special member functions.

    +

    This check is an alias for modernize-use-equals-default. Implements rule 12.5.1 to explicitly default special member functions.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -8287,13 +8347,13 @@ switch(i) {}

    clang-tidy - hicpp-use-equals-delete

    -
    +

    hicpp-use-equals-delete

    -

    This check is an alias for modernize-use-equals-delete. Implements rule 12.5.1 to explicitly default or delete special member functions.

    +

    This check is an alias for modernize-use-equals-delete. Implements rule 12.5.1 to explicitly default or delete special member functions.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -8305,13 +8365,13 @@ switch(i) {}

    clang-tidy - hicpp-use-noexcept

    -
    +

    hicpp-use-noexcept

    -

    The hicpp-use-noexcept check is an alias, please see modernize-use-noexcept for more information. It enforces the rule 1.3.5.

    +

    The hicpp-use-noexcept check is an alias, please see modernize-use-noexcept for more information. It enforces the rule 1.3.5.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -8323,13 +8383,13 @@ switch(i) {}

    clang-tidy - hicpp-use-nullptr

    -
    +

    hicpp-use-nullptr

    -

    The hicpp-use-nullptr check is an alias, please see modernize-use-nullptr for more information. It enforces the rule 2.5.3.

    +

    The hicpp-use-nullptr check is an alias, please see modernize-use-nullptr for more information. It enforces the rule 2.5.3.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -8341,13 +8401,13 @@ switch(i) {}

    clang-tidy - hicpp-use-override

    -
    +

    hicpp-use-override

    -

    This check is an alias for modernize-use-override. Implements rule 10.2.1 to declare a virtual function override when overriding.

    +

    This check is an alias for modernize-use-override. Implements rule 10.2.1 to declare a virtual function override when overriding.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -8359,13 +8419,13 @@ switch(i) {}

    clang-tidy - hicpp-vararg

    -
    +

    hicpp-vararg

    -

    The hicpp-vararg check is an alias, please see cppcoreguidelines-pro-type-vararg for more information. It enforces the rule 14.1.1.

    +

    The hicpp-vararg check is an alias, please see cppcoreguidelines-pro-type-vararg for more information. It enforces the rule 14.1.1.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MAJOR CODE_SMELL @@ -8392,7 +8452,7 @@ void *fn() { ERR_PTR(-EINVAL); } /* An invalid use of fn. */ fn();

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -8404,13 +8464,13 @@ fn();

    clang-tidy - llvm-else-after-return

    -
    +

    llvm-else-after-return

    -

    The llvm-else-after-return check is an alias, please see readability-else-after-return for more information.

    +

    The llvm-else-after-return check is an alias, please see readability-else-after-return for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -8427,10 +8487,10 @@ fn();

    Options

    HeaderFileExtensions

    -

    A comma-separated list of filename extensions of header files (the filename extensions should not include "." prefix). Default is "h,hh,hpp,hxx". For header files without an extension, use an empty string (if there are no other desired extensions) or leave an empty element in the list. e.g., "h,hh,hpp,hxx," (note the trailing comma).

    +

    A comma-separated list of filename extensions of header files (the filename extensions should not include "." prefix). Default is "h,hh,hpp,hxx". For header files without an extension, use an empty string (if there are no other desired extensions) or leave an empty element in the list. E.g., "h,hh,hpp,hxx," (note the trailing comma).

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -8446,7 +8506,7 @@ fn();

    Checks the correct order of #includes.

    See https://llvm.org/docs/CodingStandards.html#include-style

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -8482,7 +8542,7 @@ void f();

    An unsigned integer specifying the number of spaces before the comment closing a namespace definition. Default is 1U.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -8518,7 +8578,7 @@ if (auto f = cast<Z>(y)->foo()) {} if (cast<Z>(y)->foo()) {} if (X.cast(y)) {}

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -8543,7 +8603,7 @@ if (X.cast(y)) {} ... }

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -8555,13 +8615,13 @@ if (X.cast(y)) {}

    clang-tidy - llvm-qualified-auto

    -
    +

    llvm-qualified-auto

    -

    The llvm-qualified-auto check is an alias, please see readability-qualified-auto for more information.

    +

    The llvm-qualified-auto check is an alias, please see readability-qualified-auto for more information.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -8581,7 +8641,7 @@ if (X.cast(y)) {} static std::string Moo = (Twine("bark") + "bah").str();

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -8611,7 +8671,7 @@ strlen("world"); } // namespace __llvm_libc

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -8644,7 +8704,7 @@ namespace something_else { void LLVM_LIBC_ENTRYPOINT(strcpy)(char *dest, const char *src) {} }

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -8667,10 +8727,10 @@ namespace something_else {

    Includes

    A string containing a comma separated glob list of allowed include filenames. Similar to the -checks glob list for running clang-tidy itself, the two wildcard characters are * and -, to include and exclude globs, respectively. The default is -*, which disallows all includes.

    This can be used to allow known safe includes such as Linux development headers. See portability-restrict-system-includes -<portability-restrict-system-includes> for more details.

    +<../portability/restrict-system-includes> for more details.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -8764,14 +8824,14 @@ constexpr T pi = T(3.1415926L);

    Options

    HeaderFileExtensions

    -

    A comma-separated list of filename extensions of header files (the filename extensions should not include "." prefix). Default is "h,hh,hpp,hxx". For header files without an extension, use an empty string (if there are no other desired extensions) or leave an empty element in the list. e.g., "h,hh,hpp,hxx," (note the trailing comma).

    +

    A comma-separated list of filename extensions of header files (the filename extensions should not include "." prefix). Default is "h,hh,hpp,hxx". For header files without an extension, use an empty string (if there are no other desired extensions) or leave an empty element in the list. E.g., "h,hh,hpp,hxx," (note the trailing comma).

    UseHeaderFileExtension

    When true, the check will use the file extension to distinguish header files. Default is true.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR CODE_SMELL @@ -8792,13 +8852,13 @@ constexpr T pi = T(3.1415926L); int main() { bool isAdmin = false; - /* } if (isAdmin) begin admins only */ + /* } if (isAdmin) begin admins only */ std::cout << "You are an admin.\n"; - /* end admins only { */ + /* end admins only { */ return 0; }

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -8815,16 +8875,16 @@ int main() {

    An example of such misleading code follows:

    #include <stdio.h>
     
    -short int  = (short int)0;
    -short int  = (short int)12345;
    +short int N = (short int)0;
    +short int l = (short int)12345;
     
     int main() {
    -  int  = ; // a local variable, set to zero?
    -  printf(" is %d\n", );
    -  printf(" is %d\n", );
    +  int N = N; // a local variable, set to zero?
    +  printf("l is %d\n", l);
    +  printf("N is %d\n", N);
     }

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -8846,7 +8906,7 @@ void f(const int_ptr ptr) { }

    The check does not diagnose when the underlying typedef/using type is a pointer to a const type or a function pointer type. This is because the const qualifier is less likely to be mistaken because it would be redundant (or disallowed) on the underlying pointee type.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -8864,7 +8924,7 @@ void f(const int_ptr ptr) {

    The check does not flag implicitly-defined operators, deleted or private operators, or placement operators.

    This check corresponds to CERT C++ Coding Standard rule DCL54-CPP. Overload allocation and deallocation functions as a pair in the same scope.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR CODE_SMELL @@ -8892,7 +8952,7 @@ void f(const int_ptr ptr) {
  • The check does not handle C++ destructors
  • References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -8909,7 +8969,7 @@ void f(const int_ptr ptr) {

    The check flags dereferences and non-pointer declarations of objects that are not meant to be passed by value, such as C FILE objects or POSIX pthread_mutex_t objects.

    This check corresponds to CERT C++ Coding Standard rule FIO38-C. Do not copy a FILE object.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR CODE_SMELL @@ -8936,7 +8996,7 @@ void f(const int_ptr ptr) {

    Allows to ignore (not diagnose) all the member variables declared with a public access specifier.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -8963,7 +9023,7 @@ void f(const int_ptr ptr) { (p->x < p->x) // always false (speed - speed + 1 == 12) // speed - speed is always zero

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -8980,7 +9040,7 @@ void f(const int_ptr ptr) {

    Replaces assert() with static_assert() if the condition is evaluable at compile time.

    The condition of static_assert() is evaluated at compile time which is safer and more efficient.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -8999,7 +9059,7 @@ void f(const int_ptr ptr) {
    Exceptions:

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR CODE_SMELL @@ -9071,7 +9131,7 @@ x.reset(y.release()); -> x = std::move(y);

    A string specifying which include-style is used, llvm or google. Default is llvm.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR CODE_SMELL @@ -9092,7 +9152,7 @@ class C {}; } namespace unused_alias = ::my_namespace;

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -9125,7 +9185,7 @@ static void staticFunctionA() { /*some code that doesn't use `i`*/ }<

    When false (default value), the check will ignore trivially unused parameters, i.e. when the corresponding function has an empty body (and in case of constructors - no constructor initializers). When the function body is empty, an unused parameter is unlikely to be unnoticed by a human reader, and there's basically no place for a bug to hide.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -9143,7 +9203,7 @@ static void staticFunctionA() { /*some code that doesn't use `i`*/ }<
    namespace n { class C; }
     using n::C;  // Never actually used.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -9196,7 +9256,7 @@ int foo() {

    which is correct.

    This check requires using C++14 or higher to run.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -9246,9 +9306,9 @@ inline void bar() { } } -

    Similarly, the main() function is ignored. Its second and third parameters can be either char* argv[] or char** argv, but can not be std::array<>.

    +

    Similarly, the main() function is ignored. Its second and third parameters can be either char* argv[] or char** argv, but cannot be std::array<>.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -9295,7 +9355,7 @@ void t(); } }

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -9310,6 +9370,14 @@ void t();

    modernize-deprecated-headers

    Some headers from C library were deprecated in C++ and are no longer welcome in C++ codebases. Some have no effect in C++. For more details refer to the C++ 14 Standard [depr.c.headers] section.

    This check replaces C standard library headers with their C++ alternatives and removes redundant ones.

    +
    // C++ source file...
    +#include <assert.h>
    +#include <stdbool.h>
    +
    +// becomes
    +
    +#include <cassert>
    +// No 'stdbool.h' here.

    Important note: the Standard doesn't guarantee that the C++ headers declare all the same functions in the global namespace. The check in its current form can break the code that uses library symbols from the global namespace.

    +

    The checker ignores include directives within extern "C" { ... } blocks, since a library might want to expose some API for C and C++ libraries.

    +
    // C++ source file...
    +extern "C" {
    +#include <assert.h>  // Left intact.
    +#include <stdbool.h> // Left intact.
    +}
    +

    Options

    +
    +

    CheckHeaderFile

    +

    clang-tidy cannot know if the header file included by the currently analyzed C++ source file is not included by any other C source files. Hence, to omit false-positives and wrong fixit-hints, we ignore emitting reports into header files. One can set this option to true if they know that the header files in the project are only used by C++ source file. Default is false.

    +

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR CODE_SMELL @@ -9383,7 +9462,7 @@ void t();

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -9557,7 +9636,7 @@ for (vector<int>::iterator it = vec.begin(), e = vec.end(); it != e; ++it)

    As range-based for loops are only available since OpenMP 5, this check should not be used on code with a compatibility requirement of OpenMP prior to version 5. It is intentional that this check does not make any attempts to exclude incorrect diagnostics on OpenMP for loops prior to OpenMP 5.

    To prevent this check to be applied (and to break) OpenMP for loops but still be applied to non-OpenMP for loops the usage of NOLINT (see clang-tidy-nolint) on the specific for loops is recommended.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR CODE_SMELL @@ -9606,7 +9685,7 @@ my_ptr = std::make_shared<MyPair>(1, 2);

    If set to non-zero, the check does not suggest edits that will transform default initialization into value initialization, as this can cause performance regressions. Default is 1.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -9653,7 +9732,7 @@ my_ptr = std::make_unique<MyPair>(1, 2);

    If set to non-zero, the check does not suggest edits that will transform default initialization into value initialization, as this can cause performance regressions. Default is 1.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -9757,7 +9836,7 @@ public: + C(std::string S) : S(std::move(S)) {} };
    -

    For more information about the pass-by-value idiom, read: Want Speed? Pass by Value.

    +

    For more information about the pass-by-value idiom, read: Want Speed? Pass by Value.

    Options

    @@ -9769,7 +9848,7 @@ public:

    When true, the check only warns about copied parameters that are already passed by value. Default is false.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -9805,7 +9884,7 @@ const char *const RegEx{R"(\w\([a-z]\))"};

    A string literal containing only escaped newlines is a common way of writing lines of text output. Introducing physical newlines with raw string literals in this case is likely to impede readability. These string literals are left unchanged.

    An escaped horizontal tab, form feed, or vertical tab prevents the string literal from being converted. The presence of a horizontal tab, form feed or vertical tab in source code is not visually obvious.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -9858,7 +9937,7 @@ const char *const RegEx{R"(\w\([a-z]\))"};

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR CODE_SMELL @@ -9920,7 +9999,7 @@ void f() {

    A string specifying which include-style is used, llvm or google. Default is llvm.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -9950,7 +10029,7 @@ private:

    Known Limitations

    Options

    @@ -9959,7 +10038,7 @@ private:

    See: https://en.cppreference.com/w/cpp/language/function#Deleted_functions

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -9994,7 +10073,7 @@ std::random_shuffle(vec.begin(), vec.end(), randomFunc); return std::mt19937(seq); }());

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -10020,7 +10099,7 @@ Foo bar() { return {baz}; }

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -10036,7 +10115,7 @@ Foo bar() {

    Replace copy and swap tricks on shrinkable containers with the shrink_to_fit() method call.

    The shrink_to_fit() method is more readable and more effective than the copy and swap trick to reduce the capacity of a shrinkable container. Note that, the shrink_to_fit() method is only available in C++11 and up.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -10060,7 +10139,7 @@ Foo bar() { static_assert(sizeof(a) <= 10); }

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -10222,7 +10301,7 @@ auto *my_first_pointer = new TypeName, *my_second_pointer = new TypeName; auto my_first_pointer = new TypeName, my_second_pointer = new TypeName;

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -10253,7 +10332,7 @@ bool x = p ? true : false;

    If set to true, the check will not give warnings inside macros. Default is true.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR CODE_SMELL @@ -10306,7 +10385,7 @@ struct A {

    If this option is set to true (default is true), the check will not warn about members declared inside macros.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -10315,7 +10394,8 @@ struct A { modernize-use-default modernize-use-default - +
    orphan
    @@ -10323,13 +10403,13 @@ struct A {

    clang-tidy - modernize-use-default

    -
    +

    modernize-use-default

    -

    This check has been renamed to modernize-use-equals-default.

    +

    This check has been renamed to modernize-use-equals-default.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -10342,22 +10422,32 @@ struct A {

    clang-tidy - modernize-use-emplace

    modernize-use-emplace

    -

    The check flags insertions to an STL-style container done by calling the push_back method with an explicitly-constructed temporary of the container element type. In this case, the corresponding emplace_back method results in less verbose and potentially more efficient code. Right now the check doesn't support push_front and insert. It also doesn't support insert functions for associative containers because replacing insert with emplace may result in speed regression, but it might get support with some addition flag in the future.

    -

    By default only std::vector, std::deque, std::list are considered. This list can be modified using the ContainersWithPushBack option.

    +

    The check flags insertions to an STL-style container done by calling the push_back, push, or push_front methods with an explicitly-constructed temporary of the container element type. In this case, the corresponding emplace equivalent methods result in less verbose and potentially more efficient code. Right now the check doesn't support insert. It also doesn't support insert functions for associative containers because replacing insert with emplace may result in speed regression, but it might get support with some addition flag in the future.

    +

    The ContainersWithPushBack, ContainersWithPush, and ContainersWithPushFront options are used to specify the container types that support the push_back, push, and push_front operations respectively. The default values for these options are as follows:

    + +

    This check also reports when an emplace-like method is improperly used, for example using emplace_back while also calling a constructor. This creates a temporary that requires at best a move and at worst a copy. Almost all emplace-like functions in the STL are covered by this, with try_emplace on std::map and std::unordered_map being the exception as it behaves slightly differently than all the others. More containers can be added with the EmplacyFunctions option, so long as the container defines a value_type type, and the emplace-like functions construct a value_type object.

    Before:

    std::vector<MyClass> v;
     v.push_back(MyClass(21, 37));
    +v.emplace_back(MyClass(21, 37));
     
     std::vector<std::pair<int, int>> w;
     
     w.push_back(std::pair<int, int>(21, 37));
    -w.push_back(std::make_pair(21L, 37L));
    +w.push_back(std::make_pair(21L, 37L)); +w.emplace_back(std::make_pair(21L, 37L));

    After:

    std::vector<MyClass> v;
     v.emplace_back(21, 37);
    +v.emplace_back(21, 37);
     
     std::vector<std::pair<int, int>> w;
     w.emplace_back(21, 37);
    +w.emplace_back(21L, 37L);
     w.emplace_back(21L, 37L);

    By default, the check is able to remove unnecessary std::make_pair and std::make_tuple calls from push_back calls on containers of std::pair and std::tuple. Custom tuple-like types can be modified by the TupleTypes option; custom make functions can be modified by the TupleMakeFunctions option.

    The other situation is when we pass arguments that will be converted to a type inside a container.

    @@ -10390,6 +10480,14 @@ v.push_back(std::unique_ptr<int>(ptr));

    Semicolon-separated list of class names of custom containers that support push_back.

    +

    ContainersWithPush

    +

    Semicolon-separated list of class names of custom containers that support push.

    +
    +
    +

    ContainersWithPushFront

    +

    Semicolon-separated list of class names of custom containers that support push_front.

    +
    +

    IgnoreImplicitConstructors

    When true, the check will ignore implicitly constructed arguments of push_back, e.g.

    std::vector<std::string> v;
    @@ -10408,15 +10506,21 @@ v.push_back("a"); // Ignored when IgnoreImplicitConstructors is `true`
     

    TupleMakeFunctions

    Semicolon-separated list of std::make_tuple-like function names. Those function calls will be removed from push_back calls and turned into emplace_back.

    +
    +

    EmplacyFunctions

    +

    Semicolon-separated list of containers without their template parameters and some emplace-like method of the container. Example: vector::emplace_back. Those methods will be checked for improper use and the check will report when a temporary is unnecessarily created.

    +

    Example

    std::vector<MyTuple<int, bool, char>> x;
    -x.push_back(MakeMyTuple(1, false, 'x'));
    +x.push_back(MakeMyTuple(1, false, 'x')); +x.emplace_back(MakeMyTuple(1, false, 'x'));

    transforms to:

    std::vector<MyTuple<int, bool, char>> x;
    +x.emplace_back(1, false, 'x');
     x.emplace_back(1, false, 'x');
    -

    when TupleTypes is set to MyTuple and TupleMakeFunctions is set to MakeMyTuple.

    +

    when TupleTypes is set to MyTuple, TupleMakeFunctions is set to MakeMyTuple, and EmplacyFunctions is set to vector::emplace_back.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]>
    INFO CODE_SMELL @@ -10455,7 +10559,7 @@ A::~A() = default;

    If set to true, the check will not give warnings inside macros. Default is true.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -10487,7 +10591,7 @@ private:

    If this option is set to true (default is true), the check will not warn about functions declared inside macros.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -10550,7 +10654,7 @@ NO_DISCARD bool empty(int i) const;

    For alternative __attribute__ syntax options to mark functions as [[nodiscard]] in non-c++17 source code. See https://clang.llvm.org/docs/AttributeReference.html#nodiscard-warn-unused-result

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -10606,7 +10710,7 @@ struct bar { }

    if the UseNoexceptFalse option is set to false.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -10657,7 +10761,7 @@ void assignment() { }

    if the NullMacros option is set to MY_NULL.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR CODE_SMELL @@ -10706,7 +10810,7 @@ void assignment() {

    For more information on the use of override see https://en.cppreference.com/w/cpp/language/override

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -10754,7 +10858,7 @@ class CC { auto CC::m() -> S { return {0}; } // error

    This code fails to compile because the S in the context of f refers to the equally named function parameter. Similarly, the S in the context of m refers to the equally named class member. The check can currently only detect and avoid a clash with a function parameter name.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -10786,7 +10890,7 @@ std::map<const char *, std::string, std::greater<std::string>> s;

    This check requires using C++14 or higher to run.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -10848,7 +10952,7 @@ int main() { res = uncaught_exceptions(); }

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -10884,7 +10988,7 @@ using R_p = R_t*;

    If set to true, the check will not give warnings inside macros. Default is true.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -10911,7 +11015,7 @@ MPI_Send(buf, 1, MPI_SHORT, 0, 0, MPI_COMM_WORLD); short *buf[1]; MPI_Send(buf, 1, MPI_SHORT, 0, 0, MPI_COMM_WORLD);

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MAJOR CODE_SMELL @@ -10936,7 +11040,7 @@ MPI_Send(&buf, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD); int buf; MPI_Send(&buf, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR BUG @@ -10954,7 +11058,7 @@ MPI_Send(&buf, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);

    Finds improper usages of XCTAssertEqual and XCTAssertNotEqual and replaces them with XCTAssertEqualObjects or XCTAssertNotEqualObjects.

    This makes tests less fragile, as many improperly rely on pointer equality for strings that have equal values. This assumption is not guarantted by the language.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -10971,7 +11075,7 @@ MPI_Send(&buf, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);

    According to Apple developer document, we should always use factory method errorWithDomain:code:userInfo: to create new NSError objects instead of [NSError alloc] init]. Otherwise it will lead to a warning message during runtime.

    The corresponding information about NSError creation: https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/ErrorHandlingCocoa/CreateCustomizeNSError/CreateCustomizeNSError.html

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR BUG @@ -10989,7 +11093,7 @@ MPI_Send(&buf, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);

    Finds implementations of -dealloc in Objective-C categories. The category implementation will override any -dealloc in the class implementation, potentially causing issues.

    Classes implement -dealloc to perform important actions to deallocate an object. If a category on the class implements -dealloc, it will override the class's implementation and unexpected deallocation behavior may occur.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -11017,7 +11121,7 @@ MPI_Send(&buf, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);

    Defaults to ABNewPersonViewController;ABPeoplePickerNavigationController;ABPersonViewController;ABUnknownPersonViewController;NSHashTable;NSMapTable;NSPointerArray;NSPointerFunctions;NSTimer;UIActionSheet;UIAlertView;UIImagePickerController;UITextInputMode;UIWebView.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR BUG @@ -11036,7 +11140,7 @@ MPI_Send(&buf, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);

    Apple documentation highlights that objects that are equal must have the same hash value: https://developer.apple.com/documentation/objectivec/1418956-nsobject/1418795-isequal?language=objc

    Note that the check only verifies the presence of -hash in scenarios where its omission could result in unexpected behavior. The verification of the implementation of -hash is the responsibility of the developer, e.g., through the addition of unit tests to verify the implementation.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -11066,7 +11170,7 @@ __unsafe_unretained id returnValue;
    // "id _returnValue" is declaration of instance variable of class.
     [invocation getReturnValue:&self->_returnValue];

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -11092,7 +11196,7 @@ __unsafe_unretained id returnValue;
    @property(nonatomic, assign) int abc_lowerCamelCase;

    The corresponding style rule: https://developer.apple.com/library/content/qa/qa1908/_index.html

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -11108,7 +11212,7 @@ __unsafe_unretained id returnValue;

    Finds invocations of -self on super instances in initializers of subclasses of NSObject and recommends calling a superclass initializer instead.

    Invoking -self on super instances in initializers is a common programmer error when the programmer's original intent is to call a superclass initializer. Failing to call a superclass initializer breaks initializer chaining and can result in invalid object initialization.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -11131,7 +11235,7 @@ __unsafe_unretained id returnValue;

    Comma-separated list containing type names which are not counted as thrown exceptions in the check. Default value is an empty string.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -11147,7 +11251,7 @@ __unsafe_unretained id returnValue;

    Finds OpenMP directives that are allowed to contain a default clause, but either don't specify it or the clause is specified but with the kind other than none, and suggests to use the default(none) clause.

    Using default(none) clause forces developers to explicitly specify data sharing attributes for the variables referenced in the construct, thus making it obvious which variables are referenced, and what is their data sharing attribute, thus increasing readability and possibly making errors easier to spot.

    Example

    -
    // ``for`` directive can not have ``default`` clause, no diagnostics.
    +
    // ``for`` directive cannot have ``default`` clause, no diagnostics.
     void n0(const int a) {
     #pragma omp for
       for (int b = 0; b < a; b++)
    @@ -11190,7 +11294,7 @@ void p0_3() {
       //          clause. Consider using ``default(none)`` clause instead.
     }

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -11216,7 +11320,7 @@ str.find('A');

    Semicolon-separated list of names of string-like classes. By default only ::std::basic_string and ::std::basic_string_view are considered. The check will only consider member functions named find, rfind, find_first_of, find_first_not_of, find_last_of, or find_last_not_of within these classes.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR CODE_SMELL @@ -11248,7 +11352,7 @@ str.find('A');

    A semicolon-separated list of names of types allowed to be copied in each iteration. Regular expressions are accepted, e.g. [Rr]ef(erence)?$ matches every type with suffix Ref, ref, Reference and reference. The default is empty. If a name in the list contains the sequence :: it is matched against the qualified typename (i.e. namespace::Type, otherwise it is matched against only the type name (i.e. Type).

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR CODE_SMELL @@ -11259,7 +11363,8 @@ str.find('A'); performance-implicit-cast-in-loop performance-implicit-cast-in-loop - +
    orphan
    @@ -11267,13 +11372,13 @@ str.find('A');

    clang-tidy - performance-implicit-cast-in-loop

    -
    +

    performance-implicit-cast-in-loop

    -

    This check has been renamed to performance-implicit-conversion-in-loop.

    +

    This check has been renamed to performance-implicit-conversion-in-loop.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR CODE_SMELL @@ -11296,7 +11401,7 @@ for (const pair<int, vector<string>>& p : my_map) {} // that the compiler added a conversion, resulting in a copy of the vectors.

    The easiest solution is usually to use const auto& instead of writing the type manually.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR CODE_SMELL @@ -11326,7 +11431,7 @@ auto c = std::count(s.begin(), s.end(), 43); auto c = s.count(43);

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR CODE_SMELL @@ -11372,7 +11477,7 @@ void g() {

    When false, the check will only check the string usage in while, for and for-range statements. Default is false.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]>
    MINOR CODE_SMELL @@ -11430,7 +11535,7 @@ for (auto element : data) {

    When true, the check will also warn on inefficient operations for proto repeated fields. Otherwise, the check only warns on inefficient vector operations. Default is false.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR CODE_SMELL @@ -11472,7 +11577,7 @@ f(std::move(s)); // Warning: passing result of std::move as a const reference a

    If true, enables detection of std::move() passed as a const reference argument. Default is true.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR CODE_SMELL @@ -11490,7 +11595,7 @@ f(std::move(s)); // Warning: passing result of std::move as a const reference a

    "cert-oop11-cpp" redirects here as an alias for this check.

    The check flags user-defined move constructors that have a ctor-initializer initializing a member or base class through a copy constructor instead of a move constructor.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR CODE_SMELL @@ -11528,7 +11633,7 @@ StatusOr<std::vector<int>> NotCool() { }

    In that case the fix is more consensual: just return std::move(obj). This is handled by the -Wreturn-std-move warning.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR CODE_SMELL @@ -11564,7 +11669,7 @@ tgt(char* maybe_underbiased_ptr) { return maybe_underbiased_ptr + bias; }

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR CODE_SMELL @@ -11582,7 +11687,7 @@ tgt(char* maybe_underbiased_ptr) {

    The check flags user-defined move constructors and assignment operators not marked with noexcept or marked with noexcept(expr) where expr evaluates to false (but is not a false literal itself).

    Move constructors of all the types used with STL containers, for example, need to be declared noexcept. Otherwise STL will choose copy constructors instead. The same is valid for move assignment operations.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR CODE_SMELL @@ -11604,7 +11709,7 @@ tgt(char* maybe_underbiased_ptr) { }; A::~A() = default;

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR CODE_SMELL @@ -11629,7 +11734,7 @@ asin(a); float a; std::asin(a);

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR CODE_SMELL @@ -11675,7 +11780,7 @@ void Function(const Foo& foo) {

    A semicolon-separated list of names of types whose methods are allowed to return the const reference the variable is copied from. When an expensive to copy variable is copy initialized by the return value from a type on this list the check does not trigger. This can be used to exclude types known to be const incorrect or where the lifetime or immutability of returned references is not tied to mutations of the container. An example are view types that don't own the underlying data. Like for AllowedTypes above, regular expressions are accepted and the inclusion of :: determines whether the qualified typename is matched or not.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR CODE_SMELL @@ -11728,7 +11833,7 @@ void setValue(string Value) {

    A semicolon-separated list of names of types allowed to be passed by value. Regular expressions are accepted, e.g. [Rr]ef(erence)?$ matches every type with suffix Ref, ref, Reference and reference. The default is empty. If a name in the list contains the sequence :: it is matched against the qualified typename (i.e. namespace::Type, otherwise it is matched against only the type name (i.e. Type).

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR CODE_SMELL @@ -11768,7 +11873,7 @@ void setValue(string Value) {

    A string containing a comma separated glob list of allowed include filenames. Similar to the -checks glob list for running clang-tidy itself, the two wildcard characters are * and -, to include and exclude globs, respectively. The default is *, which allows all includes.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR CODE_SMELL @@ -11802,7 +11907,7 @@ vec_add(a, b); // Power

    The namespace used to suggest P0214 alternatives. If not specified, std:: for -std=c++20 and std::experimental:: for -std=c++11.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -11820,8 +11925,13 @@ vec_add(a, b); // Power

    Examples:

    void f(const string);   // Bad: const is top level.
     void f(const string&);  // Good: const is not top level.
    +

    Options

    +
    +

    IgnoreMacros

    +

    If set to true, the check will not give warnings inside macros. Default is true.

    +

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR CODE_SMELL @@ -11852,7 +11962,7 @@ void f(const string&); // Good: const is not top level.

    The number of lines is counted from the end of condition or initial keyword (do/else) until the last line of the inner statement. Default value 0 means that braces will be added to all statements (not having them already).

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR CODE_SMELL @@ -11876,8 +11986,13 @@ Clazz *const foo();
    const int* foo();
     const int& foo();
     const Clazz* foo();
    +

    Options

    +
    +

    IgnoreMacros

    +

    If set to true, the check will not give warnings inside macros. Default is true.

    +

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR CODE_SMELL @@ -11935,7 +12050,7 @@ const Clazz* foo();

    This check applies to std::set, std::unordered_set, std::map, std::unordered_map and the corresponding multi-key variants. It is only active for C++20 and later, as the contains method was only added in C++20.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -11951,7 +12066,7 @@ const Clazz* foo();

    Finds cases where code could use data() rather than the address of the element at index 0 in a container. This pattern is commonly used to materialize a pointer to the backing data of a container. std::vector and std::string provide a data() accessor to retrieve the data pointer which should be preferred.

    This also ensures that in the case that the container is empty, the data pointer access does not perform an errant memory access.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -11971,7 +12086,7 @@ const Clazz* foo(); bool empty() const;

    size_type can be any kind of integer type.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR CODE_SMELL @@ -11988,25 +12103,9 @@ bool empty() const;

    readability-convert-member-functions-to-static

    Finds non-static member functions that can be made static because the functions don't use this.

    After applying modifications as suggested by the check, running the check again might find more opportunities to mark member functions static.

    -

    After making a member function static, you might want to run the check readability-static-accessed-through-instance to replace calls like Instance.method() by Class::method().

    +

    After making a member function static, you might want to run the check readability-static-accessed-through-instance to replace calls like Instance.method() by Class::method().

    References

    -

    clang.llvm.org

    ]]> - - INFO - CODE_SMELL - - - readability-data-pointer - readability-data-pointer - - -

    clang-tidy - readability-data-pointer

    - -

    readability-data-pointer

    -

    Finds cases where code could use data() rather than the address of the element at index 0 in a container. This pattern is commonly used to materialize a pointer to the backing data of a container. std::vector and std::string provide a data() accessor to retrieve the data pointer which should be preferred.

    -

    This also ensures that in the case that the container is empty, the data pointer access does not perform an errant memory access.

    -

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]>
    INFO CODE_SMELL @@ -12024,7 +12123,7 @@ bool empty() const; if (p) delete p;

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -12049,11 +12148,12 @@ if (p)
    #undef NDEBUG
     #include "assertion.h"
     // ...code with assertions enabled
    +
     #define NDEBUG
     #include "assertion.h"
     // ...code with assertions disabled

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -12121,7 +12221,7 @@ if (p)

    There is an alias of this check called llvm-else-after-return. In that version the options WarnOnUnfixable and WarnOnConditionVariables are both set to false by default.

    This check helps to enforce this LLVM Coding Standards recommendation.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -12268,7 +12368,7 @@ if (p)

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR CODE_SMELL @@ -12311,7 +12411,7 @@ if (p)

    Flag functions exceeding this number of variables declared in the body. The default is -1 (ignore the number of variables). Please note that function parameters and variables declared in lambdas, GNU Statement Expressions, and nested class inline functions are not counted.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR CODE_SMELL @@ -12400,7 +12500,7 @@ catch (const std::exception& e) { }

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -14565,7 +14665,7 @@ double dValueDouble = 0.0; ULONG ulValueUlong = 0; DWORD dwValueDword = 0;

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR CODE_SMELL @@ -14576,7 +14676,8 @@ DWORD dwValueDword = 0; readability-implicit-bool-cast readability-implicit-bool-cast - +
    orphan
    @@ -14584,13 +14685,13 @@ DWORD dwValueDword = 0;

    clang-tidy - readability-implicit-bool-cast

    -
    +

    readability-implicit-bool-cast

    -

    This check has been renamed to readability-implicit-bool-conversion.

    +

    This check has been renamed to readability-implicit-bool-conversion.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -14691,7 +14792,7 @@ void conversionsFromBool() {

    When true, the check will allow conditional pointer conversions. Default is false.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]>
    INFO CODE_SMELL @@ -14733,7 +14834,7 @@ int foo(int b) { return b + 2; } // definition with use of "b"<

    If this option is set to true (default is false), then names must match exactly (or be absent).

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR CODE_SMELL @@ -14814,7 +14915,7 @@ void macros() { // Won't be transformed, but a diagnostic is emitted. }

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -14893,7 +14994,7 @@ for (int mm = 1; mm <= MONTHS_IN_A_YEAR; ++mm) {

    Boolean value indicating whether to accept magic numbers as bit field widths without warning. This is useful for example for register definitions which are generated from hardware specifications. Default value is true.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -14925,7 +15026,7 @@ for (int mm = 1; mm <= MONTHS_IN_A_YEAR; ++mm) {
  • contain a const_cast
  • are templated or part of a class template
  • have an empty body
  • -
  • do not (implicitly) use this at all (see readability-convert-member-functions-to-static).
  • +
  • do not (implicitly) use this at all (see readability-convert-member-functions-to-static).
  • The following real-world examples will be preserved by the check:

    class E1 {
    @@ -14949,7 +15050,7 @@ public:
     };

    After applying modifications as suggested by the check, running the check again might find more opportunities to mark member functions const.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -14980,7 +15081,7 @@ if (cond1)

    Limitations

    Note that this check only works as expected when the tabs or spaces are used consistently and not mixed.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -15011,7 +15112,7 @@ if (cond1)

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -15030,7 +15131,7 @@ if (cond1)

    All parameters should be named, with identical names in the declaration and implementation.

    Corresponding cpplint.py check name: readability/function.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -15081,7 +15182,7 @@ void f4(int *p) { int &x = *p; }

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -15137,7 +15238,7 @@ const auto *Foo2 = cast<const int *>(Bar2); const auto &Foo3 = cast<const int &>(Bar3);

    Note in the LLVM alias, the default value is false.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -15176,7 +15277,7 @@ public: }

    If CheckFirstDeclaration option is enabled, a warning about redundant access specifier will be emitted, because public is the default member access for structs.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -15215,7 +15316,7 @@ void f() { } }

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -15245,7 +15346,7 @@ extern int X;

    If set to true, the check will not give warnings inside macros. Default is true.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -15270,7 +15371,7 @@ int (*p)(int, int) = &f; int i = (*p)(10, 50);

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -15306,7 +15407,7 @@ struct Foo : public Bar { std::string s; };

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -15362,7 +15463,7 @@ void f(); #endif #endif

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -15386,7 +15487,7 @@ if (ptr.get() == nullptr) ... => if (ptr == nullptr) ...

    If this option is set to true (default is true), the check will not warn about calls inside macros.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR CODE_SMELL @@ -15403,7 +15504,7 @@ if (ptr.get() == nullptr) ... => if (ptr == nullptr) ...

    readability-redundant-string-cstr

    Finds unnecessary calls to std::string::c_str() and std::string::data().

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MINOR CODE_SMELL @@ -15444,7 +15545,7 @@ std::string_view b;

    Semicolon-delimited list of class names to apply this check to. By default ::std::basic_string applies to std::string and std::wstring. Set to e.g. ::std::basic_string;llvm::StringRef;QString to perform this check on custom classes.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -15457,7 +15558,7 @@ std::string_view b;

    clang-tidy - readability-simplify-boolean-expr

    readability-simplify-boolean-expr

    -

    Looks for boolean expressions involving boolean constants and simplifies them to use the appropriate boolean expression directly.

    +

    Looks for boolean expressions involving boolean constants and simplifies them to use the appropriate boolean expression directly. Simplifies boolean expressions by application of DeMorgan's Theorem.

    Examples:

    @@ -15563,6 +15664,42 @@ std::string_view b;

    return !e;

    + + + + + + + + + + + + + + + + + + + + + + + +
    !(!a || b)
    +

    a && !b

    +
    !(a || !b)
    +

    !a && b

    +
    !(!a || !b)
    +

    a && b

    +
    !(!a && b)
    +

    a || !b

    +
    !(a && !b)
    +

    !a || b

    +
    !(!a && !b)
    +

    a || b

    +
    @@ -15599,8 +15736,22 @@ std::string_view b;

    ChainedConditionalAssignment

    If true, conditional boolean assignments at the end of an if/else if chain will be transformed. Default is false.

    +
    +

    SimplifyDeMorgan

    +

    If true, DeMorgan's Theorem will be applied to simplify negated conjunctions and disjunctions. Default is true.

    +
    +
    +

    SimplifyDeMorganRelaxed

    +

    If true, SimplifyDeMorgan will also transform negated conjunctions and disjunctions where there is no negation on either operand. This option has no effect if SimplifyDeMorgan is false. Default is false.

    +

    When Enabled:

    +
    bool X = !(A && B)
    +bool Y = !(A || B)
    +

    Would be transformed to:

    +
    bool X = !A || !B
    +bool Y = !A && !B
    +

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -15623,7 +15774,7 @@ char c = s.data()[i]; // char c = s[i];

    The list of type(s) that triggers this check. Default is ::std::basic_string;::std::basic_string_view;::std::vector;::std::array

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -15652,7 +15803,7 @@ c1->x; C::foo(); C::x;

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -15676,7 +15827,7 @@ C::x; }

    The check will apply a fix by removing the redundant static qualifier.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -15724,7 +15875,7 @@ if (str1.compare("foo") == 0) { }

    The above code examples show the list of if-statements that this check will give a warning for. All of them uses compare to check if equality or inequality of two strings instead of using the correct operators.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -15748,6 +15899,7 @@ if (str1.compare("foo") == 0) {

    Abbreviation

    Common abbreviations can be specified which will deem the strings similar if the abbreviated and the abbreviation stand together. For example, if src is registered as an abbreviation for source, then the following code example will be warned about.

    void foo(int source, int x);
    +
     foo(b, src);

    The abbreviations to recognise can be configured with the Abbreviations<opt_Abbreviations> check option. This heuristic is case-insensitive.

    Prefix

    @@ -15763,11 +15915,11 @@ foo(b, src);

    The Levenshtein distance describes how many single-character changes (additions, changes, or removals) must be applied to transform one string into another.

    The Levenshtein distance is translated into a similarity percentage by dividing it with the length of the longer string, and taking its complement with regards to 100%. For example, given something and anything, the distance is 4 edits, and the similarity percentage is 100% - 4 / 9 = 55.55...%.

    This heuristic can be configured with bounds<opt_Bounds>. The default bounds are: below 50% dissimilar and above 66% similar. This heuristic is case-sensitive.

    -

    Jaro-Winkler distance (as JaroWinkler)

    -

    The Jaro-Winkler distance is an edit distance like the Levenshtein distance. It is calculated from the amount of common characters that are sufficiently close to each other in position, and to-be-changed characters. The original definition of Jaro has been extended by Winkler to weigh prefix similarities more. The similarity percentage is expressed as an average of the common and non-common characters against the length of both strings.

    +

    Jaro--Winkler distance (as JaroWinkler)

    +

    The Jaro--Winkler distance is an edit distance like the Levenshtein distance. It is calculated from the amount of common characters that are sufficiently close to each other in position, and to-be-changed characters. The original definition of Jaro has been extended by Winkler to weigh prefix similarities more. The similarity percentage is expressed as an average of the common and non-common characters against the length of both strings.

    This heuristic can be configured with bounds<opt_Bounds>. The default bounds are: below 75% dissimilar and above 85% similar. This heuristic is case-insensitive.

    -

    Sorensen-Dice coefficient (as Dice)

    -

    The Sorensen-Dice coefficient was originally defined to measure the similarity of two sets. Formally, the coefficient is calculated by dividing 2 * #(intersection) with #(set1) + #(set2), where #() is the cardinality function of sets. This metric is applied to strings by creating bigrams (substring sequences of length 2) of the two strings and using the set of bigrams for the two strings as the two sets.

    +

    Sorensen--Dice coefficient (as Dice)

    +

    The Sorensen--Dice coefficient was originally defined to measure the similarity of two sets. Formally, the coefficient is calculated by dividing 2 * #(intersection) with #(set1) + #(set2), where #() is the cardinality function of sets. This metric is applied to strings by creating bigrams (substring sequences of length 2) of the two strings and using the set of bigrams for the two strings as the two sets.

    This heuristic can be configured with bounds<opt_Bounds>. The default bounds are: below 60% dissimilar and above 70% similar. This heuristic is case-insensitive.

    Options

    @@ -15843,7 +15995,7 @@ foo(b, src);

    Empty argument or parameter names are ignored by the heuristics.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -15877,7 +16029,7 @@ std::unique_ptr<int> P; P.reset();

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -15923,7 +16075,7 @@ auto x = 1U; // OK, suffix is uppercase.

    If this option is set to true (default is true), the check will not warn about literal suffixes inside macros.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -15948,7 +16100,7 @@ auto x = 1U; // OK, suffix is uppercase. // return std::ranges::all_of(V, [](int I) { return I % 2 == 0; }); }

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> INFO CODE_SMELL @@ -15989,13 +16141,777 @@ Derived(); // and so temporary construction is okay

    A semi-colon-separated list of fully-qualified names of C++ classes that should not be constructed as temporaries. Default is empty.

    References

    -

    clang.llvm.org

    ]]> +

    clang.llvm.org

    ]]> MAJOR BUG LINEAR 5min + + abseil-cleanup-ctad + abseil-cleanup-ctad + + +

    clang-tidy - abseil-cleanup-ctad

    + +

    abseil-cleanup-ctad

    +

    Suggests switching the initialization pattern of absl::Cleanup instances from the factory function to class template argument deduction (CTAD), in C++17 and higher.

    +
    auto c1 = absl::MakeCleanup([] {});
    +
    +const auto c2 = absl::MakeCleanup(std::function<void()>([] {}));
    +

    becomes

    +
    absl::Cleanup c1 = [] {};
    +
    +const absl::Cleanup c2 = std::function<void()>([] {});
    +

    References

    +

    clang.llvm.org

    ]]> + +
    + INFO + CODE_SMELL +
    + + bugprone-assignment-in-if-condition + bugprone-assignment-in-if-condition + + +

    clang-tidy - bugprone-assignment-in-if-condition

    + +

    bugprone-assignment-in-if-condition

    +

    Finds assignments within conditions of if statements. Such assignments are bug-prone because they may have been intended as equality tests.

    +

    This check finds all assignments within if conditions, including ones that are not flagged by -Wparentheses due to an extra set of parentheses, and including assignments that call an overloaded operator=(). The identified assignments violate BARR group "Rule 8.2.c".

    +
    int f = 3;
    +if(f = 4) { // This is identified by both `Wparentheses` and this check - should it have been: `if (f == 4)` ?
    +  f = f + 1;
    +}
    +
    +if((f == 5) || (f = 6)) { // the assignment here `(f = 6)` is identified by this check, but not by `-Wparentheses`. Should it have been `(f == 6)` ?
    +  f = f + 2;
    +}
    +

    References

    +

    clang.llvm.org

    ]]> + +
    + INFO + CODE_SMELL +
    + + bugprone-narrowing-conversions + bugprone-narrowing-conversions + + +

    clang-tidy - bugprone-narrowing-conversions

    + +
    + +
    +

    bugprone-narrowing-conversions

    +

    The bugprone-narrowing-conversions check is an alias, please see cppcoreguidelines-narrowing-conversions for more information.

    +

    References

    +

    clang.llvm.org

    ]]> + +
    + INFO + CODE_SMELL +
    + + bugprone-standalone-empty + bugprone-standalone-empty + + +

    clang-tidy - bugprone-standalone-empty

    + +

    bugprone-standalone-empty

    +

    Warns when empty() is used on a range and the result is ignored. Suggests clear() if it is an existing member function.

    +

    The empty() method on several common ranges returns a Boolean indicating whether or not the range is empty, but is often mistakenly interpreted as a way to clear the contents of a range. Some ranges offer a clear() method for this purpose. This check warns when a call to empty returns a result that is ignored, and suggests replacing it with a call to clear() if it is available as a member function of the range.

    +

    For example, the following code could be used to indicate whether a range is empty or not, but the result is ignored:

    +
    std::vector<int> v;
    +...
    +v.empty();
    +

    A call to clear() would appropriately clear the contents of the range:

    +
    std::vector<int> v;
    +...
    +v.clear();
    +

    References

    +

    clang.llvm.org

    ]]> + +
    + INFO + CODE_SMELL +
    + + bugprone-suspicious-realloc-usage + bugprone-suspicious-realloc-usage + + +

    clang-tidy - bugprone-suspicious-realloc-usage

    + +

    bugprone-suspicious-realloc-usage

    +

    This check finds usages of realloc where the return value is assigned to the same expression as passed to the first argument: p = realloc(p, size); The problem with this construct is that if realloc fails it returns a null pointer but does not deallocate the original memory. If no other variable is pointing to it, the original memory block is not available any more for the program to use or free. In either case p = realloc(p, size); indicates bad coding style and can be replaced by q = realloc(p, size);.

    +

    The pointer expression (used at realloc) can be a variable or a field member of a data structure, but can not contain function calls or unresolved types.

    +

    In obvious cases when the pointer used at realloc is assigned to another variable before the realloc call, no warning is emitted. This happens only if a simple expression in form of q = p or void *q = p is found in the same function where p = realloc(p, ...) is found. The assignment has to be before the call to realloc (but otherwise at any place) in the same function. This suppression works only if p is a single variable.

    +

    Examples:

    +
    struct A {
    +  void *p;
    +};
    +
    +A &getA();
    +
    +void foo(void *p, A *a, int new_size) {
    +  p = realloc(p, new_size); // warning: 'p' may be set to null if 'realloc' fails, which may result in a leak of the original buffer
    +  a->p = realloc(a->p, new_size); // warning: 'a->p' may be set to null if 'realloc' fails, which may result in a leak of the original buffer
    +  getA().p = realloc(getA().p, new_size); // no warning
    +}
    +
    +void foo1(void *p, int new_size) {
    +  void *p1 = p;
    +  p = realloc(p, new_size); // no warning
    +}
    +

    References

    +

    clang.llvm.org

    ]]> + +
    + INFO + CODE_SMELL +
    + + bugprone-unchecked-optional-access + bugprone-unchecked-optional-access + + +

    clang-tidy - bugprone-unchecked-optional-access

    + +

    bugprone-unchecked-optional-access

    +

    Note: This check uses a flow-sensitive static analysis to produce its results. Therefore, it may be more resource intensive (RAM, CPU) than the average clang-tidy check.

    +

    This check identifies unsafe accesses to values contained in std::optional<T>, absl::optional<T>, or base::Optional<T> objects. Below we will refer to all these types collectively as optional<T>.

    +

    An access to the value of an optional<T> occurs when one of its value, operator*, or operator-> member functions is invoked. To align with common misconceptions, the check considers these member functions as equivalent, even though there are subtle differences related to exceptions versus undefined behavior. See go/optional-style-recommendations for more information on that topic.

    +

    An access to the value of an optional<T> is considered safe if and only if code in the local scope (for example, a function body) ensures that the optional<T> has a value in all possible execution paths that can reach the access. That should happen either through an explicit check, using the optional<T>::has_value member function, or by constructing the optional<T> in a way that shows that it unambiguously holds a value (e.g using std::make_optional which always returns a populated std::optional<T>).

    +

    Below we list some examples, starting with unsafe optional access patterns, followed by safe access patterns.

    +

    Unsafe access patterns

    +

    Access the value without checking if it exists

    +

    The check flags accesses to the value that are not locally guarded by existence check:

    +
    void f(std::optional<int> opt) {
    +  use(*opt); // unsafe: it is unclear whether `opt` has a value.
    +}
    +

    Access the value in the wrong branch

    +

    The check is aware of the state of an optional object in different branches of the code. For example:

    +
    void f(std::optional<int> opt) {
    +  if (opt.has_value()) {
    +  } else {
    +    use(opt.value()); // unsafe: it is clear that `opt` does *not* have a value.
    +  }
    +}
    +

    Assume a function result to be stable

    +

    The check is aware that function results might not be stable. That is, consecutive calls to the same function might return different values. For example:

    +
    void f(Foo foo) {
    +  if (foo.opt().has_value()) {
    +    use(*foo.opt()); // unsafe: it is unclear whether `foo.opt()` has a value.
    +  }
    +}
    +

    Rely on invariants of uncommon APIs

    +

    The check is unaware of invariants of uncommon APIs. For example:

    +
    void f(Foo foo) {
    +  if (foo.HasProperty("bar")) {
    +    use(*foo.GetProperty("bar")); // unsafe: it is unclear whether `foo.GetProperty("bar")` has a value.
    +  }
    +}
    +

    Check if a value exists, then pass the optional to another function

    +

    The check relies on local reasoning. The check and value access must both happen in the same function. An access is considered unsafe even if the caller of the function performing the access ensures that the optional has a value. For example:

    +
    void g(std::optional<int> opt) {
    +  use(*opt); // unsafe: it is unclear whether `opt` has a value.
    +}
    +
    +void f(std::optional<int> opt) {
    +  if (opt.has_value()) {
    +    g(opt);
    +  }
    +}
    +

    Safe access patterns

    +

    Check if a value exists, then access the value

    +

    The check recognizes all straightforward ways for checking if a value exists and accessing the value contained in an optional object. For example:

    +
    void f(std::optional<int> opt) {
    +  if (opt.has_value()) {
    +    use(*opt);
    +  }
    +}
    +

    Check if a value exists, then access the value from a copy

    +

    The criteria that the check uses is semantic, not syntactic. It recognizes when a copy of the optional object being accessed is known to have a value. For example:

    +
    void f(std::optional<int> opt1) {
    +  if (opt1.has_value()) {
    +    std::optional<int> opt2 = opt1;
    +    use(*opt2);
    +  }
    +}
    +

    Ensure that a value exists using common macros

    +

    The check is aware of common macros like CHECK, DCHECK, and ASSERT_THAT. Those can be used to ensure that an optional object has a value. For example:

    +
    void f(std::optional<int> opt) {
    +  DCHECK(opt.has_value());
    +  use(*opt);
    +}
    +

    Ensure that a value exists, then access the value in a correlated branch

    +

    The check is aware of correlated branches in the code and can figure out when an optional object is ensured to have a value on all execution paths that lead to an access. For example:

    +
    void f(std::optional<int> opt) {
    +  bool safe = false;
    +  if (opt.has_value() && SomeOtherCondition()) {
    +    safe = true;
    +  }
    +  // ... more code...
    +  if (safe) {
    +    use(*opt);
    +  }
    +}
    +

    Stabilize function results

    +

    Since function results are not assumed to be stable across calls, it is best to store the result of the function call in a local variable and use that variable to access the value. For example:

    +
    void f(Foo foo) {
    +  if (const auto& foo_opt = foo.opt(); foo_opt.has_value()) {
    +    use(*foo_opt);
    +  }
    +}
    +

    Do not rely on uncommon-API invariants

    +

    When uncommon APIs guarantee that an optional has contents, do not rely on it --instead, check explicitly that the optional object has a value. For example:

    +
    void f(Foo foo) {
    +  if (const auto& property = foo.GetProperty("bar")) {
    +    use(*property);
    +  }
    +}
    +

    instead of the HasProperty, GetProperty pairing we saw above.

    +

    Do not rely on caller-performed checks

    +

    If you know that all of a function's callers have checked that an optional argument has a value, either change the function to take the value directly or check the optional again in the local scope of the callee. For example:

    +
    void g(int val) {
    +  use(val);
    +}
    +
    +void f(std::optional<int> opt) {
    +  if (opt.has_value()) {
    +    g(*opt);
    +  }
    +}
    +

    and

    +
    struct S {
    +  std::optional<int> opt;
    +  int x;
    +};
    +
    +void g(const S &s) {
    +  if (s.opt.has_value() && s.x > 10) {
    +    use(*s.opt);
    +}
    +
    +void f(S s) {
    +  if (s.opt.has_value()) {
    +    g(s);
    +  }
    +}
    +

    Additional notes

    +

    Aliases created via using declarations

    +

    The check is aware of aliases of optional types that are created via using declarations. For example:

    +
    using OptionalInt = std::optional<int>;
    +
    +void f(OptionalInt opt) {
    +  use(opt.value()); // unsafe: it is unclear whether `opt` has a value.
    +}
    +

    Lambdas

    +

    The check does not currently report unsafe optional accesses in lambdas. A future version will expand the scope to lambdas, following the rules outlined above. It is best to follow the same principles when using optionals in lambdas.

    +

    References

    +

    clang.llvm.org

    ]]> + +
    + INFO + CODE_SMELL +
    + + cert-msc54-cpp + cert-msc54-cpp + + +

    clang-tidy - cert-msc54-cpp

    + +
    + +
    +

    cert-msc54-cpp

    +

    The cert-msc54-cpp check is an alias, please see bugprone-signal-handler for more information.

    +

    References

    +

    clang.llvm.org

    ]]> + +
    + INFO + CODE_SMELL +
    + + cppcoreguidelines-avoid-const-or-ref-data-members + cppcoreguidelines-avoid-const-or-ref-data-members + + +

    clang-tidy - cppcoreguidelines-avoid-const-or-ref-data-members

    + +

    cppcoreguidelines-avoid-const-or-ref-data-members

    +

    This check warns when structs or classes have const-qualified or reference (lvalue or rvalue) data members. Having such members is rarely useful, and makes the class only copy-constructible but not copy-assignable.

    +

    Examples:

    +
    // Bad, const-qualified member
    +struct Const {
    +  const int x;
    +}
    +
    +// Good:
    +class Foo {
    + public:
    +  int get() const { return x; }
    + private:
    +  int x;
    +};
    +
    +// Bad, lvalue reference member
    +struct Ref {
    +  int& x;
    +};
    +
    +// Good:
    +struct Foo {
    +  int* x;
    +  std::unique_ptr<int> x;
    +  std::shared_ptr<int> x;
    +  gsl::not_null<int> x;
    +};
    +
    +// Bad, rvalue reference member
    +struct RefRef {
    +  int&& x;
    +};
    +

    The check implements rule C.12 of C++ Core Guidelines.

    +

    Further reading: Data members: Never const.

    +

    References

    +

    clang.llvm.org

    ]]> + +
    + INFO + CODE_SMELL +
    + + cppcoreguidelines-avoid-do-while + cppcoreguidelines-avoid-do-while + + +

    clang-tidy - cppcoreguidelines-avoid-do-while

    + +

    cppcoreguidelines-avoid-do-while

    +

    Warns when using do-while loops. They are less readable than plain while loops, since the termination condition is at the end and the condition is not checked prior to the first iteration. This can lead to subtle bugs.

    +

    The check implements rule ES.75 of C++ Core Guidelines.

    +

    Examples:

    +
    int x;
    +do {
    +    std::cin >> x;
    +    // ...
    +} while (x < 0);
    +

    Options

    +
    +

    IgnoreMacros

    +

    Ignore the check when analyzing macros. This is useful for safely defining function-like macros:

    +
    #define FOO_BAR(x) \
    +do { \
    +  foo(x); \
    +  bar(x); \
    +} while(0)
    +

    Defaults to false.

    +
    +

    References

    +

    clang.llvm.org

    ]]> + +
    + INFO + CODE_SMELL +
    + + cppcoreguidelines-macro-to-enum + cppcoreguidelines-macro-to-enum + + +

    clang-tidy - cppcoreguidelines-macro-to-enum

    + +
    + +
    +

    cppcoreguidelines-macro-to-enum

    +

    The cppcoreguidelines-macro-to-enum check is an alias, please see modernize-macro-to-enum <../modernize/macro-to-enum> for more information.

    +

    References

    +

    clang.llvm.org

    ]]> + +
    + INFO + CODE_SMELL +
    + + misc-confusable-identifiers + misc-confusable-identifiers + + +

    clang-tidy - misc-confusable-identifiers

    + +

    misc-confusable-identifiers

    +

    Warn about confusable identifiers, i.e. identifiers that are visually close to each other, but use different Unicode characters. This detects a potential attack described in CVE-2021-42574.

    +

    Example:

    +
    int fo; // Initial character is U+0066 (LATIN SMALL LETTER F).
    +int fo; // Initial character is U+1D41F (MATHEMATICAL BOLD SMALL F) not U+0066 (LATIN SMALL LETTER F).
    +

    References

    +

    clang.llvm.org

    ]]> + +
    + INFO + CODE_SMELL +
    + + misc-const-correctness + misc-const-correctness + + +

    clang-tidy - misc-const-correctness

    + +

    misc-const-correctness

    +

    This check implements detection of local variables which could be declared as const but are not. Declaring variables as const is required or recommended by many coding guidelines, such as: CppCoreGuidelines ES.25 and AUTOSAR C++14 Rule A7-1-1 (6.7.1 Specifiers).

    +

    Please note that this check's analysis is type-based only. Variables that are not modified but used to create a non-const handle that might escape the scope are not diagnosed as potential const.

    +
    // Declare a variable, which is not ``const`` ...
    +int i = 42;
    +// but use it as read-only. This means that `i` can be declared ``const``.
    +int result = i * i;       // Before transformation
    +int const result = i * i; // After transformation
    +

    The check can analyze values, pointers and references but not (yet) pointees:

    +
    // Normal values like built-ins or objects.
    +int potential_const_int = 42;       // Before transformation
    +int const potential_const_int = 42; // After transformation
    +int copy_of_value = potential_const_int;
    +
    +MyClass could_be_const;       // Before transformation
    +MyClass const could_be_const; // After transformation
    +could_be_const.const_qualified_method();
    +
    +// References can be declared const as well.
    +int &reference_value = potential_const_int;       // Before transformation
    +int const& reference_value = potential_const_int; // After transformation
    +int another_copy = reference_value;
    +
    +// The similar semantics of pointers are not (yet) analyzed.
    +int *pointer_variable = &potential_const_int; // _NO_ 'const int *pointer_variable' suggestion.
    +int last_copy = *pointer_variable;
    +

    The automatic code transformation is only applied to variables that are declared in single declarations. You may want to prepare your code base with readability-isolate-declaration first.

    +

    Note that there is the check cppcoreguidelines-avoid-non-const-global-variables to enforce const correctness on all globals.

    +

    Known Limitations

    +

    The check does not run on C code.

    +

    The check will not analyze templated variables or variables that are instantiation dependent. Different instantiations can result in different const correctness properties and in general it is not possible to find all instantiations of a template. The template might be used differently in an independent translation unit.

    +

    Pointees can not be analyzed for constness yet. The following code shows this limitation.

    +
    // Declare a variable that will not be modified.
    +int constant_value = 42;
    +
    +// Declare a pointer to that variable, that does not modify either, but misses 'const'.
    +// Could be 'const int *pointer_to_constant = &constant_value;'
    +int *pointer_to_constant = &constant_value;
    +
    +// Usage:
    +int result = 520 * 120 * (*pointer_to_constant);
    +

    This limitation affects the capability to add const to methods which is not possible, too.

    +

    Options

    +
    +

    AnalyzeValues (default = true)

    +

    Enable or disable the analysis of ordinary value variables, like int i = 42;

    +
    // Warning
    +int i = 42;
    +// No warning
    +int const i = 42;
    +
    +// Warning
    +int a[] = {42, 42, 42};
    +// No warning
    +int const a[] = {42, 42, 42};
    +
    +
    +

    AnalyzeReferences (default = true)

    +

    Enable or disable the analysis of reference variables, like int &ref = i;

    +
    int i = 42;
    +// Warning
    +int& ref = i;
    +// No warning
    +int const& ref = i;
    +
    +
    +

    WarnPointersAsValues (default = false)

    +

    This option enables the suggestion for const of the pointer itself. Pointer values have two possibilities to be const, the pointer and the value pointing to.

    +
    int value = 42;
    +
    +// Warning
    +const int * pointer_variable = &value;
    +// No warning
    +const int *const pointer_variable = &value;
    +
    +
    +

    TransformValues (default = true)

    +

    Provides fixit-hints for value types that automatically add const if its a single declaration.

    +
    // Before
    +int value = 42;
    +// After
    +int const value = 42;
    +
    +// Before
    +int a[] = {42, 42, 42};
    +// After
    +int const a[] = {42, 42, 42};
    +
    +// Result is modified later in its life-time. No diagnostic and fixit hint will be emitted.
    +int result = value * 3;
    +result -= 10;
    +
    +
    +

    TransformReferences (default = true)

    +

    Provides fixit-hints for reference types that automatically add const if its a single declaration.

    +
    // This variable could still be a constant. But because there is a non-const reference to
    +// it, it can not be transformed (yet).
    +int value = 42;
    +// The reference 'ref_value' is not modified and can be made 'const int &ref_value = value;'
    +// Before
    +int &ref_value = value;
    +// After
    +int const &ref_value = value;
    +
    +// Result is modified later in its life-time. No diagnostic and fixit hint will be emitted.
    +int result = ref_value * 3;
    +result -= 10;
    +
    +
    +

    TransformPointersAsValues (default = false)

    +

    Provides fixit-hints for pointers if their pointee is not changed. This does not analyze if the value-pointed-to is unchanged!

    +

    Requires 'WarnPointersAsValues' to be 'true'.

    +
    int value = 42;
    +
    +// Before
    +const int * pointer_variable = &value;
    +// After
    +const int *const pointer_variable = &value;
    +
    +// Before
    +const int * a[] = {&value, &value};
    +// After
    +const int *const a[] = {&value, &value};
    +
    +// Before
    +int *ptr_value = &value;
    +// After
    +int *const ptr_value = &value;
    +
    +int result = 100 * (*ptr_value); // Does not modify the pointer itself.
    +// This modification of the pointee is still allowed and not diagnosed.
    +*ptr_value = 0;
    +
    +// The following pointer may not become a 'int *const'.
    +int *changing_pointee = &value;
    +changing_pointee = &result;
    +
    +

    References

    +

    clang.llvm.org

    ]]> + +
    + INFO + CODE_SMELL +
    + + misc-use-anonymous-namespace + misc-use-anonymous-namespace + + +

    clang-tidy - misc-use-anonymous-namespace

    + +

    misc-use-anonymous-namespace

    +

    Finds instances of static functions or variables declared at global scope that could instead be moved into an anonymous namespace.

    +

    Anonymous namespaces are the "superior alternative" according to the C++ Standard. static was proposed for deprecation, but later un-deprecated to keep C compatibility [1]. static is an overloaded term with different meanings in different contexts, so it can create confusion.

    +

    The following uses of static will not be diagnosed:

    +
      +
    • Functions or variables in header files, since anonymous namespaces in headers is considered an antipattern. Allowed header file extensions can be configured via the HeaderFileExtensions option (see below).
    • +
    • const or constexpr variables, since they already have implicit internal linkage in C++.
    • +
    +

    Examples:

    +
    // Bad
    +static void foo();
    +static int x;
    +
    +// Good
    +namespace {
    +  void foo();
    +  int x;
    +} // namespace
    +

    Options

    +
    +

    HeaderFileExtensions

    +

    A semicolon-separated list of filename extensions of header files (the filename extensions should not include "." prefix). Default is ";h;hh;hpp;hxx". For extension-less header files, using an empty string or leaving an empty string between ";" if there are other filename extensions.

    +
    +

    [1] Undeprecating static

    +

    References

    +

    clang.llvm.org

    ]]> + +
    + INFO + CODE_SMELL +
    + + modernize-macro-to-enum + modernize-macro-to-enum + + +

    clang-tidy - modernize-macro-to-enum

    + +

    modernize-macro-to-enum

    +

    Replaces groups of adjacent macros with an unscoped anonymous enum. Using an unscoped anonymous enum ensures that everywhere the macro token was used previously, the enumerator name may be safely used.

    +

    This check can be used to enforce the C++ core guideline Enum.1: Prefer enumerations over macros, within the constraints outlined below.

    +

    Potential macros for replacement must meet the following constraints:

    +
      +
    • Macros must expand only to integral literal tokens or expressions of literal tokens. The expression may contain any of the unary operators -, +, ~ or !, any of the binary operators ,, -, +, *, /, %, &, |, ^, <, >, <=, >=, ==, !=, ||, &&, <<, >> or <=>, the ternary operator ?: and its GNU extension. Parenthesized expressions are also recognized. This recognizes most valid expressions. In particular, expressions with the sizeof operator are not recognized.
    • +
    • Macros must be defined on sequential source file lines, or with only comment lines in between macro definitions.
    • +
    • Macros must all be defined in the same source file.
    • +
    • Macros must not be defined within a conditional compilation block. (Conditional include guards are exempt from this constraint.)
    • +
    • Macros must not be defined adjacent to other preprocessor directives.
    • +
    • Macros must not be used in any conditional preprocessing directive.
    • +
    • Macros must not be used as arguments to other macros.
    • +
    • Macros must not be undefined.
    • +
    • Macros must be defined at the top-level, not inside any declaration or definition.
    • +
    +

    Each cluster of macros meeting the above constraints is presumed to be a set of values suitable for replacement by an anonymous enum. From there, a developer can give the anonymous enum a name and continue refactoring to a scoped enum if desired. Comments on the same line as a macro definition or between subsequent macro definitions are preserved in the output. No formatting is assumed in the provided replacements, although clang-tidy can optionally format all fixes.

    +
    +
    +

    Warning

    +
    +

    Initializing expressions are assumed to be valid initializers for an enum. C requires that enum values fit into an int, but this may not be the case for some accepted constant expressions. For instance 1 << 40 will not fit into an int when the size of an int is 32 bits.

    +
    +

    Examples:

    +
    #define RED   0xFF0000
    +#define GREEN 0x00FF00
    +#define BLUE  0x0000FF
    +
    +#define TM_NONE (-1) // No method selected.
    +#define TM_ONE 1    // Use tailored method one.
    +#define TM_TWO 2    // Use tailored method two.  Method two
    +                    // is preferable to method one.
    +#define TM_THREE 3  // Use tailored method three.
    +

    becomes

    +
    enum {
    +RED = 0xFF0000,
    +GREEN = 0x00FF00,
    +BLUE = 0x0000FF
    +};
    +
    +enum {
    +TM_NONE = (-1), // No method selected.
    +TM_ONE = 1,    // Use tailored method one.
    +TM_TWO = 2,    // Use tailored method two.  Method two
    +                    // is preferable to method one.
    +TM_THREE = 3  // Use tailored method three.
    +};
    +

    References

    +

    clang.llvm.org

    ]]> + +
    + INFO + CODE_SMELL +
    + + objc-nsdate-formatter + objc-nsdate-formatter + + +

    clang-tidy - objc-nsdate-formatter

    + +

    objc-nsdate-formatter

    +

    When NSDateFormatter is used to convert an NSDate type to a String type, the user can specify a custom format string. Certain format specifiers are undesirable despite being legal. See http://www.unicode.org/reports/tr35/tr35-dates.html#Date_Format_Patterns for all legal date patterns.

    +

    This checker reports as warnings the following string patterns in a date format specifier:

    +
      +
    1. yyyy + ww : Calendar year specified with week of a week year (unless YYYY is also specified). +
        +
      • Example 1: Input Date: 29 December 2014 ; Format String: yyyy-ww;
        +Output string: 2014-01 (Wrong because it's not the first week of 2014)
      • +
      • Example 2: Input Date: 29 December 2014 ; Format String: dd-MM-yyyy (ww-YYYY);
        +Output string: 29-12-2014 (01-2015) (This is correct)
      • +
    2. +
    3. F without ee/EE : Numeric day of week in a month without actual day. +
        +
      • Example: Input Date: 29 December 2014 ; Format String: F-MM;
        +Output string: 5-12 (Wrong because it reads as 5th ___ of Dec in English)
      • +
    4. +
    5. F without MM : Numeric day of week in a month without month. +
        +
      • Example: Input Date: 29 December 2014 ; Format String: F-EE
        +Output string: 5-Mon (Wrong because it reads as 5th Mon of ___ in English)
      • +
    6. +
    7. WW without MM : Week of the month without the month. +
        +
      • Example: Input Date: 29 December 2014 ; Format String: WW-yyyy
        +Output string: 05-2014 (Wrong because it reads as 5th Week of ___ in English)
      • +
    8. +
    9. YYYY + QQ : Week year specified with quarter of normal year (unless yyyy is also specified). +
        +
      • Example 1: Input Date: 29 December 2014 ; Format String: YYYY-QQ
        +Output string: 2015-04 (Wrong because it's not the 4th quarter of 2015)
      • +
      • Example 2: Input Date: 29 December 2014 ; Format String: ww-YYYY (QQ-yyyy)
        +Output string: 01-2015 (04-2014) (This is correct)
      • +
    10. +
    11. YYYY + MM : Week year specified with Month of a calendar year (unless yyyy is also specified). +
        +
      • Example 1: Input Date: 29 December 2014 ; Format String: YYYY-MM
        +Output string: 2015-12 (Wrong because it's not the 12th month of 2015)
      • +
      • Example 2: Input Date: 29 December 2014 ; Format String: ww-YYYY (MM-yyyy)
        +Output string: 01-2015 (12-2014) (This is correct)
      • +
    12. +
    13. YYYY + DD : Week year with day of a calendar year (unless yyyy is also specified). +
        +
      • Example 1: Input Date: 29 December 2014 ; Format String: YYYY-DD
        +Output string: 2015-363 (Wrong because it's not the 363rd day of 2015)
      • +
      • Example 2: Input Date: 29 December 2014 ; Format String: ww-YYYY (DD-yyyy)
        +Output string: 01-2015 (363-2014) (This is correct)
      • +
    14. +
    15. YYYY + WW : Week year with week of a calendar year (unless yyyy is also specified). +
        +
      • Example 1: Input Date: 29 December 2014 ; Format String: YYYY-WW
        +Output string: 2015-05 (Wrong because it's not the 5th week of 2015)
      • +
      • Example 2: Input Date: 29 December 2014 ; Format String: ww-YYYY (WW-MM-yyyy)
        +Output string: 01-2015 (05-12-2014) (This is correct)
      • +
    16. +
    17. YYYY + F : Week year with day of week in a calendar month (unless yyyy is also specified). +
        +
      • Example 1: Input Date: 29 December 2014 ; Format String: YYYY-ww-F-EE
        +Output string: 2015-01-5-Mon (Wrong because it's not the 5th Monday of January in 2015)
      • +
      • Example 2: Input Date: 29 December 2014 ; Format String: ww-YYYY (F-EE-MM-yyyy)
        +Output string: 01-2015 (5-Mon-12-2014) (This is correct)
      • +
    18. +
    +

    References

    +

    clang.llvm.org

    ]]> + +
    + INFO + CODE_SMELL +
    + + portability-std-allocator-const + portability-std-allocator-const + + +

    clang-tidy - portability-std-allocator-const

    + +

    portability-std-allocator-const

    +

    Report use of std::vector<const T> (and similar containers of const elements). These are not allowed in standard C++, and should usually be std::vector<T> instead."

    +

    Per C++ [allocator.requirements.general]: "T is any cv-unqualified object type", std::allocator<const T> is undefined. Many standard containers use std::allocator by default and therefore their const T instantiations are undefined.

    +

    libc++ defines std::allocator<const T> as an extension which will be removed in the future.

    +

    libstdc++ and MSVC do not support std::allocator<const T>:

    +
    // libstdc++ has a better diagnostic since https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48101
    +std::deque<const int> deque; // error: static assertion failed: std::deque must have a non-const, non-volatile value_type
    +std::set<const int> set; // error: static assertion failed: std::set must have a non-const, non-volatile value_type
    +std::vector<int* const> vector; // error: static assertion failed: std::vector must have a non-const, non-volatile value_type
    +
    +// MSVC
    +// error C2338: static_assert failed: 'The C++ Standard forbids containers of const elements because allocator<const T> is ill-formed.'
    +

    Code bases only compiled with libc++ may accrue such undefined usage. This check finds such code and prevents backsliding while clean-up is ongoing.

    +

    References

    +

    clang.llvm.org

    ]]> + +
    + INFO + CODE_SMELL +
    diff --git a/cxx-sensors/src/test/java/org/sonar/cxx/sensors/clangtidy/CxxClangTidyRuleRepositoryTest.java b/cxx-sensors/src/test/java/org/sonar/cxx/sensors/clangtidy/CxxClangTidyRuleRepositoryTest.java index 5ee2916113..2c8767f663 100644 --- a/cxx-sensors/src/test/java/org/sonar/cxx/sensors/clangtidy/CxxClangTidyRuleRepositoryTest.java +++ b/cxx-sensors/src/test/java/org/sonar/cxx/sensors/clangtidy/CxxClangTidyRuleRepositoryTest.java @@ -36,7 +36,7 @@ void createRulesTest() { def.define(context); RulesDefinition.Repository repo = context.repository(CxxClangTidyRuleRepository.KEY); - assertThat(repo.rules()).hasSize(1340); + assertThat(repo.rules()).hasSize(1355); } } diff --git a/cxx-sensors/src/tools/clangtidy_createrules.py b/cxx-sensors/src/tools/clangtidy_createrules.py index 216b4df649..f209b2e23d 100644 --- a/cxx-sensors/src/tools/clangtidy_createrules.py +++ b/cxx-sensors/src/tools/clangtidy_createrules.py @@ -30,7 +30,7 @@ SEVERITY_MAP = { - # last update: llvmorg-14-init-8123-ga875e6e1225a (git describe) + # last update: llvmorg-16-init-15404-g61be26154924 (git describe) # rule keys are in alphabetical order "abseil-no-namespace": {"type": "CODE_SMELL", "severity": "INFO"}, @@ -317,10 +317,11 @@ def rstfile_to_rule(path, fix_urls): filename_with_extension = os.path.basename(path) filename = os.path.splitext(filename_with_extension)[0] + containing_folder = os.path.basename(os.path.dirname(path)) - key = filename - name = filename - description = rstfile_to_description(path, filename, fix_urls) + key = containing_folder + '-' + filename + name = key + description = rstfile_to_description(path, containing_folder + '/' + filename, fix_urls) default_issue_type = "CODE_SMELL" default_issue_severity = "INFO" diff --git a/cxx-sensors/src/tools/generate_clangtidy_resources.cmd b/cxx-sensors/src/tools/generate_clangtidy_resources.cmd index 4c3439cb19..49dfcb60eb 100644 --- a/cxx-sensors/src/tools/generate_clangtidy_resources.cmd +++ b/cxx-sensors/src/tools/generate_clangtidy_resources.cmd @@ -43,7 +43,7 @@ REM GENERATION OF RULES FROM CLANG-TIDY DOCUMENTATION (RST FILES) ECHO [INFO] generate the new version of the rules file... "%PYTHON_DIR%python.exe" "%SCRIPT_DIR%clangtidy_createrules.py" rules "%LLVM_DIR%clang-tools-extra\docs\clang-tidy\checks" > "%SCRIPT_DIR%clangtidy_new.xml" ECHO [INFO] compare the new version with the old one, extend the old XML... -"%PYTHON_DIR%python.exe" "%SCRIPT_DIR%utils_createrules.py" comparerules "%SCRIPT_DIR%\..\main\resources\clangtidy.xml" "%SCRIPT_DIR%clangtidy_new.xml" > "%SCRIPT_DIR%clangtidy-comparison.md" +"%PYTHON_DIR%python.exe" "%SCRIPT_DIR%utils_createrules.py" comparerules "%SCRIPT_DIR%..\main\resources\clangtidy.xml" "%SCRIPT_DIR%clangtidy_new.xml" > "%SCRIPT_DIR%clangtidy-comparison.md" REM GENERATION OF RULES FROM CLANG DIAGNOSTICS ECHO [INFO] generate the list of diagnostics... @@ -53,7 +53,7 @@ POPD ECHO [INFO] generate the new version of the diagnostics file... "%PYTHON_DIR%python.exe" "%SCRIPT_DIR%clangtidy_createrules.py" diagnostics "%SCRIPT_DIR%diagnostic.json" > "%SCRIPT_DIR%diagnostic_new.xml" ECHO [INFO] compare the new version with the old one, extend the old XML... -"%PYTHON_DIR%python.exe" "%SCRIPT_DIR%utils_createrules.py" comparerules "%SCRIPT_DIR%\..\main\resources\clangtidy.xml" "%SCRIPT_DIR%diagnostic_new.xml" > "%SCRIPT_DIR%diagnostic-comparison.md" +"%PYTHON_DIR%python.exe" "%SCRIPT_DIR%utils_createrules.py" comparerules "%SCRIPT_DIR%..\main\resources\clangtidy.xml" "%SCRIPT_DIR%diagnostic_new.xml" > "%SCRIPT_DIR%diagnostic-comparison.md" REM exit GOTO END