@@ -4226,11 +4226,12 @@ bool LLParser::parseValID(ValID &ID, PerFunctionState *PFS, Type *ExpectedTy) {
42264226 }
42274227 case lltok::kw_ptrauth: {
42284228 // ValID ::= 'ptrauth' '(' ptr @foo ',' i32 <key>
4229- // (',' i64 <disc> (',' ptr addrdisc)? )? ')'
4229+ // (',' i64 <disc> (',' ptr addrdisc (',' ptr ds)? )? )? ')'
42304230 Lex.Lex ();
42314231
42324232 Constant *Ptr, *Key;
4233- Constant *Disc = nullptr , *AddrDisc = nullptr ;
4233+ Constant *Disc = nullptr , *AddrDisc = nullptr ,
4234+ *DeactivationSymbol = nullptr ;
42344235
42354236 if (parseToken (lltok::lparen,
42364237 " expected '(' in constant ptrauth expression" ) ||
@@ -4239,11 +4240,14 @@ bool LLParser::parseValID(ValID &ID, PerFunctionState *PFS, Type *ExpectedTy) {
42394240 " expected comma in constant ptrauth expression" ) ||
42404241 parseGlobalTypeAndValue (Key))
42414242 return true ;
4242- // If present, parse the optional disc/addrdisc.
4243- if (EatIfPresent (lltok::comma))
4244- if (parseGlobalTypeAndValue (Disc) ||
4245- (EatIfPresent (lltok::comma) && parseGlobalTypeAndValue (AddrDisc)))
4246- return true ;
4243+ // If present, parse the optional disc/addrdisc/ds.
4244+ if (EatIfPresent (lltok::comma) && parseGlobalTypeAndValue (Disc))
4245+ return true ;
4246+ if (EatIfPresent (lltok::comma) && parseGlobalTypeAndValue (AddrDisc))
4247+ return true ;
4248+ if (EatIfPresent (lltok::comma) &&
4249+ parseGlobalTypeAndValue (DeactivationSymbol))
4250+ return true ;
42474251 if (parseToken (lltok::rparen,
42484252 " expected ')' in constant ptrauth expression" ))
42494253 return true ;
@@ -4274,7 +4278,16 @@ bool LLParser::parseValID(ValID &ID, PerFunctionState *PFS, Type *ExpectedTy) {
42744278 AddrDisc = ConstantPointerNull::get (PointerType::get (Context, 0 ));
42754279 }
42764280
4277- ID.ConstantVal = ConstantPtrAuth::get (Ptr, KeyC, DiscC, AddrDisc);
4281+ if (DeactivationSymbol) {
4282+ if (!DeactivationSymbol->getType ()->isPointerTy ())
4283+ return error (
4284+ ID.Loc , " constant ptrauth deactivation symbol must be a pointer" );
4285+ } else {
4286+ DeactivationSymbol = ConstantPointerNull::get (PointerType::get (Context, 0 ));
4287+ }
4288+
4289+ ID.ConstantVal =
4290+ ConstantPtrAuth::get (Ptr, KeyC, DiscC, AddrDisc, DeactivationSymbol);
42784291 ID.Kind = ValID::t_Constant;
42794292 return false ;
42804293 }
0 commit comments