[clang] [Clang] fix missing source location for errors in macro-expanded (PR #143460)

Eli Friedman via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 11 09:20:58 PDT 2025


================
@@ -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:

I'm not sure what this getSpellingLoc() call accomplishes; at first glance, it's just throwing away information about macro expansions.

https://github.com/llvm/llvm-project/pull/143460


More information about the cfe-commits mailing list