We're using clang with -fmodule
and -fcxx-module
to enable module support as documented at http://clang.llvm.org/docs/Modules.html. We're already seeing a significant improvement in build times by defining module maps for our core libraries.
However, we have some library headers that use pragmas to disable warnings for certain lines, for example:
template <typename TFloat>
static bool exactlyEqual(TFloat lhs, TFloat rhs)
{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wfloat-equal"
return lhs == rhs;
#pragma clang diagnostic pop
}
When this header is pulled in as a precompiled module, it seems clang's internal representation does not preserve the pragma information and the warning is still emitted. Since we treat warnings as errors this causes compilation to fail. Some might argue to just disable float-equal
entirely, but we have a bunch of other cases with different warnings which we don't want to globally disable.
We're already using -Wno-system-headers
and -isystem
so that clients of libraries generally don't see warnings like this anyway (even without the pragma), but this doesn't seem to work when the header is imported as a module. In addition we still hit these warnings for code internal to the library which includes the header as a non-system header (i.e. without using -isystem
/ using double quotes), since module precompilation and importing also occurs here.
I've tried using _Pragma(...)
instead of #pragma
which didn't have any effect.
Is there some other way to conditionally ignore warnings in headers that come from precompiled clang modules?
UPDATE: I've put a sample project up on https://github.com/MikeWeller/ClangModuleWarnings which reproduces the problem
UPDATE: Seems the [system]
module attribute will suppress all warnings. However this suppresses even warnings we want to see when building the library itself, and we don't want to make all our modules system modules. If we find a way to not use the library's module map when building the library itself this may be acceptable but we'd still like to pragma out certain warnings for non-system modules..