@@ -168,8 +168,13 @@ class PointerAuthQualifier {
168168 AuthenticatesNullValuesBits = 1 ,
169169 AuthenticatesNullValuesMask = ((1 << AuthenticatesNullValuesBits) - 1 )
170170 << AuthenticatesNullValuesShift,
171- KeyShift = AuthenticatesNullValuesShift + AuthenticatesNullValuesBits,
172- KeyBits = 10 ,
171+ RestrictedIntegralShift =
172+ AuthenticatesNullValuesShift + AuthenticatesNullValuesBits,
173+ RestrictedIntegralBits = 1 ,
174+ RestrictedIntegralMask = ((1 << RestrictedIntegralBits) - 1 )
175+ << RestrictedIntegralShift,
176+ KeyShift = RestrictedIntegralShift + RestrictedIntegralBits,
177+ KeyBits = 9 ,
173178 KeyMask = ((1 << KeyBits) - 1 ) << KeyShift,
174179 DiscriminatorShift = KeyShift + KeyBits,
175180 DiscriminatorBits = 16 ,
@@ -178,32 +183,33 @@ class PointerAuthQualifier {
178183
179184 // bits: |0 |1 |2..3 |4 |
180185 // |Enabled|Address|AuthenticationMode|ISA pointer|
181- // bits: |5 |6..15| 16...31 |
182- // |AuthenticatesNull|Key |Discriminator|
186+ // bits: |5 |6 |7 ..15| 16...31 |
187+ // |AuthenticatesNull|RestrictedIntegral| Key |Discriminator|
183188 uint32_t Data = 0 ;
184189
185190 // The following static assertions check that each of the 32 bits is present
186191 // exactly in one of the constants.
187192 static_assert ((EnabledBits + AddressDiscriminatedBits +
188193 AuthenticationModeBits + IsaPointerBits +
189- AuthenticatesNullValuesBits + KeyBits + DiscriminatorBits) ==
190- 32 ,
194+ AuthenticatesNullValuesBits + RestrictedIntegralBits +
195+ KeyBits + DiscriminatorBits) == 32 ,
191196 " PointerAuthQualifier should be exactly 32 bits" );
192197 static_assert ((EnabledMask + AddressDiscriminatedMask +
193198 AuthenticationModeMask + IsaPointerMask +
194- AuthenticatesNullValuesMask + KeyMask + DiscriminatorMask) ==
195- 0xFFFFFFFF ,
199+ AuthenticatesNullValuesMask + RestrictedIntegralMask +
200+ KeyMask + DiscriminatorMask) == 0xFFFFFFFF ,
196201 " All masks should cover the entire bits" );
197202 static_assert ((EnabledMask ^ AddressDiscriminatedMask ^
198203 AuthenticationModeMask ^ IsaPointerMask ^
199- AuthenticatesNullValuesMask ^ KeyMask ^ DiscriminatorMask) ==
200- 0xFFFFFFFF ,
204+ AuthenticatesNullValuesMask ^ RestrictedIntegralMask ^
205+ KeyMask ^ DiscriminatorMask) == 0xFFFFFFFF ,
201206 " All masks should cover the entire bits" );
202207
203208 PointerAuthQualifier (unsigned Key, bool IsAddressDiscriminated,
204209 unsigned ExtraDiscriminator,
205210 PointerAuthenticationMode AuthenticationMode,
206- bool IsIsaPointer, bool AuthenticatesNullValues)
211+ bool IsIsaPointer, bool AuthenticatesNullValues,
212+ bool IsRestrictedIntegral)
207213 : Data(EnabledMask |
208214 (IsAddressDiscriminated
209215 ? llvm::to_underlying(AddressDiscriminatedMask)
@@ -212,8 +218,8 @@ class PointerAuthQualifier {
212218 (llvm::to_underlying(AuthenticationMode)
213219 << AuthenticationModeShift) |
214220 (ExtraDiscriminator << DiscriminatorShift) |
215- (IsIsaPointer << IsaPointerShift ) |
216- (AuthenticatesNullValues << AuthenticatesNullValuesShift )) {
221+ (AuthenticatesNullValues << AuthenticatesNullValuesShift ) |
222+ (IsRestrictedIntegral << RestrictedIntegralShift )) {
217223 assert (Key <= KeyNoneInternal);
218224 assert (ExtraDiscriminator <= MaxDiscriminator);
219225 assert ((Data == 0 ) ==
@@ -237,13 +243,13 @@ class PointerAuthQualifier {
237243 static PointerAuthQualifier
238244 Create (unsigned Key, bool IsAddressDiscriminated, unsigned ExtraDiscriminator,
239245 PointerAuthenticationMode AuthenticationMode, bool IsIsaPointer,
240- bool AuthenticatesNullValues) {
246+ bool AuthenticatesNullValues, bool IsRestrictedIntegral ) {
241247 if (Key == PointerAuthKeyNone)
242248 Key = KeyNoneInternal;
243249 assert (Key <= KeyNoneInternal && " out-of-range key value" );
244250 return PointerAuthQualifier (Key, IsAddressDiscriminated, ExtraDiscriminator,
245251 AuthenticationMode, IsIsaPointer,
246- AuthenticatesNullValues);
252+ AuthenticatesNullValues, IsRestrictedIntegral );
247253 }
248254
249255 bool isPresent () const {
@@ -290,6 +296,10 @@ class PointerAuthQualifier {
290296 return hasKeyNone () ? PointerAuthQualifier () : *this ;
291297 }
292298
299+ bool isRestrictedIntegral () const {
300+ return (Data & RestrictedIntegralMask) >> RestrictedIntegralShift;
301+ }
302+
293303 friend bool operator ==(PointerAuthQualifier Lhs, PointerAuthQualifier Rhs) {
294304 return Lhs.Data == Rhs.Data ;
295305 }
@@ -2563,7 +2573,9 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
25632573 bool isFunctionProtoType () const { return getAs<FunctionProtoType>(); }
25642574 bool isPointerType () const ;
25652575 bool isPointerOrReferenceType () const ;
2566- bool isSignableType () const ;
2576+ bool isSignableType (const ASTContext &Ctx) const ;
2577+ bool isSignablePointerType () const ;
2578+ bool isSignableIntegerType (const ASTContext &Ctx) const ;
25672579 bool isAnyPointerType () const ; // Any C pointer or ObjC object pointer
25682580 bool isCountAttributedType () const ;
25692581 bool isBlockPointerType () const ;
@@ -8216,7 +8228,13 @@ inline bool Type::isAnyPointerType() const {
82168228 return isPointerType () || isObjCObjectPointerType ();
82178229}
82188230
8219- inline bool Type::isSignableType () const { return isPointerType (); }
8231+ inline bool Type::isSignableType (const ASTContext &Ctx) const {
8232+ return isSignablePointerType () || isSignableIntegerType (Ctx);
8233+ }
8234+
8235+ inline bool Type::isSignablePointerType () const {
8236+ return isPointerType () || isObjCClassType () || isObjCQualifiedClassType ();
8237+ }
82208238
82218239inline bool Type::isBlockPointerType () const {
82228240 return isa<BlockPointerType>(CanonicalType);
0 commit comments