const tooling::Replacement &Placed = *Reps->begin();
auto Begin = StartOfFile.getLocWithOffset(Placed.getOffset());
- auto End = Begin.getLocWithOffset(Placed.getLength());
+ auto End = Begin.getLocWithOffset(std::max(0, (int)Placed.getLength() - 1));
PartialDiagnostic PD(DiagID, Ctx.getDiagAllocator());
PD << Context.getHeaderInfos().front().Header
- << FixItHint::CreateReplacement(SourceRange(Begin, End),
+ << FixItHint::CreateReplacement(CharSourceRange::getCharRange(Begin, End),
Placed.getReplacementText());
Correction.addExtraDiagnostic(std::move(PD));
}
// CHECK: FIX-IT: Replace [3:1 - 3:4] with "foo"
// CHECK: yamldb_plugin.cpp:3:1: note: Add '#include "foo.h"' to provide the missing declaration [clang-include-fixer]
// CHECK: Number FIX-ITs = 1
-// CHECK: FIX-IT: Replace [3:1 - 3:4] with "#include "foo.h"
+// CHECK: FIX-IT: Insert "#include "foo.h"
+// CHECK: " at 3:1
// CHECK: yamldb_plugin.cpp:4:1:
// CHECK: error: unknown type name 'unknown'
// CHECK: Number FIX-ITs = 0