[all-commits] [llvm/llvm-project] c128fd: [Clang] prevent crash on invalid nested name speci...

Oleksandr T. via All-commits all-commits at lists.llvm.org
Wed Dec 3 07:24:55 PST 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: c128fd9bebf7d281ac7cf12d8258573e8928672b
      https://github.com/llvm/llvm-project/commit/c128fd9bebf7d281ac7cf12d8258573e8928672b
  Author: Oleksandr T. <oleksandr.tarasiuk at outlook.com>
  Date:   2025-12-03 (Wed, 03 Dec 2025)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/include/clang/Lex/Token.h
    M clang/lib/Parse/ParseTentative.cpp
    A clang/test/Parser/cxx-nested-name-spec.cpp

  Log Message:
  -----------
  [Clang] prevent crash on invalid nested name specifiers with a single colon (#169246)

Fixes #167905

--- 

This patch addresses an issue where invalid nested name specifier
sequences containing a single colon (`a:c::`) could be treated during
recovery as valid scope specifiers, which in turn led to a crash


https://github.com/llvm/llvm-project/blob/c543615744d61e0967b956c402e310946d741570/clang/lib/Parse/ParseExprCXX.cpp#L404-L418


For malformed inputs like `a:c::`, the single colon recovery incorrectly
triggers and produces an `annot_cxxscope`. When tentative parsing later
runs


https://github.com/llvm/llvm-project/blob/996213c6ea0dc2e47624c6b06c0833a882c1c1f7/clang/lib/Parse/ParseTentative.cpp#L1739-L1740

the classifier returns `Ambiguous`, which doesn't stop parsing. The
parser then enters the


https://github.com/llvm/llvm-project/blob/996213c6ea0dc2e47624c6b06c0833a882c1c1f7/clang/lib/Parse/ParseTentative.cpp#L1750-L1752

and consumes the invalid scope annotation, eventually reaching `EOF` and
crashing.



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