Basic/Diagnostics: Move setDiagnosticMapping() to using DiagnosticMappingInfo

and eliminate setDiagnosticMappingInternal.

llvm-svn: 140763
This commit is contained in:
Daniel Dunbar
2011-09-29 01:34:47 +00:00
parent bc6de90a5f
commit 458edfa2b7
2 changed files with 7 additions and 12 deletions

View File

@@ -566,13 +566,6 @@ private:
/// \brief Report the delayed diagnostic. /// \brief Report the delayed diagnostic.
void ReportDelayed(); void ReportDelayed();
void setDiagnosticMappingInternal(unsigned DiagId, diag::Mapping Map,
DiagState *State,
bool isUser, bool isPragma) const {
State->setMappingInfo((diag::kind)DiagId, DiagnosticMappingInfo::MakeInfo(
Map, isUser, isPragma));
}
// This is private state used by DiagnosticBuilder. We put it here instead of // This is private state used by DiagnosticBuilder. We put it here instead of
// in DiagnosticBuilder in order to keep DiagnosticBuilder a small lightweight // in DiagnosticBuilder in order to keep DiagnosticBuilder a small lightweight
// object. This implementation choice means that we can only have one // object. This implementation choice means that we can only have one

View File

@@ -172,10 +172,12 @@ void DiagnosticsEngine::setDiagnosticMapping(diag::kind Diag, diag::Mapping Map,
bool isPragma = L.isValid(); bool isPragma = L.isValid();
FullSourceLoc Loc(L, *SourceMgr); FullSourceLoc Loc(L, *SourceMgr);
FullSourceLoc LastStateChangePos = DiagStatePoints.back().Loc; FullSourceLoc LastStateChangePos = DiagStatePoints.back().Loc;
DiagnosticMappingInfo MappingInfo = DiagnosticMappingInfo::MakeInfo(
Map, /*IsUser=*/true, isPragma);
// Common case; setting all the diagnostics of a group in one place. // Common case; setting all the diagnostics of a group in one place.
if (Loc.isInvalid() || Loc == LastStateChangePos) { if (Loc.isInvalid() || Loc == LastStateChangePos) {
setDiagnosticMappingInternal(Diag, Map, GetCurDiagState(), true, isPragma); GetCurDiagState()->setMappingInfo(Diag, MappingInfo);
return; return;
} }
@@ -188,7 +190,7 @@ void DiagnosticsEngine::setDiagnosticMapping(diag::kind Diag, diag::Mapping Map,
// the new state became active. // the new state became active.
DiagStates.push_back(*GetCurDiagState()); DiagStates.push_back(*GetCurDiagState());
PushDiagStatePoint(&DiagStates.back(), Loc); PushDiagStatePoint(&DiagStates.back(), Loc);
setDiagnosticMappingInternal(Diag, Map, GetCurDiagState(), true, isPragma); GetCurDiagState()->setMappingInfo(Diag, MappingInfo);
return; return;
} }
@@ -201,12 +203,12 @@ void DiagnosticsEngine::setDiagnosticMapping(diag::kind Diag, diag::Mapping Map,
// Update all diagnostic states that are active after the given location. // Update all diagnostic states that are active after the given location.
for (DiagStatePointsTy::iterator for (DiagStatePointsTy::iterator
I = Pos+1, E = DiagStatePoints.end(); I != E; ++I) { I = Pos+1, E = DiagStatePoints.end(); I != E; ++I) {
setDiagnosticMappingInternal(Diag, Map, I->State, true, isPragma); GetCurDiagState()->setMappingInfo(Diag, MappingInfo);
} }
// If the location corresponds to an existing point, just update its state. // If the location corresponds to an existing point, just update its state.
if (Pos->Loc == Loc) { if (Pos->Loc == Loc) {
setDiagnosticMappingInternal(Diag, Map, Pos->State, true, isPragma); GetCurDiagState()->setMappingInfo(Diag, MappingInfo);
return; return;
} }
@@ -215,7 +217,7 @@ void DiagnosticsEngine::setDiagnosticMapping(diag::kind Diag, diag::Mapping Map,
Pos->Loc.isBeforeInTranslationUnitThan(Loc); Pos->Loc.isBeforeInTranslationUnitThan(Loc);
DiagStates.push_back(*Pos->State); DiagStates.push_back(*Pos->State);
DiagState *NewState = &DiagStates.back(); DiagState *NewState = &DiagStates.back();
setDiagnosticMappingInternal(Diag, Map, NewState, true, isPragma); GetCurDiagState()->setMappingInfo(Diag, MappingInfo);
DiagStatePoints.insert(Pos+1, DiagStatePoint(NewState, DiagStatePoints.insert(Pos+1, DiagStatePoint(NewState,
FullSourceLoc(Loc, *SourceMgr))); FullSourceLoc(Loc, *SourceMgr)));
} }