Skip to content

clang-tidy prints warnings from certain macros from system headers #44873

@llvmbot

Description

@llvmbot
Bugzilla Link 45528
Version unspecified
OS All
Attachments Full working example of the issue
Reporter LLVM Bugzilla Contributor

Extended Description

According to documentation clang-tidy should not print warnings for headers included from system include directories unless --system-headers is specified. This seems to mostly work however I have discovered that warnings from certain macros in Catch2 header (https://github.com/catchorg/Catch2/blob/master/single_include/catch2/catch.hpp):

//main.cpp
#define CATCH_CONFIG_MAIN
#include <Catch2/catch.hpp>

TEST_CASE("") {
REQUIRE(true == true);
}

The command line either:

clang-tidy main.cpp -- -isystem ../include

Or using compilation database entry:

[
{
"directory": "/home/mv/clang-tidy-system/build",
"command": "/usr/bin/clang++-10 -isystem ../include -std=gnu++17 -o CMakeFiles/app.dir/main.cpp.o -c /home/mv/clang-tidy-system/main.cpp",
"file": "/home/mv/clang-tidy-system/main.cpp"
}
]

Specifically it comes from the macro REQUIRE:

~/clang-tidy-system/build$ clang-tidy-10 ../main.cpp
34285 warnings generated.
/home/mv/clang-tidy-system/main.cpp:5:5: warning: do not call c-style vararg functions [hicpp-vararg]
REQUIRE(true == true);
^
../include/Catch2/catch.hpp:17317:24: note: expanded from macro 'REQUIRE'
#define REQUIRE( ... ) INTERNAL_CATCH_TEST( "REQUIRE", Catch::ResultDisposition::Normal, VA_ARGS )
^
../include/Catch2/catch.hpp:2677:9: note: expanded from macro 'INTERNAL_CATCH_TEST'
CATCH_INTERNAL_IGNORE_BUT_WARN(VA_ARGS);
^
../include/Catch2/catch.hpp:154:55: note: expanded from macro 'CATCH_INTERNAL_IGNORE_BUT_WARN'

define CATCH_INTERNAL_IGNORE_BUT_WARN(...) (void)__builtin_constant_p(VA_ARGS) /* NOLINT(cppcoreguidelines-pro-type-vararg) */

                                                  ^

Suppressed 34291 warnings (34284 in non-user code, 7 NOLINT).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.

Attached is the complete example I am using to debug this including the Catch2 header.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions