Fix horrible regression in control of warnings caused by introduction of -Wpedantic.
While -Wpedantic was reasonable, -Wno-pedantic would turn off a bunch of warnings that
are on by default. This counters the intention of this warning flag.
To fix this, -Wpedantic now includes extentions that are not on by default. The
remaining warnings will manifest anyway, and won't accidentally get turned off
by -Wno-pedantic.
Fixes <rdar://problem/12076105>
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161695 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/utils/TableGen/ClangDiagnosticsEmitter.cpp b/utils/TableGen/ClangDiagnosticsEmitter.cpp
index 8e7f454..8615d2d 100644
--- a/utils/TableGen/ClangDiagnosticsEmitter.cpp
+++ b/utils/TableGen/ClangDiagnosticsEmitter.cpp
@@ -204,6 +204,9 @@
/// Determine if the diagnostic is an extension.
bool isExtension(const Record *Diag);
+ /// Determine if the diagnostic is off by default.
+ bool isOffByDefault(const Record *Diag);
+
/// Increment the count for a group, and transitively marked
/// parent groups when appropriate.
void markGroup(const Record *Group);
@@ -234,6 +237,11 @@
return ClsName == "CLASS_EXTENSION";
}
+bool InferPedantic::isOffByDefault(const Record *Diag) {
+ const std::string &DefMap = Diag->getValueAsDef("DefaultMapping")->getName();
+ return DefMap == "MAP_IGNORE";
+}
+
bool InferPedantic::groupInPedantic(const Record *Group, bool increment) {
GMap::mapped_type &V = GroupCount[Group];
// Lazily compute the threshold value for the group count.
@@ -265,12 +273,12 @@
void InferPedantic::compute(VecOrSet DiagsInPedantic,
VecOrSet GroupsInPedantic) {
- // All extensions are implicitly in the "pedantic" group. For those that
- // aren't explicitly included in -Wpedantic, mark them for consideration
- // to be included in -Wpedantic directly.
+ // All extensions that are not on by default are implicitly in the
+ // "pedantic" group. For those that aren't explicitly included in -Wpedantic,
+ // mark them for consideration to be included in -Wpedantic directly.
for (unsigned i = 0, e = Diags.size(); i != e; ++i) {
Record *R = Diags[i];
- if (isExtension(R)) {
+ if (isExtension(R) && isOffByDefault(R)) {
DiagsSet.insert(R);
if (DefInit *Group = dynamic_cast<DefInit*>(R->getValueInit("Group"))) {
const Record *GroupRec = Group->getDef();