Add a new command-line option "-fixit-at=file:line:column" that only
applies fix-its to error messages that occur at that specific location
in the program. 



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68342 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Frontend/FixItRewriter.cpp b/lib/Frontend/FixItRewriter.cpp
index 8883b91..6fde5da 100644
--- a/lib/Frontend/FixItRewriter.cpp
+++ b/lib/Frontend/FixItRewriter.cpp
@@ -81,8 +81,43 @@
 
 void FixItRewriter::HandleDiagnostic(Diagnostic::Level DiagLevel,
                                      const DiagnosticInfo &Info) {
-  if (Client)
-    Client->HandleDiagnostic(DiagLevel, Info);
+  Client->HandleDiagnostic(DiagLevel, Info);
+
+  // Skip over any diagnostics that are ignored.
+  if (DiagLevel == Diagnostic::Ignored)
+    return;
+
+  if (!FixItLocations.empty()) {
+    // The user has specified the locations where we should perform
+    // the various fix-it modifications.
+
+    // If this diagnostic does not have any code modifications,
+    // completely ignore it, even if it's an error: fix-it locations
+    // are meant to perform specific fix-ups even in the presence of
+    // other errors.
+    if (Info.getNumCodeModificationHints() == 0)
+      return;
+
+    // See if the location of the error is one that matches what the
+    // user requested.
+    bool AcceptableLocation = false;
+    const FileEntry *File 
+      = Rewrite.getSourceMgr().getFileEntryForID(
+                                            Info.getLocation().getFileID());
+    unsigned Line = Info.getLocation().getSpellingLineNumber();
+    unsigned Column = Info.getLocation().getSpellingColumnNumber();
+    for (llvm::SmallVector<RequestedSourceLocation, 4>::iterator
+           Loc = FixItLocations.begin(), LocEnd = FixItLocations.end();
+         Loc != LocEnd; ++Loc) {
+      if (Loc->File == File && Loc->Line == Line && Loc->Column == Column) {
+        AcceptableLocation = true;
+        break;
+      }
+    }
+
+    if (!AcceptableLocation)
+      return;
+  }
 
   // Make sure that we can perform all of the modifications we
   // in this diagnostic.