[cfe-commits] r140768 - in /cfe/trunk: include/clang/Basic/DiagnosticIDs.h lib/Basic/Diagnostic.cpp lib/Basic/DiagnosticIDs.cpp
Daniel Dunbar
daniel at zuster.org
Wed Sep 28 18:52:06 PDT 2011
Author: ddunbar
Date: Wed Sep 28 20:52:06 2011
New Revision: 140768
URL: http://llvm.org/viewvc/llvm-project?rev=140768&view=rev
Log:
Basic/Diagnostics: Add three explicit bits to DiagnosticMappingInfo to track "no-warning-as-error", "no-error-as-fatal", and "show-in-system-header", and update DiagnosticsEngine::setDiagnosticGroup{WarningAsError,ErrorAsFatal} and GetDefaultDiagMappingInfo to set them appropriately.
- No actual functionality change for now, we still also use the diag::Mapping::{MAP_WARNING_NO_ERROR,MAP_ERROR_NO_FATAL,MAP_WARNING_SHOW_IN_SYSTEM_HEADER} for a little while longer.
Modified:
cfe/trunk/include/clang/Basic/DiagnosticIDs.h
cfe/trunk/lib/Basic/Diagnostic.cpp
cfe/trunk/lib/Basic/DiagnosticIDs.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticIDs.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticIDs.h?rev=140768&r1=140767&r2=140768&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticIDs.h (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticIDs.h Wed Sep 28 20:52:06 2011
@@ -83,11 +83,14 @@
unsigned Mapping : 3;
unsigned IsUser : 1;
unsigned IsPragma : 1;
+ unsigned HasShowInSystemHeader : 1;
+ unsigned HasNoWarningAsError : 1;
+ unsigned HasNoErrorAsFatal : 1;
public:
static DiagnosticMappingInfo MakeUnset() {
DiagnosticMappingInfo Result;
- Result.Mapping = Result.IsUser = Result.IsPragma = 0;
+ Result.Mapping = 0;
return Result;
}
@@ -97,14 +100,28 @@
Result.Mapping = Mapping;
Result.IsUser = IsUser;
Result.IsPragma = IsPragma;
+ Result.HasShowInSystemHeader = 0;
+ Result.HasNoWarningAsError = 0;
+ Result.HasNoErrorAsFatal = 0;
return Result;
}
+ bool isUnset() const { return Mapping == 0; }
+
diag::Mapping getMapping() const { return diag::Mapping(Mapping); }
+ void setMapping(diag::Mapping Value) { Mapping = Value; }
+
bool isUser() const { return IsUser; }
bool isPragma() const { return IsPragma; }
- bool isUnset() const { return Mapping == 0; }
+ bool hasShowInSystemHeader() const { return HasShowInSystemHeader; }
+ void setShowInSystemHeader(bool Value) { HasShowInSystemHeader = Value; }
+
+ bool hasNoWarningAsError() const { return HasNoWarningAsError; }
+ void setNoWarningAsError(bool Value) { HasNoWarningAsError = Value; }
+
+ bool hasNoErrorAsFatal() const { return HasNoErrorAsFatal; }
+ void setNoErrorAsFatal(bool Value) { HasNoErrorAsFatal = Value; }
};
/// \brief Used for handling and querying diagnostic IDs. Can be used and shared
Modified: cfe/trunk/lib/Basic/Diagnostic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Diagnostic.cpp?rev=140768&r1=140767&r2=140768&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Diagnostic.cpp (original)
+++ cfe/trunk/lib/Basic/Diagnostic.cpp Wed Sep 28 20:52:06 2011
@@ -239,14 +239,56 @@
bool DiagnosticsEngine::setDiagnosticGroupWarningAsError(StringRef Group,
bool Enabled) {
- diag::Mapping Map = Enabled ? diag::MAP_ERROR : diag::MAP_WARNING_NO_WERROR;
- return setDiagnosticGroupMapping(Group, Map);
+ // If we are enabling this feature, just set the diagnostic mappings to map to
+ // errors.
+ if (Enabled)
+ return setDiagnosticGroupMapping(Group, diag::MAP_ERROR);
+
+ // Otherwise, we want to set the diagnostic mapping's "no Werror" bit, and
+ // potentially downgrade anything already mapped to be a warning.
+
+ // Get the diagnostics in this group.
+ llvm::SmallVector<diag::kind, 8> GroupDiags;
+ if (Diags->getDiagnosticsInGroup(Group, GroupDiags))
+ return true;
+
+ // Perform the mapping change.
+ for (unsigned i = 0, e = GroupDiags.size(); i != e; ++i) {
+ DiagnosticMappingInfo &Info = GetCurDiagState()->getOrAddMappingInfo(
+ GroupDiags[i]);
+
+ Info.setMapping(diag::MAP_WARNING_NO_WERROR);
+ Info.setNoWarningAsError(true);
+ }
+
+ return false;
}
bool DiagnosticsEngine::setDiagnosticGroupErrorAsFatal(StringRef Group,
bool Enabled) {
- diag::Mapping Map = Enabled ? diag::MAP_FATAL : diag::MAP_ERROR_NO_WFATAL;
- return setDiagnosticGroupMapping(Group, Map);
+ // If we are enabling this feature, just set the diagnostic mappings to map to
+ // fatal errors.
+ if (Enabled)
+ return setDiagnosticGroupMapping(Group, diag::MAP_FATAL);
+
+ // Otherwise, we want to set the diagnostic mapping's "no Werror" bit, and
+ // potentially downgrade anything already mapped to be an error.
+
+ // Get the diagnostics in this group.
+ llvm::SmallVector<diag::kind, 8> GroupDiags;
+ if (Diags->getDiagnosticsInGroup(Group, GroupDiags))
+ return true;
+
+ // Perform the mapping change.
+ for (unsigned i = 0, e = GroupDiags.size(); i != e; ++i) {
+ DiagnosticMappingInfo &Info = GetCurDiagState()->getOrAddMappingInfo(
+ GroupDiags[i]);
+
+ Info.setMapping(diag::MAP_ERROR_NO_WFATAL);
+ Info.setNoErrorAsFatal(true);
+ }
+
+ return false;
}
void DiagnosticsEngine::Report(const StoredDiagnostic &storedDiag) {
Modified: cfe/trunk/lib/Basic/DiagnosticIDs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/DiagnosticIDs.cpp?rev=140768&r1=140767&r2=140768&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/DiagnosticIDs.cpp (original)
+++ cfe/trunk/lib/Basic/DiagnosticIDs.cpp Wed Sep 28 20:52:06 2011
@@ -184,26 +184,29 @@
return Found;
}
-static diag::Mapping GetDefaultDiagMapping(unsigned DiagID) {
- if (const StaticDiagInfoRec *Info = GetDiagInfo(DiagID)) {
- // Compute the effective mapping based on the extra bits.
- diag::Mapping Mapping = (diag::Mapping) Info->Mapping;
+static DiagnosticMappingInfo GetDefaultDiagMappingInfo(unsigned DiagID) {
+ DiagnosticMappingInfo Info = DiagnosticMappingInfo::MakeInfo(
+ diag::MAP_FATAL, /*IsUser=*/false, /*IsPragma=*/false);
+
+ if (const StaticDiagInfoRec *StaticInfo = GetDiagInfo(DiagID)) {
+ Info.setMapping((diag::Mapping) StaticInfo->Mapping);
- if (Info->WarnNoWerror) {
- assert(Mapping == diag::MAP_WARNING &&
+ if (StaticInfo->WarnNoWerror) {
+ assert(Info.getMapping() == diag::MAP_WARNING &&
"Unexpected mapping with no-Werror bit!");
- Mapping = diag::MAP_WARNING_NO_WERROR;
+ Info.setMapping(diag::MAP_WARNING_NO_WERROR);
+ Info.setNoWarningAsError(true);
}
- if (Info->WarnShowInSystemHeader) {
- assert(Mapping == diag::MAP_WARNING &&
+ if (StaticInfo->WarnShowInSystemHeader) {
+ assert(Info.getMapping() == diag::MAP_WARNING &&
"Unexpected mapping with show-in-system-header bit!");
- Mapping = diag::MAP_WARNING_SHOW_IN_SYSTEM_HEADER;
+ Info.setMapping(diag::MAP_WARNING_SHOW_IN_SYSTEM_HEADER);
+ Info.setShowInSystemHeader(true);
}
-
- return Mapping;
}
- return diag::MAP_FATAL;
+
+ return Info;
}
/// getWarningOptionForDiag - Return the lowest-level warning option that
@@ -247,8 +250,7 @@
// Initialize the entry if we added it.
if (Result.second) {
assert(Result.first->second.isUnset() && "unexpected unset entry");
- Result.first->second = DiagnosticMappingInfo::MakeInfo(
- GetDefaultDiagMapping(Diag), /*IsUser=*/false, /*IsPragma=*/false);
+ Result.first->second = GetDefaultDiagMappingInfo(Diag);
}
return Result.first->second;
@@ -474,7 +476,8 @@
getBuiltinDiagClass(DiagID) != CLASS_EXTENSION)
return false;
- EnabledByDefault = GetDefaultDiagMapping(DiagID) != diag::MAP_IGNORE;
+ EnabledByDefault =
+ GetDefaultDiagMappingInfo(DiagID).getMapping() != diag::MAP_IGNORE;
return true;
}
@@ -482,7 +485,7 @@
if (DiagID >= diag::DIAG_UPPER_LIMIT)
return false;
- return GetDefaultDiagMapping(DiagID) == diag::MAP_ERROR;
+ return GetDefaultDiagMappingInfo(DiagID).getMapping() == diag::MAP_ERROR;
}
/// getDescription - Given a diagnostic ID, return a description of the
More information about the cfe-commits
mailing list