[llvm-branch-commits] [clang] [Clang] [NFC] Expansion Statements (Part 4: for-range and `ParseScope` refactor) (PR #169683)

Aaron Ballman via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri May 15 06:12:34 PDT 2026


AaronBallman wrote:

> > I'm a bit uncomfortable moving parser related objects to sema.
> 
> Well I would argue it’s ‘parser-related’ in name only; what it does is it pushes a new scope; the implementation of `ParseScope` only calls Sema functions; it never actually did anything `Parser`-related in the first place

To me, the `ParseScope` object is an RAII one that should live in `RAIIObjectsForParser.h`; it exists for `Parser` and `Sema` to collude on scope management from the perspective of the parser. (e.g., when parsing, you know it's time to enter a new scope so you'd use one of these to manage it automagically for you). Based on that, it seems like this interface should remain at the `Parser` level; Sema should not need to enter new parse scopes in general *except* in the case of doing statement rewriting which should be an exception rather than a regular thing, right? (IOW, I think we'd want to go in the direction of generic facilities to support statement rewriting rather than lower-level facilities like the parser has to use?)

This isn't a strongly held opinion btw.

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


More information about the llvm-branch-commits mailing list