aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-08-18 14:24:02 +0000
committerDouglas Gregor <dgregor@apple.com>2010-08-18 14:24:02 +0000
commit783c56f47745f719590b17afd7ed937bf2407b53 (patch)
tree143425eeda3a41f746d55761be44faaa98f0e97e /lib
parent6aa03e6dc72623f04af415527bf580ec189ab7f6 (diff)
Simplify FixItHint by eliminated the unnecessary InsertionLoc
location. Patch by Eelis van der Weegen! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111362 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Basic/Diagnostic.cpp10
-rw-r--r--lib/Frontend/TextDiagnosticPrinter.cpp4
-rw-r--r--lib/Rewrite/FixItRewriter.cpp12
3 files changed, 3 insertions, 23 deletions
diff --git a/lib/Basic/Diagnostic.cpp b/lib/Basic/Diagnostic.cpp
index d4c7aa9521..d8095f4f6d 100644
--- a/lib/Basic/Diagnostic.cpp
+++ b/lib/Basic/Diagnostic.cpp
@@ -1152,11 +1152,6 @@ void StoredDiagnostic::Serialize(llvm::raw_ostream &OS) const {
break;
}
- if (F->InsertionLoc.isValid() && F->InsertionLoc.isMacroID()) {
- NumFixIts = 0;
- break;
- }
-
++NumFixIts;
}
@@ -1166,7 +1161,6 @@ void StoredDiagnostic::Serialize(llvm::raw_ostream &OS) const {
WriteSourceLocation(OS, SM, F->RemoveRange.getBegin());
WriteSourceLocation(OS, SM, F->RemoveRange.getEnd());
WriteUnsigned(OS, F->RemoveRange.isTokenRange());
- WriteSourceLocation(OS, SM, F->InsertionLoc);
WriteString(OS, F->CodeToInsert);
}
}
@@ -1294,12 +1288,11 @@ StoredDiagnostic::Deserialize(FileManager &FM, SourceManager &SM,
if (ReadUnsigned(Memory, MemoryEnd, NumFixIts))
return Diag;
for (unsigned I = 0; I != NumFixIts; ++I) {
- SourceLocation RemoveBegin, RemoveEnd, InsertionLoc;
+ SourceLocation RemoveBegin, RemoveEnd;
unsigned InsertLen = 0, RemoveIsTokenRange;
if (ReadSourceLocation(FM, SM, Memory, MemoryEnd, RemoveBegin) ||
ReadSourceLocation(FM, SM, Memory, MemoryEnd, RemoveEnd) ||
ReadUnsigned(Memory, MemoryEnd, RemoveIsTokenRange) ||
- ReadSourceLocation(FM, SM, Memory, MemoryEnd, InsertionLoc) ||
ReadUnsigned(Memory, MemoryEnd, InsertLen) ||
Memory + InsertLen > MemoryEnd) {
Diag.FixIts.clear();
@@ -1309,7 +1302,6 @@ StoredDiagnostic::Deserialize(FileManager &FM, SourceManager &SM,
FixItHint Hint;
Hint.RemoveRange = CharSourceRange(SourceRange(RemoveBegin, RemoveEnd),
RemoveIsTokenRange);
- Hint.InsertionLoc = InsertionLoc;
Hint.CodeToInsert.assign(Memory, Memory + InsertLen);
Memory += InsertLen;
Diag.FixIts.push_back(Hint);
diff --git a/lib/Frontend/TextDiagnosticPrinter.cpp b/lib/Frontend/TextDiagnosticPrinter.cpp
index 1b5b7e2ea8..bc1b50475b 100644
--- a/lib/Frontend/TextDiagnosticPrinter.cpp
+++ b/lib/Frontend/TextDiagnosticPrinter.cpp
@@ -447,11 +447,11 @@ void TextDiagnosticPrinter::EmitCaretDiagnostic(SourceLocation Loc,
if (NumHints && DiagOpts->ShowFixits) {
for (const FixItHint *Hint = Hints, *LastHint = Hints + NumHints;
Hint != LastHint; ++Hint) {
- if (Hint->InsertionLoc.isValid()) {
+ if (!Hint->CodeToInsert.empty()) {
// We have an insertion hint. Determine whether the inserted
// code is on the same line as the caret.
std::pair<FileID, unsigned> HintLocInfo
- = SM.getDecomposedInstantiationLoc(Hint->InsertionLoc);
+ = SM.getDecomposedInstantiationLoc(Hint->RemoveRange.getBegin());
if (SM.getLineNumber(HintLocInfo.first, HintLocInfo.second) ==
SM.getLineNumber(FID, FileOffset)) {
// Insert the new code into the line just below the code
diff --git a/lib/Rewrite/FixItRewriter.cpp b/lib/Rewrite/FixItRewriter.cpp
index df7b60547a..3fdec07459 100644
--- a/lib/Rewrite/FixItRewriter.cpp
+++ b/lib/Rewrite/FixItRewriter.cpp
@@ -96,12 +96,6 @@ void FixItRewriter::HandleDiagnostic(Diagnostic::Level DiagLevel,
CanRewrite = false;
break;
}
-
- if (Hint.InsertionLoc.isValid() &&
- !Rewrite.isRewritable(Hint.InsertionLoc)) {
- CanRewrite = false;
- break;
- }
}
if (!CanRewrite) {
@@ -120,12 +114,6 @@ void FixItRewriter::HandleDiagnostic(Diagnostic::Level DiagLevel,
for (unsigned Idx = 0, Last = Info.getNumFixItHints();
Idx < Last; ++Idx) {
const FixItHint &Hint = Info.getFixItHint(Idx);
- if (!Hint.RemoveRange.isValid()) {
- // We're adding code.
- if (Rewrite.InsertTextBefore(Hint.InsertionLoc, Hint.CodeToInsert))
- Failed = true;
- continue;
- }
if (Hint.CodeToInsert.empty()) {
// We're removing code.