summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/FixItRewriter.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-04-02 19:05:20 +0000
committerDouglas Gregor <dgregor@apple.com>2009-04-02 19:05:20 +0000
commit9c0d38a7a0babc23db7f4b8e4cf0c21f9daf0470 (patch)
tree99ca384424d7a645e73226ead689c4e17adad945 /clang/lib/Frontend/FixItRewriter.cpp
parent38a5c9650e6ba4011800572e80f2b1300ff5047a (diff)
downloadbcm5719-llvm-9c0d38a7a0babc23db7f4b8e4cf0c21f9daf0470.tar.gz
bcm5719-llvm-9c0d38a7a0babc23db7f4b8e4cf0c21f9daf0470.zip
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. llvm-svn: 68342
Diffstat (limited to 'clang/lib/Frontend/FixItRewriter.cpp')
-rw-r--r--clang/lib/Frontend/FixItRewriter.cpp39
1 files changed, 37 insertions, 2 deletions
diff --git a/clang/lib/Frontend/FixItRewriter.cpp b/clang/lib/Frontend/FixItRewriter.cpp
index 8883b91ab9e..6fde5dae75f 100644
--- a/clang/lib/Frontend/FixItRewriter.cpp
+++ b/clang/lib/Frontend/FixItRewriter.cpp
@@ -81,8 +81,43 @@ bool FixItRewriter::IncludeInDiagnosticCounts() const {
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.
OpenPOWER on IntegriCloud