[all-commits] [llvm/llvm-project] d8f63b: [clang] Fix crash in isAtEndOfMacroExpansion at Fi...

Haojian Wu via All-commits all-commits at lists.llvm.org
Thu Apr 16 00:20:07 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: d8f63bbc8e20a68e764852a15d67a06fcd14c5bd
      https://github.com/llvm/llvm-project/commit/d8f63bbc8e20a68e764852a15d67a06fcd14c5bd
  Author: Haojian Wu <hokein.wu at gmail.com>
  Date:   2026-04-16 (Thu, 16 Apr 2026)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/lib/Lex/Lexer.cpp
    A clang/test/Parser/macro-braces-recovery.cpp

  Log Message:
  -----------
  [clang] Fix crash in isAtEndOfMacroExpansion at FileID boundary. (#191734)

During error recovery, a synthetic token (whose length is 0) can be
inserted past the end of a FileID, e.g. inserting ")" when a macro-arg
containing a comma should be guarded by parentheses.

When calculating the location after this token, the calculated
`AfterLoc` can point exactly to the start of the next FileID
(`NextLocalOffset`), any source manager operations on the `AfterLoc` are
invalid.
  
This patch adds a safe guard in `Lexer::isAtEndOfMacroExpansion` to
prevent passing this invalid location to `SourceManager`.

 Fixes #115007
 Fixes #21755



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