I want to remove/ignore a clang warning for a block of code and found multiple examples of how to use pragamas for this. For example if the warning is unused-variable
you can disable it by using:
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-variable"
int a;
#pragma clang diagnostic pop
However the problem is that I do not get a warning in the output when building the repository, I only get to know which clang check it is that gives the warning... And I can not find any other questions or documentations where this is the case. This is what my output looks:
warning: Use of memory after it is freed [clang-analyzer-cplusplus.NewDelete]
I have tried hundreds of different combinations of how to ignore this but nothing works (using // NOLINT
is not a viable option). Among the things that i have tried, here are some:
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winline-new-delete"
#pragma clang diagnostic ignored "-Wmost"
#pragma clang diagnostic ignored "-Weverything"
#pragma clang diagnostic ignored "clang-analyzer-cplusplus.NewDelete"
#pragma clang diagnostic ignored "-Wclang-analyzer-cplusplus.NewDelete"
#pragma clang diagnostic ignored "-clang-analyzer-cplusplus.NewDelete"
#pragma clang diagnostic ignored "-W-NewDelete"
#pragma clang diagnostic ignored "-W-new-delete"
// code
#pragma clang diagnostic pop
Note, "fixing" the code is also not an option since it is third party code.