Author: ctopper
Date: Wed Nov 25 23:51:54 2015
New Revision: 254134

URL: http://llvm.org/viewvc/llvm-project?rev=254134&view=rev
Log:
[Diagnostics] Call setMapping on the correct diagnostic states in a few places. 
GetCurDiagState() was being used when it shouldn't be.

I spotted this by inspection in the for loop that wasn't using its iterator and 
was just acting on the current state repeatedly.

This appears to have been introduced as a copy and paste bug in r140763 over 4 
years ago.

I have no idea how to test this. I just went back to the original commit and 
tried to use the variables it was using before that.

Modified:
    cfe/trunk/lib/Basic/Diagnostic.cpp

Modified: cfe/trunk/lib/Basic/Diagnostic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Diagnostic.cpp?rev=254134&r1=254133&r2=254134&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Diagnostic.cpp (original)
+++ cfe/trunk/lib/Basic/Diagnostic.cpp Wed Nov 25 23:51:54 2015
@@ -226,12 +226,12 @@ void DiagnosticsEngine::setSeverity(diag
   // Update all diagnostic states that are active after the given location.
   for (DiagStatePointsTy::iterator
          I = Pos+1, E = DiagStatePoints.end(); I != E; ++I) {
-    GetCurDiagState()->setMapping(Diag, Mapping);
+    I->State->setMapping(Diag, Mapping);
   }
 
   // If the location corresponds to an existing point, just update its state.
   if (Pos->Loc == Loc) {
-    GetCurDiagState()->setMapping(Diag, Mapping);
+    Pos->State->setMapping(Diag, Mapping);
     return;
   }
 
@@ -240,7 +240,7 @@ void DiagnosticsEngine::setSeverity(diag
   assert(Pos->Loc.isBeforeInTranslationUnitThan(Loc));
   DiagStates.push_back(*Pos->State);
   DiagState *NewState = &DiagStates.back();
-  GetCurDiagState()->setMapping(Diag, Mapping);
+  NewState->setMapping(Diag, Mapping);
   DiagStatePoints.insert(Pos+1, DiagStatePoint(NewState,
                                                FullSourceLoc(Loc, 
*SourceMgr)));
 }


_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to