summaryrefslogtreecommitdiff
path: root/include/clang/Basic/Diagnostic.h
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
commita172a34fb1b047c946366af60eb7e5da2ac32f4c (patch)
treee5793206f7e597320644db27a4cba038a9a10c97 /include/clang/Basic/Diagnostic.h
parent5324f83f54c4bc4d24b2408659cb9e09a238ee2f (diff)
downloadclang-a172a34fb1b047c946366af60eb7e5da2ac32f4c.tar.gz
clang-a172a34fb1b047c946366af60eb7e5da2ac32f4c.tar.bz2
clang-a172a34fb1b047c946366af60eb7e5da2ac32f4c.tar.xz
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@207477 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Basic/Diagnostic.h')
-rw-r--r--include/clang/Basic/Diagnostic.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/include/clang/Basic/Diagnostic.h b/include/clang/Basic/Diagnostic.h
index f7f84440a5..76b2eac9b5 100644
--- a/include/clang/Basic/Diagnostic.h
+++ b/include/clang/Basic/Diagnostic.h
@@ -21,6 +21,7 @@
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/ADT/iterator_range.h"
#include <list>
#include <vector>
@@ -364,6 +365,14 @@ public:
/// \brief Retrieve the diagnostic options.
DiagnosticOptions &getDiagnosticOptions() const { return *DiagOpts; }
+ typedef llvm::iterator_range<DiagState::const_iterator> diag_mapping_range;
+
+ /// \brief Get the current set of diagnostic mappings.
+ diag_mapping_range getDiagnosticMappings() const {
+ const DiagState &DS = *GetCurDiagState();
+ return diag_mapping_range(DS.begin(), DS.end());
+ }
+
DiagnosticConsumer *getClient() { return Client; }
const DiagnosticConsumer *getClient() const { return Client; }