Skip to content

Commit 9b11da9

Browse files
committedSep 6, 2018
Fix reported range of partial token replacement
Summary: Fixes bug: 38678 Reviewers: klimek, rsmith Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D51192 llvm-svn: 341583
1 parent ec6b705 commit 9b11da9

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed
 

‎clang-tools-extra/clang-tidy/ClangTidy.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,6 @@ class ErrorReporter {
122122
<< Message.Message << Name;
123123
for (const auto &FileAndReplacements : Error.Fix) {
124124
for (const auto &Repl : FileAndReplacements.second) {
125-
// Retrieve the source range for applicable fixes. Macro definitions
126-
// on the command line have locations in a virtual buffer and don't
127-
// have valid file paths and are therefore not applicable.
128-
SourceRange Range;
129125
SourceLocation FixLoc;
130126
++TotalFixes;
131127
bool CanBeApplied = false;
@@ -166,7 +162,11 @@ class ErrorReporter {
166162
FixLoc = getLocation(FixAbsoluteFilePath, Repl.getOffset());
167163
SourceLocation FixEndLoc =
168164
FixLoc.getLocWithOffset(Repl.getLength());
169-
Range = SourceRange(FixLoc, FixEndLoc);
165+
// Retrieve the source range for applicable fixes. Macro definitions
166+
// on the command line have locations in a virtual buffer and don't
167+
// have valid file paths and are therefore not applicable.
168+
CharSourceRange Range =
169+
CharSourceRange::getCharRange(SourceRange(FixLoc, FixEndLoc));
170170
Diag << FixItHint::CreateReplacement(Range,
171171
Repl.getReplacementText());
172172
}

0 commit comments

Comments
 (0)