3131#include " clang/Basic/PointerAuthOptions.h"
3232#include " clang/Basic/SourceLocation.h"
3333#include " clang/Basic/Specifiers.h"
34+ #include " clang/Basic/TargetInfo.h"
3435#include " clang/Basic/Visibility.h"
3536#include " llvm/ADT/APInt.h"
3637#include " llvm/ADT/APSInt.h"
@@ -323,6 +324,7 @@ class PointerAuthQualifier {
323324// / * Objective C: the GC attributes (none, weak, or strong)
324325class Qualifiers {
325326public:
327+ Qualifiers () = default ;
326328 enum TQ : uint64_t {
327329 // NOTE: These flags must be kept in sync with DeclSpec::TQ.
328330 Const = 0x1 ,
@@ -697,7 +699,8 @@ class Qualifiers {
697699 // / every address space is a superset of itself.
698700 // / CL2.0 adds:
699701 // / __generic is a superset of any address space except for __constant.
700- static bool isAddressSpaceSupersetOf (LangAS A, LangAS B) {
702+ static bool isAddressSpaceSupersetOf (LangAS A, LangAS B,
703+ const TargetInfo &TI) {
701704 // Address spaces must match exactly.
702705 return A == B ||
703706 // Otherwise in OpenCLC v2.0 s6.5.5: every address space except
@@ -722,20 +725,24 @@ class Qualifiers {
722725 // to implicitly cast into the default address space.
723726 (A == LangAS::Default &&
724727 (B == LangAS::cuda_constant || B == LangAS::cuda_device ||
725- B == LangAS::cuda_shared));
728+ B == LangAS::cuda_shared)) ||
729+ // Conversions from target specific address spaces may be legal
730+ // depending on the target information.
731+ TI.isAddressSpaceSupersetOf (A, B);
726732 }
727733
728734 // / Returns true if the address space in these qualifiers is equal to or
729735 // / a superset of the address space in the argument qualifiers.
730- bool isAddressSpaceSupersetOf (Qualifiers other) const {
731- return isAddressSpaceSupersetOf (getAddressSpace (), other.getAddressSpace ());
736+ bool isAddressSpaceSupersetOf (Qualifiers other, const TargetInfo &TI) const {
737+ return isAddressSpaceSupersetOf (getAddressSpace (), other.getAddressSpace (),
738+ TI);
732739 }
733740
734741 // / Determines if these qualifiers compatibly include another set.
735742 // / Generally this answers the question of whether an object with the other
736743 // / qualifiers can be safely used as an object with these qualifiers.
737- bool compatiblyIncludes (Qualifiers other) const {
738- return isAddressSpaceSupersetOf (other) &&
744+ bool compatiblyIncludes (Qualifiers other, const TargetInfo &TI ) const {
745+ return isAddressSpaceSupersetOf (other, TI ) &&
739746 // ObjC GC qualifiers can match, be added, or be removed, but can't
740747 // be changed.
741748 (getObjCGCAttr () == other.getObjCGCAttr () || !hasObjCGCAttr () ||
@@ -1273,11 +1280,11 @@ class QualType {
12731280
12741281 // / Determine whether this type is more qualified than the other
12751282 // / given type, requiring exact equality for non-CVR qualifiers.
1276- bool isMoreQualifiedThan (QualType Other) const ;
1283+ bool isMoreQualifiedThan (QualType Other, const TargetInfo &TI ) const ;
12771284
12781285 // / Determine whether this type is at least as qualified as the other
12791286 // / given type, requiring exact equality for non-CVR qualifiers.
1280- bool isAtLeastAsQualifiedAs (QualType Other) const ;
1287+ bool isAtLeastAsQualifiedAs (QualType Other, const TargetInfo &TI ) const ;
12811288
12821289 QualType getNonReferenceType () const ;
12831290
@@ -1425,11 +1432,12 @@ class QualType {
14251432 // / address spaces overlap iff they are they same.
14261433 // / OpenCL C v2.0 s6.5.5 adds:
14271434 // / __generic overlaps with any address space except for __constant.
1428- bool isAddressSpaceOverlapping (QualType T) const {
1435+ bool isAddressSpaceOverlapping (QualType T, const TargetInfo &TI ) const {
14291436 Qualifiers Q = getQualifiers ();
14301437 Qualifiers TQ = T.getQualifiers ();
14311438 // Address spaces overlap if at least one of them is a superset of another
1432- return Q.isAddressSpaceSupersetOf (TQ) || TQ.isAddressSpaceSupersetOf (Q);
1439+ return Q.isAddressSpaceSupersetOf (TQ, TI) ||
1440+ TQ.isAddressSpaceSupersetOf (Q, TI);
14331441 }
14341442
14351443 // / Returns gc attribute of this type.
@@ -8112,24 +8120,26 @@ inline FunctionType::ExtInfo getFunctionExtInfo(QualType t) {
81128120// / is more qualified than "const int", "volatile int", and
81138121// / "int". However, it is not more qualified than "const volatile
81148122// / int".
8115- inline bool QualType::isMoreQualifiedThan (QualType other) const {
8123+ inline bool QualType::isMoreQualifiedThan (QualType other,
8124+ const TargetInfo &TI) const {
81168125 Qualifiers MyQuals = getQualifiers ();
81178126 Qualifiers OtherQuals = other.getQualifiers ();
8118- return (MyQuals != OtherQuals && MyQuals.compatiblyIncludes (OtherQuals));
8127+ return (MyQuals != OtherQuals && MyQuals.compatiblyIncludes (OtherQuals, TI ));
81198128}
81208129
81218130// / Determine whether this type is at last
81228131// / as qualified as the Other type. For example, "const volatile
81238132// / int" is at least as qualified as "const int", "volatile int",
81248133// / "int", and "const volatile int".
8125- inline bool QualType::isAtLeastAsQualifiedAs (QualType other) const {
8134+ inline bool QualType::isAtLeastAsQualifiedAs (QualType other,
8135+ const TargetInfo &TI) const {
81268136 Qualifiers OtherQuals = other.getQualifiers ();
81278137
81288138 // Ignore __unaligned qualifier if this type is a void.
81298139 if (getUnqualifiedType ()->isVoidType ())
81308140 OtherQuals.removeUnaligned ();
81318141
8132- return getQualifiers ().compatiblyIncludes (OtherQuals);
8142+ return getQualifiers ().compatiblyIncludes (OtherQuals, TI );
81338143}
81348144
81358145// / If Type is a reference type (e.g., const
0 commit comments