|
24 | 24 | #include "swift/AST/TypeLoc.h"
|
25 | 25 | #include "swift/Basic/Statistic.h"
|
26 | 26 | #include "swift/Basic/Version.h"
|
| 27 | +#include "swift/Basic/WarningAsErrorRule.h" |
27 | 28 | #include "swift/Localization/LocalizationFormat.h"
|
28 | 29 | #include "llvm/ADT/BitVector.h"
|
29 | 30 | #include "llvm/ADT/StringRef.h"
|
@@ -839,8 +840,8 @@ namespace swift {
|
839 | 840 | /// Don't emit any remarks
|
840 | 841 | bool suppressRemarks = false;
|
841 | 842 |
|
842 |
| - /// Emit all warnings as errors |
843 |
| - bool warningsAsErrors = false; |
| 843 | + /// Treat these warnings as errors. Indicies here corespond to DiagID enum |
| 844 | + llvm::BitVector warningsAsErrors; |
844 | 845 |
|
845 | 846 | /// Whether a fatal error has occurred
|
846 | 847 | bool fatalErrorOccurred = false;
|
@@ -881,9 +882,22 @@ namespace swift {
|
881 | 882 | void setSuppressRemarks(bool val) { suppressRemarks = val; }
|
882 | 883 | bool getSuppressRemarks() const { return suppressRemarks; }
|
883 | 884 |
|
884 |
| - /// Whether to treat warnings as errors |
885 |
| - void setWarningsAsErrors(bool val) { warningsAsErrors = val; } |
886 |
| - bool getWarningsAsErrors() const { return warningsAsErrors; } |
| 885 | + /// Whether a warning should be upgraded to an error or not |
| 886 | + void setWarningAsErrorForDiagID(DiagID id, bool value) { |
| 887 | + warningsAsErrors[(unsigned)id] = value; |
| 888 | + } |
| 889 | + bool getWarningAsErrorForDiagID(DiagID id) { |
| 890 | + return warningsAsErrors[(unsigned)id]; |
| 891 | + } |
| 892 | + |
| 893 | + /// Whether all warnings should be upgraded to errors or not |
| 894 | + void setAllWarningsAsErrors(bool value) { |
| 895 | + if (value) { |
| 896 | + warningsAsErrors.set(); |
| 897 | + } else { |
| 898 | + warningsAsErrors.reset(); |
| 899 | + } |
| 900 | + } |
887 | 901 |
|
888 | 902 | void resetHadAnyError() {
|
889 | 903 | anyErrorOccurred = false;
|
@@ -1093,11 +1107,15 @@ namespace swift {
|
1093 | 1107 | return state.getSuppressRemarks();
|
1094 | 1108 | }
|
1095 | 1109 |
|
1096 |
| - /// Whether to treat warnings as errors |
1097 |
| - void setWarningsAsErrors(bool val) { state.setWarningsAsErrors(val); } |
1098 |
| - bool getWarningsAsErrors() const { |
1099 |
| - return state.getWarningsAsErrors(); |
1100 |
| - } |
| 1110 | + /// Apply rules specifing what warnings should or shouldn't be treated as |
| 1111 | + /// errors. For group rules the string is either a group name defined by |
| 1112 | + /// DiagnosticGroups.def or a string with format "_id:<diag_id>" where |
| 1113 | + /// <diag_id> is one of the diagnostic IDs listed in |
| 1114 | + /// include/swift/AST/Diagnostics*.def |
| 1115 | + /// Rules are applied in order they appear in the vector. |
| 1116 | + /// In case the vector contains rules affecting the same diagnostic ID |
| 1117 | + /// the last rule wins. |
| 1118 | + void setWarningsAsErrorsRules(const std::vector<WarningAsErrorRule> &rules); |
1101 | 1119 |
|
1102 | 1120 | /// Whether to print diagnostic names after their messages
|
1103 | 1121 | void setPrintDiagnosticNames(bool val) {
|
|
0 commit comments