Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warnings reported by clang-tidy due to use of var_arg #1921

Closed
avitase opened this issue May 1, 2020 · 11 comments
Closed

Warnings reported by clang-tidy due to use of var_arg #1921

avitase opened this issue May 1, 2020 · 11 comments

Comments

@avitase
Copy link

avitase commented May 1, 2020

Description
Using REQUIRE triggers clang-tidy to warn about the usage of var_arg. Using NOLINT at each and every call to REQUIRE resolves this issue but is very tedious... Maybe there is way to avoid the usage of var_arg (as suggested by core guidelines F.55) or maybe add NOLINT to the definition of the macro?

@horenmar
Copy link
Member

horenmar commented May 2, 2020

Which version are you using?

@avitase
Copy link
Author

avitase commented May 2, 2020

catch2/2.11.0 via conan

@horenmar
Copy link
Member

horenmar commented May 2, 2020

That's quite a bit behind. Have you tried updating?

@avitase
Copy link
Author

avitase commented May 2, 2020

sorry, my mistake. I mixed up the versions. The "error" occurs since catch2/2.11.3 (i.e. including catch2/2.12.1). Version catch2/2.11.1 is the last that is not "affected". (2.11.2 is not available via conan.)

@horenmar
Copy link
Member

horenmar commented May 4, 2020

Interesting, that warning should already be suppressed since v2.12.0. Can you check why the NOLINT is not obeyed in your configuration?

@avitase
Copy link
Author

avitase commented May 4, 2020

I am not quite sure how. But maybe this error log helps? This is from version catch2/2.12.0 but it is the very same for catch2/2.12.1 (including the line numbers). You are right, obviously there is the /* NOLINT(cppcoreguidelines-pro-type-vararg) */ comment and I don't know why it is skipped. I cannot test it right now, but just two things that pop up to my mind: I always use NOLINT with // instead of a /* ... */ or maybe this issue is related to my old clang-tidy version 7.0.1 ...

[...] tests.cpp:10:3: error: do not call c-style vararg functions [hicpp-vararg,-warnings-as-errors]
  REQUIRE(Factorial(1) == 1);
  ^
[...] catch2/catch.hpp:17394:24: note: expanded from macro 'REQUIRE'
#define REQUIRE( ... ) INTERNAL_CATCH_TEST( "REQUIRE", Catch::ResultDisposition::Normal, __VA_ARGS__  )
                       ^
[...] catch2/catch.hpp:2698:9: note: expanded from macro 'INTERNAL_CATCH_TEST'
        CATCH_INTERNAL_IGNORE_BUT_WARN(__VA_ARGS__); \
        ^
[...] catch2/catch.hpp:166: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) */
                                                      ^

@horenmar
Copy link
Member

horenmar commented May 4, 2020

@moha-gh Hey, can you confirm what clang-tidy version are you running?

@moha-gh
Copy link
Contributor

moha-gh commented May 5, 2020

@horenmar: We are using v9. I think the issue here is that for @avitase hicpp-vararg triggers, while the NOLINT is limited to cppcoreguidelines-pro-type-vararg. However, the hicpp warning is an alias for the cppcoreguidelines one. clang-tidy doesn't seem to take this into account when processing the NOLINT - even on v9: If I also enable hicpp-vararg in our config, I get the same warning locally. So I guess the solution would be to either extend the existing NOLINT

/* NOLINT(cppcoreguidelines-pro-type-vararg, hicpp-vararg) */

(works for me and my preference) or make it suppress every finding:

/* NOLINT */

@horenmar
Copy link
Member

horenmar commented May 7, 2020

Ok, I will suppress the warning in both variants, and open up an issue with clang-tidy upstream.

@avitase
Copy link
Author

avitase commented May 7, 2020

thanks for your help

@avitase avitase closed this as completed May 7, 2020
horenmar added a commit that referenced this issue May 9, 2020
Ideally, clang-tidy would be smart that if one alias of a warning
is suppressed, then the other one is suppressed as well, but as of
right now, it isn't. This means that for now we have to suppress
both aliases of this warning. Opened upstream issue to fix this:
https://bugs.llvm.org/show_bug.cgi?id=45859

Obviously, ideally clang-tidy would also not warn that we are calling
a vararg function when it is an unevaluated magic builtin, but that
also is not happening right now and I opened an issue for it:
https://bugs.llvm.org/show_bug.cgi?id=45860

Closes #1921
@horenmar
Copy link
Member

horenmar commented May 9, 2020

Okay, this is now fixed in master.

I also opened two bugs in clang-tidy's bugzilla,

nitnelave pushed a commit to nitnelave/Catch2 that referenced this issue May 25, 2020
Ideally, clang-tidy would be smart that if one alias of a warning
is suppressed, then the other one is suppressed as well, but as of
right now, it isn't. This means that for now we have to suppress
both aliases of this warning. Opened upstream issue to fix this:
https://bugs.llvm.org/show_bug.cgi?id=45859

Obviously, ideally clang-tidy would also not warn that we are calling
a vararg function when it is an unevaluated magic builtin, but that
also is not happening right now and I opened an issue for it:
https://bugs.llvm.org/show_bug.cgi?id=45860

Closes catchorg#1921
cenit pushed a commit to physycom/Catch that referenced this issue Aug 8, 2020
Ideally, clang-tidy would be smart that if one alias of a warning
is suppressed, then the other one is suppressed as well, but as of
right now, it isn't. This means that for now we have to suppress
both aliases of this warning. Opened upstream issue to fix this:
https://bugs.llvm.org/show_bug.cgi?id=45859

Obviously, ideally clang-tidy would also not warn that we are calling
a vararg function when it is an unevaluated magic builtin, but that
also is not happening right now and I opened an issue for it:
https://bugs.llvm.org/show_bug.cgi?id=45860

Closes catchorg#1921
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants