@@ -4216,11 +4216,12 @@ bool LLParser::parseValID(ValID &ID, PerFunctionState *PFS, Type *ExpectedTy) {
42164216 }
42174217 case lltok::kw_ptrauth: {
42184218 // ValID ::= 'ptrauth' '(' ptr @foo ',' i32 <key>
4219- // (',' i64 <disc> (',' ptr addrdisc)? )? ')'
4219+ // (',' i64 <disc> (',' ptr addrdisc (',' ptr ds)? )? )? ')'
42204220 Lex.Lex ();
42214221
42224222 Constant *Ptr, *Key;
4223- Constant *Disc = nullptr , *AddrDisc = nullptr ;
4223+ Constant *Disc = nullptr , *AddrDisc = nullptr ,
4224+ *DeactivationSymbol = nullptr ;
42244225
42254226 if (parseToken (lltok::lparen,
42264227 " expected '(' in constant ptrauth expression" ) ||
@@ -4229,11 +4230,14 @@ bool LLParser::parseValID(ValID &ID, PerFunctionState *PFS, Type *ExpectedTy) {
42294230 " expected comma in constant ptrauth expression" ) ||
42304231 parseGlobalTypeAndValue (Key))
42314232 return true ;
4232- // If present, parse the optional disc/addrdisc.
4233- if (EatIfPresent (lltok::comma))
4234- if (parseGlobalTypeAndValue (Disc) ||
4235- (EatIfPresent (lltok::comma) && parseGlobalTypeAndValue (AddrDisc)))
4236- return true ;
4233+ // If present, parse the optional disc/addrdisc/ds.
4234+ if (EatIfPresent (lltok::comma) && parseGlobalTypeAndValue (Disc))
4235+ return true ;
4236+ if (EatIfPresent (lltok::comma) && parseGlobalTypeAndValue (AddrDisc))
4237+ return true ;
4238+ if (EatIfPresent (lltok::comma) &&
4239+ parseGlobalTypeAndValue (DeactivationSymbol))
4240+ return true ;
42374241 if (parseToken (lltok::rparen,
42384242 " expected ')' in constant ptrauth expression" ))
42394243 return true ;
@@ -4264,7 +4268,16 @@ bool LLParser::parseValID(ValID &ID, PerFunctionState *PFS, Type *ExpectedTy) {
42644268 AddrDisc = ConstantPointerNull::get (PointerType::get (Context, 0 ));
42654269 }
42664270
4267- ID.ConstantVal = ConstantPtrAuth::get (Ptr, KeyC, DiscC, AddrDisc);
4271+ if (DeactivationSymbol) {
4272+ if (!DeactivationSymbol->getType ()->isPointerTy ())
4273+ return error (
4274+ ID.Loc , " constant ptrauth deactivation symbol must be a pointer" );
4275+ } else {
4276+ DeactivationSymbol = ConstantPointerNull::get (PointerType::get (Context, 0 ));
4277+ }
4278+
4279+ ID.ConstantVal =
4280+ ConstantPtrAuth::get (Ptr, KeyC, DiscC, AddrDisc, DeactivationSymbol);
42684281 ID.Kind = ValID::t_Constant;
42694282 return false ;
42704283 }
0 commit comments