[clang] [llvm] [clang/LLVM] Add flatten_deep attribute for depth-limited inlining (1/2) (PR #165777)

Erich Keane via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 17 06:21:50 PST 2025


================
@@ -3695,6 +3695,22 @@ static void handleInitPriorityAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
   D->addAttr(::new (S.Context) InitPriorityAttr(S.Context, AL, prioritynum));
 }
 
+static void handleFlattenDepthAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
+  Expr *E = AL.getArgAsExpr(0);
+  uint32_t depthHint;
+  if (!S.checkUInt32Argument(AL, E, depthHint)) {
----------------
erichkeane wrote:

This doesn't seem to handle dependent arguments, which, IMO, we probably want to support.  Consider:

```
template<typename T, unsigned I> struct S {

[[flatten_depth(I)]]
void func1(){/*...*/}

[[flatten_depth(T::value)]]
void func2(){/*...*/}

};

struct HasVal { static constexpr int value = 3; };

void foo() {
   S<HasVal, 2> s;
s.func1();
s.func2();
}
```


I would expect that to work without issue.

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


More information about the llvm-commits mailing list