[clang] [clang/AST] Make it possible to use SwiftAttr in type context (PR #108631)

Henrik G. Olsson via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 17 12:51:13 PDT 2024


================
@@ -5125,24 +5127,54 @@ QualType ASTContext::getUnresolvedUsingType(
 
 QualType ASTContext::getAttributedType(attr::Kind attrKind,
                                        QualType modifiedType,
-                                       QualType equivalentType) const {
+                                       QualType equivalentType,
+                                       const Attr *attr) const {
   llvm::FoldingSetNodeID id;
   AttributedType::Profile(id, attrKind, modifiedType, equivalentType);
----------------
hnrklssn wrote:

`AttributedType` is uniqued based on `attrKind`, but not `attr`. So calling this function may return a type with a pointer to a different `Attr` (although of the same kind). Is this a problem? Do we want to fully unique `AttributedType` based on it's `Attr*`?

The other option I believe is to fetch the `Attr*` from `AttributedTypeLoc` (which you can get through the `TypeSourceInfo` from `Decl` or `ExplicitCastExpr`) rather than the `AttributedType`, but doing that for generic expressions gets quite hairy.

https://github.com/llvm/llvm-project/pull/108631


More information about the cfe-commits mailing list