DiagMap[Diag] = Info;
}
- DiagnosticMappingInfo getMappingInfo(diag::kind Diag) const {
- const_iterator I = DiagMap.find(Diag);
- if (I != DiagMap.end())
- return I->second;
- return DiagnosticMappingInfo::MakeUnset();
- }
-
DiagnosticMappingInfo &getOrAddMappingInfo(diag::kind Diag);
const_iterator begin() const { return DiagMap.begin(); }
bool setDiagnosticGroupMapping(StringRef Group, diag::Mapping Map,
SourceLocation Loc = SourceLocation());
- /// \brief Set the warning-as-error flag for the given diagnostic group.
+ /// \brief Set the warning-as-error flag for the given diagnostic group. This
+ /// function always only operates on the current diagnostic state.
///
/// \returns True if the given group is unknown, false otherwise.
bool setDiagnosticGroupWarningAsError(StringRef Group, bool Enabled);
- /// \brief Set the error-as-fatal flag for the given diagnostic group.
+ /// \brief Set the error-as-fatal flag for the given diagnostic group. This
+ /// function always only operates on the current diagnostic state.
///
/// \returns True if the given group is unknown, false otherwise.
bool setDiagnosticGroupErrorAsFatal(StringRef Group, bool Enabled);
unsigned HasNoErrorAsFatal : 1;
public:
- static DiagnosticMappingInfo MakeUnset() {
- DiagnosticMappingInfo Result;
- Result.Mapping = 0;
- return Result;
- }
-
- static DiagnosticMappingInfo MakeInfo(diag::Mapping Mapping,
- bool IsUser, bool IsPragma) {
+ static DiagnosticMappingInfo Make(diag::Mapping Mapping, bool IsUser,
+ bool IsPragma) {
DiagnosticMappingInfo Result;
Result.Mapping = Mapping;
Result.IsUser = IsUser;
return Result;
}
- bool isUnset() const { return Mapping == 0; }
-
diag::Mapping getMapping() const { return diag::Mapping(Mapping); }
void setMapping(diag::Mapping Value) { Mapping = Value; }
bool isPragma = L.isValid();
FullSourceLoc Loc(L, *SourceMgr);
FullSourceLoc LastStateChangePos = DiagStatePoints.back().Loc;
- DiagnosticMappingInfo MappingInfo = DiagnosticMappingInfo::MakeInfo(
+ DiagnosticMappingInfo MappingInfo = DiagnosticMappingInfo::Make(
Map, /*IsUser=*/true, isPragma);
// Common case; setting all the diagnostics of a group in one place.
}
static DiagnosticMappingInfo GetDefaultDiagMappingInfo(unsigned DiagID) {
- DiagnosticMappingInfo Info = DiagnosticMappingInfo::MakeInfo(
+ DiagnosticMappingInfo Info = DiagnosticMappingInfo::Make(
diag::MAP_FATAL, /*IsUser=*/false, /*IsPragma=*/false);
if (const StaticDiagInfoRec *StaticInfo = GetDiagInfo(DiagID)) {
diag::kind Diag)
{
std::pair<iterator, bool> Result = DiagMap.insert(
- std::make_pair(Diag, DiagnosticMappingInfo::MakeUnset()));
+ std::make_pair(Diag, DiagnosticMappingInfo()));
// Initialize the entry if we added it.
- if (Result.second) {
- assert(Result.first->second.isUnset() && "unexpected unset entry");
+ if (Result.second)
Result.first->second = GetDefaultDiagMappingInfo(Diag);
- }
return Result.first->second;
}
Result = DiagnosticIDs::Fatal;
}
- // If we are in a system header, we ignore it.
- // We also want to ignore extensions and warnings in -Werror and
+ // If we are in a system header, we ignore it. We look at the diagnostic class
+ // because we also want to ignore extensions and warnings in -Werror and
// -pedantic-errors modes, which *map* warnings/extensions to errors.
if (Result >= DiagnosticIDs::Warning &&
DiagClass != CLASS_ERROR &&