If any Fix-Its attached to a diagnostic have invalid source locations
or source locations that refer into a macro instantiation, delete all
of the Fix-Its on that diagnostic.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124833 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Basic/DiagnosticIDs.cpp b/lib/Basic/DiagnosticIDs.cpp
index 8efeb68..8725e7f 100644
--- a/lib/Basic/DiagnosticIDs.cpp
+++ b/lib/Basic/DiagnosticIDs.cpp
@@ -560,6 +560,19 @@
       Diag.SetDelayedDiagnostic(diag::fatal_too_many_errors);
   }
 
+  // If we have any Fix-Its, make sure that all of the Fix-Its point into
+  // source locations that aren't macro instantiations. If any point into
+  // macro instantiations, remove all of the Fix-Its.
+  for (unsigned I = 0, N = Diag.NumFixItHints; I != N; ++I) {
+    const FixItHint &FixIt = Diag.FixItHints[I];
+    if (FixIt.RemoveRange.isInvalid() ||
+        FixIt.RemoveRange.getBegin().isMacroID() ||
+        FixIt.RemoveRange.getEnd().isMacroID()) {
+      Diag.NumFixItHints = 0;
+      break;
+    }    
+  }
+  
   // Finally, report it.
   Diag.Client->HandleDiagnostic((Diagnostic::Level)DiagLevel, Info);
   if (Diag.Client->IncludeInDiagnosticCounts()) {