forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 1
Silencing Diagnostics
June Rhodes edited this page Aug 2, 2024
·
2 revisions
You can change the severity of diagnostics or silence diagnostics using #pragma
directives.
To silence rule diagnostics, use the fully qualified name of the rule (both the namespace and the rule name).
#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunknown-warning-option"
#pragma clang diagnostic ignored "-Wnamespace/rule"
#pragma clang diagnostic ignored "-Wnamespace/rule2"
#pragma clang diagnostic ignored "-Wnamespace/rule3"
#endif
// ...
#if defined(__clang__)
#pragma clang diagnostic pop
#endif
You can use ignored
on rules that are configured for Error
severity in the .clang-rules
configuration files, but you can't reduce an Error
severity down to a warning with a #pragma
directive due to limitations inside Clang's diagnostic system.
Refer to Include-What-You-Use Analyser on how to silence warnings from include-what-you-use analysis.