summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/FrontendActions.cpp
diff options
context:
space:
mode:
authorBen Langmuir <blangmuir@apple.com>2014-04-29 00:36:53 +0000
committerBen Langmuir <blangmuir@apple.com>2014-04-29 00:36:53 +0000
commitbe84adbf1b7d2c7d30c524392151f7e14a82daff (patch)
treebba2a35725a23b1201a06381a091d88ab1bf5243 /clang/lib/Frontend/FrontendActions.cpp
parent72d57ab32e3ec8d59c40ee13344e3692139ca737 (diff)
downloadbcm5719-llvm-be84adbf1b7d2c7d30c524392151f7e14a82daff.tar.gz
bcm5719-llvm-be84adbf1b7d2c7d30c524392151f7e14a82daff.zip
Check -Werror options during module validation
This patch checks whether the diagnostic options that could lead to errors (principally -Werror) are consistent between when a module was built and when it is loaded. If there are new -Werror flags, then the module is rebuilt. In order to canonicalize the options we do this check at the level of the constructed DiagnosticsEngine, which contains the final set of diag to diagnostic level mappings. Currently we only rebuild with the new diagnostic options, but we intend to refine this in the future to include the union of the new and old flags, since we know the old ones did not cause errors. System modules are only rebuilt when -Wsystem-headers is enabled. One oddity is that unlike checking language options, we don’t perform this diagnostic option checking when loading from a precompiled header. The reason for this is that the compiler cannot rebuild the PCH, so anything that requires it to be rebuilt effectively leaks into the build system. And in this case, that would mean the build system understanding the complex relationship between diagnostic options and the underlying diagnostic mappings, which is unreasonable. Skipping the check is safe, because these options do not affect the generated AST. You simply won’t get new build errors due to changed -Werror options automatically, which is also true for non-module cases. llvm-svn: 207477
Diffstat (limited to 'clang/lib/Frontend/FrontendActions.cpp')
-rw-r--r--clang/lib/Frontend/FrontendActions.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/clang/lib/Frontend/FrontendActions.cpp b/clang/lib/Frontend/FrontendActions.cpp
index 3d65ae32c01..a8df7fd1cb8 100644
--- a/clang/lib/Frontend/FrontendActions.cpp
+++ b/clang/lib/Frontend/FrontendActions.cpp
@@ -459,6 +459,25 @@ namespace {
return false;
}
+ virtual bool
+ ReadDiagnosticOptions(IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts,
+ bool Complain) override {
+ Out.indent(2) << "Diagnostic options:\n";
+#define DIAGOPT(Name, Bits, Default) DUMP_BOOLEAN(DiagOpts->Name, #Name);
+#define ENUM_DIAGOPT(Name, Type, Bits, Default) \
+ Out.indent(4) << #Name << ": " << DiagOpts->get##Name() << "\n";
+#define VALUE_DIAGOPT(Name, Bits, Default) \
+ Out.indent(4) << #Name << ": " << DiagOpts->Name << "\n";
+#include "clang/Basic/DiagnosticOptions.def"
+
+ Out.indent(4) << "Warning options:\n";
+ for (const std::string &Warning : DiagOpts->Warnings) {
+ Out.indent(6) << "-W" << Warning << "\n";
+ }
+
+ return false;
+ }
+
bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts,
bool Complain) override {
Out.indent(2) << "Header search options:\n";
OpenPOWER on IntegriCloud