[all-commits] [llvm/llvm-project] 741a4d: [clang] Clarify SourceLocation and (Char)SourceRan...

Tobias Ribizel via All-commits all-commits at lists.llvm.org
Fri Feb 13 04:50:43 PST 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 741a4daa84c602d4bdd838ad469aea95b9f1d46c
      https://github.com/llvm/llvm-project/commit/741a4daa84c602d4bdd838ad469aea95b9f1d46c
  Author: Tobias Ribizel <mail at ribizel.de>
  Date:   2026-02-13 (Fri, 13 Feb 2026)

  Changed paths:
    M clang/include/clang/Basic/SourceLocation.h

  Log Message:
  -----------
  [clang] Clarify SourceLocation and (Char)SourceRange docs (#177400)

The current documentation leaves some questions unanswered to me, which
I'm trying to clarify here.
1. It was unclear how SourceLocation differed when referring to the
character level vs. the token level. Turns out there is no such
difference, and SourceLocation always refers to characters. This should
be made explicit in the docs.
2. It was unclear in which cases (Char)SourceRange is inclusive
(containing the endpoint) or exclusive (ending before the endpoint).
>From my reading of the docs and investigating the behavior of different
AST nodes' `getSourceLoc()` result and `Lexer::getSourceText()`,
SourceRange is always inclusive and CharSourceRange is inclusive only as
a TokenRange, and exclusive as a CharRange. This is also consistent
matches with the documentation of the clang::transformer::after()
function in RangeSelector.h, where the question of inclusive/exclusive
ranges came up first for me.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list