================
@@ -1873,6 +1873,17 @@ Parser::TryAnnotateName(CorrectionCandidateCallback *CCC,
   return AnnotatedNameKind::Unresolved;
 }
 
+SourceLocation Parser::getEndOfPreviousToken() const {
+  SourceLocation TokenEndLoc = PP.getLocForEndOfToken(PrevTokLocation);
+  if (TokenEndLoc.isValid())
+    return TokenEndLoc;
+
+  if (Tok.getLocation().isMacroID())
+    return PP.getSourceManager().getSpellingLoc(Tok.getLocation());
----------------
efriedma-quic wrote:

In cases where the we don't try to compute the end of a token, the diagnostic 
usually looks something like this:

```
#define D if x==3) {}
void f(int x) { D }
<stdin>:2:17: error: expected '(' after 'if'
    2 | void f(int x) { D }
      |                 ^
<stdin>:1:14: note: expanded from macro 'D'
    1 | #define D if x==3) {}
      |              ^
1 error generated.
```

Which... maybe you could argue there's room for improvement, but we should 
behave consistently across diagnostics.

https://github.com/llvm/llvm-project/pull/143460
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to