]> granicus.if.org Git - clang/commit
Serialization: Simulate -Werror settings in implicit modules
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Wed, 12 Apr 2017 03:58:58 +0000 (03:58 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Wed, 12 Apr 2017 03:58:58 +0000 (03:58 +0000)
commitd3992c554d9bb6e1114ef15bb046290dbfb9c0a1
treebcfa5775bb914052bece749c6d2d8edfd7c6c46a
parent91f051ff9b155afaf2eedfb2f66050af526d7bf5
Serialization: Simulate -Werror settings in implicit modules

r293123 started serializing diagnostic pragma state for modules.  This
makes the serialization work properly for implicit modules.

An implicit module build (using Clang's internal build system) uses the
same PCM file location for different `-Werror` levels.

E.g., if a TU has `-Werror=format` and tries to load a PCM built without
`-Werror=format`, a new PCM will be built in its place (and the new PCM
should have the same signature, since r297655).  In the other direction,
if a TU does not have `-Werror=format` and tries to load a PCM built
with `-Werror=format`, it should "just work".

The idea is to evolve the PCM toward the strictest -Werror flags that
anyone tries.

r293123 started serializing the diagnostic pragma state for each PCM.
Since this encodes the -Werror settings at module-build time, it breaks
the implicit build model.

This commit filters the diagnostic state in order to simulate the
current compilation's diagnostic settings.  Firstly, it ignores the
module's serialized first diagnostic state, replacing it with the state
from this compilation's command-line.  Secondly, if a pragma warning was
upgraded to error/fatal when generating the PCM (e.g., due to `-Werror`
on the command-line), it checks whether it should still be upgraded in
its current context.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@300025 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/Basic/Diagnostic.h
include/clang/Basic/DiagnosticIDs.h
lib/Basic/Diagnostic.cpp
lib/Serialization/ASTReader.cpp
lib/Serialization/ASTWriter.cpp
test/Modules/Inputs/implicit-built-Werror-using-W/convert.h [new file with mode: 0644]
test/Modules/Inputs/implicit-built-Werror-using-W/module.modulemap [new file with mode: 0644]
test/Modules/implicit-built-Werror-using-W.cpp [new file with mode: 0644]