rsmith added inline comments.
Comment at: lib/Parse/ParseDecl.cpp:2702
DS.SetRangeStart(Tok.getLocation());
-DS.SetRangeEnd(SourceLocation());
+DS.SetRangeEnd(Tok.getLocation());
}
This doesn't look right: this is a source range containing exactly
erikjv updated this revision to Diff 80735.
https://reviews.llvm.org/D21075
Files:
lib/Parse/ParseDecl.cpp
lib/Sema/SemaExpr.cpp
test/Index/diagnostic-ranges.cpp
Index: test/Index/diagnostic-ranges.cpp
===
--- /dev/null
+++ t
klimek added a comment.
> It's mostly about how much is "underlined". If there is only a caret, that
> quite often translates into a single character being pointed out, instead of
> an identifier (i.e. the first character). Hene the extension of the range.
Aren't we mostly doing token positions
erikjv added inline comments.
Comment at: lib/Sema/SemaExpr.cpp:2061-2062
+ auto Builder = Diag(R.getNameLoc(), diagnostic) << Name;
+ if (Name.isIdentifier())
+Builder << SourceRange(R.getNameLoc());
return true;
rsmith wrote:
> I'm indifferent on this
rsmith added inline comments.
Comment at: lib/Sema/SemaExpr.cpp:2061-2062
+ auto Builder = Diag(R.getNameLoc(), diagnostic) << Name;
+ if (Name.isIdentifier())
+Builder << SourceRange(R.getNameLoc());
return true;
I'm indifferent on this change: I don't
klimek added a reviewer: rsmith.
Comment at: lib/Sema/SemaType.cpp:1339
@@ +1338,3 @@
+auto R = DS.getSourceRange();
+if (R.getEnd().isInvalid())
+ R.setEnd(R.getBegin());
erikjv wrote:
> klimek wrote:
> > Do you know in which cases we get
erikjv added a comment.
I'll add tests in the next diff, but I'd like to know if these changes are ok.
Comment at: lib/Sema/SemaType.cpp:1339
@@ +1338,3 @@
+auto R = DS.getSourceRange();
+if (R.getEnd().isInvalid())
+ R.setEnd(R.getBegin());
klimek added inline comments.
Comment at: lib/Sema/SemaType.cpp:1339
@@ +1338,3 @@
+auto R = DS.getSourceRange();
+if (R.getEnd().isInvalid())
+ R.setEnd(R.getBegin());
Do you know in which cases we get source ranges that are half valid?
erikjv created this revision.
erikjv added reviewers: bkramer, klimek.
erikjv added a subscriber: cfe-commits.
Declaration names in DeclSpec had only their start set to a valid
location, so when the type specifier was missing, only the carret would
be shown at the first character of the name of a