[clang] [clang/AST] Make it possible to use SwiftAttr in type context (PR #108631)
Gábor Horváth via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 18 02:31:44 PDT 2024
================
@@ -6037,13 +6038,24 @@ class AttributedType : public Type, public llvm::FoldingSetNode {
private:
friend class ASTContext; // ASTContext creates these
+ const Attr *Attribute;
+
QualType ModifiedType;
QualType EquivalentType;
AttributedType(QualType canon, attr::Kind attrKind, QualType modified,
QualType equivalent)
+ : AttributedType(canon, attrKind, nullptr, modified, equivalent) {}
+
+ AttributedType(QualType canon, const Attr *attr, QualType modified,
+ QualType equivalent);
+
+private:
+ AttributedType(QualType canon, attr::Kind attrKind, const Attr *attr,
+ QualType modified, QualType equivalent)
: Type(Attributed, canon, equivalent->getDependence()),
- ModifiedType(modified), EquivalentType(equivalent) {
+ Attribute(attr), ModifiedType(modified),
+ EquivalentType(equivalent) {
AttributedTypeBits.AttrKind = attrKind;
----------------
Xazax-hun wrote:
I see, thanks! In that case it makes sense to me to encode this invariant in the constructor as an assertion (either `attr` is null, or it has the same kind as `attrKind`).
https://github.com/llvm/llvm-project/pull/108631
More information about the cfe-commits
mailing list