[llvm-branch-commits] [clang] [clang] Reject ranges getExpansionRangeInFile cannot represent (PR #214461)

DonĂ¡t Nagy via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Aug 10 05:36:26 PDT 2026


================
@@ -36,7 +36,14 @@ using DiagOrStoredDiag =
 /// Maps both endpoints of \p Range to their macro expansion, so that the range
 /// can be shown to a user.
 ///
-/// \returns nullopt if \p Range is invalid, if an endpoint lies outside \p FID.
+/// \returns nullopt if \p Range is invalid, if an endpoint lies outside \p FID,
+/// Unlike \c Lexer::makeFileCharRange(), which gives up when an endpoint is
+/// strictly inside an expansion, this points at the expansion; prefer
+/// \c makeFileCharRange() when a faithful file range matters, e.g. for
+/// rewriting.
+///
+/// The result may still be a token range, but \c Lexer::getAsCharRange() cannot
+/// fail on it: both endpoints are file locations.
----------------
NagyDonat wrote:

I don't see the correspondence between this comment update and the code change (which introduces the postcondition for the returned range its begin is <= its end).

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


More information about the llvm-branch-commits mailing list