llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

[BoundsSafety] Move late parsing for parameters trigger from ParseDeclaratorInternal to ActOnFunctionDeclarator

Open rapidsna opened this issue 7 months ago • 4 comments

Part of: Late Parsing Refactoring for Bounds Safety Type Attributes (see llvm/llvm-project#179612) Phase: 0 (no dependencies, can be done immediately) Type: Downstream refactoring

Description

Currently, late parsing for function parameter bounds-safety attributes is triggered early during declarator parsing in ParseDeclaratorInternal. This is done to prevent FunctionDecl from being immediately merged with a previous declaration when the bounds attributes differ.

Move this trigger to ActOnFunctionDeclarator in SemaDecl.cpp, after the full FunctionDecl is created. The old late parsing mechanism stays — only the trigger location changes.

Why

The new approach creates LateParsedAttrType placeholders during declarator parsing and replaces them after the declaration is fully formed. Moving the trigger now validates that late parsing for parameters works from the new site, before the full mechanism switch.

Risk

Moving the trigger changes when late parsing occurs relative to other parser state. Scope setup for parameter name lookup must be replicated at the new site. Function redeclaration must be carefully verified.

Key files

  • clang/lib/Parse/ParseDecl.cpp — current trigger in ParseDeclaratorInternal at line 6806-6842
  • clang/lib/Sema/SemaDecl.cpp — target location in ActOnFunctionDeclarator

Validation

All existing lit tests must pass. Function redeclaration behavior must be verified.

rapidsna avatar Apr 14 '26 18:04 rapidsna

Hi, I would like to work on this.

abhijeetsharma200 avatar Apr 22 '26 13:04 abhijeetsharma200

@abhijeetsharma200 Are you still working on it? Let me know if you have any questions.

rapidsna avatar May 18 '26 22:05 rapidsna

Hi, just pushed a PR. Please take a look. Apologies for the delay

abhijeetsharma200 avatar Jun 12 '26 20:06 abhijeetsharma200

CC @Holo-xy

rapidsna avatar Jun 12 '26 20:06 rapidsna