-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[clang/AST] Make it possible to use SwiftAttr in type context #108631
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1241,8 +1241,8 @@ struct SimpleTransformVisitor : public TypeVisitor<Derived, QualType> { | |
== T->getEquivalentType().getAsOpaquePtr()) | ||
return QualType(T, 0); | ||
|
||
return Ctx.getAttributedType(T->getAttrKind(), modifiedType, | ||
equivalentType); | ||
return Ctx.getAttributedType(T->getAttrKind(), modifiedType, equivalentType, | ||
T->getAttr()); | ||
} | ||
|
||
QualType VisitSubstTemplateTypeParmType(const SubstTemplateTypeParmType *T) { | ||
|
@@ -1545,7 +1545,8 @@ struct SubstObjCTypeArgsVisitor | |
|
||
// Rebuild the attributed type. | ||
return Ctx.getAttributedType(newAttrType->getAttrKind(), | ||
newAttrType->getModifiedType(), newEquivType); | ||
newAttrType->getModifiedType(), newEquivType, | ||
newAttrType->getAttr()); | ||
} | ||
}; | ||
|
||
|
@@ -4115,6 +4116,19 @@ bool RecordType::hasConstFields() const { | |
return false; | ||
} | ||
|
||
AttributedType::AttributedType(QualType canon, const Attr *attr, | ||
QualType modified, QualType equivalent) | ||
: AttributedType(canon, attr->getKind(), attr, modified, equivalent) {} | ||
|
||
AttributedType::AttributedType(QualType canon, attr::Kind attrKind, | ||
const Attr *attr, QualType modified, | ||
QualType equivalent) | ||
: Type(Attributed, canon, equivalent->getDependence()), Attribute(attr), | ||
ModifiedType(modified), EquivalentType(equivalent) { | ||
AttributedTypeBits.AttrKind = attrKind; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it'd be lovely to get these bits back. Perhaps just remove attrKind from this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we can do that, see https://github.com/llvm/llvm-project/pull/108631/files#r1823004595. @Xazax-hun had a comment to that effect already. |
||
assert(!attr || attr->getKind() == attrKind); | ||
} | ||
|
||
bool AttributedType::isQualifier() const { | ||
// FIXME: Generate this with TableGen. | ||
switch (getAttrKind()) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there reason to store both
attribute
andattrKind
here? Should we just implementattrKind
asattribute.getKind
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, Attr is not always available (nullability related attributes only have a kind and don't allocate Attr).