@@ -1620,6 +1620,23 @@ bool LLParser::parseEnumAttribute(Attribute::AttrKind Attr, AttrBuilder &B,
16201620 B.addDereferenceableOrNullAttr (Bytes);
16211621 return false ;
16221622 }
1623+ case Attribute::FlattenDeep: {
1624+ uint64_t Depth = 0 ;
1625+ if (InAttrGroup) {
1626+ Lex.Lex ();
1627+ LocTy DepthLoc = Lex.getLoc ();
1628+ if (parseToken (lltok::equal, " expected '=' here" ) ||
1629+ parseUInt64 (Depth))
1630+ return true ;
1631+ if (!Depth)
1632+ return error (DepthLoc, " flatten_deep depth must be non-zero" );
1633+ } else {
1634+ if (parseOptionalFlattenDeepDepth (lltok::kw_flatten_deep, Depth))
1635+ return true ;
1636+ }
1637+ B.addFlattenDeepAttr (Depth);
1638+ return false ;
1639+ }
16231640 case Attribute::UWTable: {
16241641 UWTableKind Kind;
16251642 if (parseOptionalUWTableKind (Kind))
@@ -2494,6 +2511,30 @@ bool LLParser::parseOptionalDerefAttrBytes(lltok::Kind AttrKind,
24942511 return false ;
24952512}
24962513
2514+ // / parseOptionalFlattenDeepDepth
2515+ // / ::= /* empty */
2516+ // / ::= 'flatten_deep' '(' 4 ')'
2517+ bool LLParser::parseOptionalFlattenDeepDepth (lltok::Kind AttrKind,
2518+ uint64_t &Depth) {
2519+ assert (AttrKind == lltok::kw_flatten_deep && " contract!" );
2520+
2521+ Depth = 0 ;
2522+ if (!EatIfPresent (AttrKind))
2523+ return false ;
2524+ LocTy ParenLoc = Lex.getLoc ();
2525+ if (!EatIfPresent (lltok::lparen))
2526+ return error (ParenLoc, " expected '('" );
2527+ LocTy DepthLoc = Lex.getLoc ();
2528+ if (parseUInt64 (Depth))
2529+ return true ;
2530+ ParenLoc = Lex.getLoc ();
2531+ if (!EatIfPresent (lltok::rparen))
2532+ return error (ParenLoc, " expected ')'" );
2533+ if (!Depth)
2534+ return error (DepthLoc, " flatten_deep depth must be non-zero" );
2535+ return false ;
2536+ }
2537+
24972538bool LLParser::parseOptionalUWTableKind (UWTableKind &Kind) {
24982539 Lex.Lex ();
24992540 Kind = UWTableKind::Default;
0 commit comments