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

2024-09-13 Thread Pavel Yaskevich via cfe-commits

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

Swift ClangImporter now supports concurrency annotations on imported 
declarations and their parameters/results, to make it possible to use imported 
APIs in Swift safely there has to be a way to annotate individual parameters 
and result types with relevant attributes that indicate that e.g. a block is 
called on a particular actor or it accepts a `Sendable` parameter.

To faciliate that `SwiftAttr` is switched from `InheritableAttr` which is a 
declaration attribute to `DeclOrTypeAttr`. To support this attribute in type 
context we need access to its "Attribute" argument which requires 
`AttributedType` to be extended to include `Attr *` when available instead of 
just `attr::Kind` otherwise it won't be possible to determine what attribute 
should be imported.

>From e3c3d347b62b63b0a85d74598569d27a671a07d0 Mon Sep 17 00:00:00 2001
From: Pavel Yaskevich 
Date: Wed, 20 Dec 2023 14:04:22 -0800
Subject: [PATCH] [clang/AST] Make it possible to use SwiftAttr in type context

Swift ClangImporter now supports concurrency annotations on imported 
declarations
and their parameters/results, to make it possible to use imported APIs in Swift
safely there has to be a way to annotate individual parameters and result types
with relevant attributes that indicate that e.g. a block is called on a 
particular
actor or it accepts a `Sendable` parameter.

To faciliate that `SwiftAttr` is switched from `InheritableAttr` which is a 
declaration
attribute to `DeclOrTypeAttr`. To support this attribute in type context we 
need access
to its "Attribute" argument which requires `AttributedType` to be extended to 
include
`Attr *` when available instead of just `attr::Kind` otherwise it won't be 
possible to
determine what attribute should be imported.
---
 clang/include/clang/AST/ASTContext.h  |  7 ++
 clang/include/clang/AST/PropertiesBase.td |  1 +
 clang/include/clang/AST/Type.h| 35 +-
 clang/include/clang/AST/TypeProperties.td |  8 ++-
 clang/include/clang/Basic/Attr.td |  2 +-
 clang/include/clang/Basic/AttrDocs.td |  4 +-
 .../clang/Serialization/ASTRecordWriter.h |  2 +
 clang/lib/AST/ASTContext.cpp  | 49 +++---
 clang/lib/AST/ASTDiagnostic.cpp   |  6 +-
 clang/lib/AST/ASTImporter.cpp |  5 +-
 clang/lib/AST/Type.cpp| 11 ++-
 clang/lib/AST/TypePrinter.cpp |  9 +++
 clang/lib/Sema/SemaDecl.cpp   |  4 +-
 clang/lib/Sema/SemaDeclObjC.cpp   |  4 +-
 clang/lib/Sema/SemaExpr.cpp   |  3 +-
 clang/lib/Sema/SemaExprObjC.cpp   | 29 +++-
 clang/lib/Sema/SemaObjCProperty.cpp   |  4 +-
 clang/lib/Sema/SemaSwift.cpp  |  7 +-
 clang/lib/Sema/SemaType.cpp   | 67 +--
 clang/lib/Sema/TreeTransform.h|  3 +-
 clang/test/AST/attr-swift_attr.m  | 31 +
 .../test/SemaObjC/validate-attr-swift_attr.m  |  4 ++
 22 files changed, 217 insertions(+), 78 deletions(-)

diff --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 168bdca3c880b2..f49bb7afce2336 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -1677,8 +1677,15 @@ class ASTContext : public RefCountedBase {
   QualType getInjectedClassNameType(CXXRecordDecl *Decl, QualType TST) const;
 
   QualType getAttributedType(attr::Kind attrKind, QualType modifiedType,
+ QualType equivalentType,
+ const Attr *attr = nullptr) const;
+
+  QualType getAttributedType(const Attr *attr, QualType modifiedType,
  QualType equivalentType) const;
 
+  QualType getAttributedType(NullabilityKind nullability, QualType 
modifiedType,
+ QualType equivalentType);
+
   QualType getBTFTagAttributedType(const BTFTypeTagAttr *BTFAttr,
QualType Wrapped);
 
diff --git a/clang/include/clang/AST/PropertiesBase.td 
b/clang/include/clang/AST/PropertiesBase.td
index 9b934b20cf2559..0d1712a1fe15fd 100644
--- a/clang/include/clang/AST/PropertiesBase.td
+++ b/clang/include/clang/AST/PropertiesBase.td
@@ -76,6 +76,7 @@ def APValue : PropertyType { let PassByReference = 1; }
 def APValueKind : EnumPropertyType<"APValue::ValueKind">;
 def ArraySizeModifier : EnumPropertyType<"ArraySizeModifier">;
 def AttrKind : EnumPropertyType<"attr::Kind">;
+def Attr : PropertyType<"const Attr *">;
 def AutoTypeKeyword : EnumPropertyType;
 def Bool : PropertyType<"bool">;
 def BuiltinTypeKind : EnumPropertyType<"BuiltinType::Kind">;
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index ef36a73716454f..7bb8aea05b8fa4 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -68,6 +68,7 

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

2024-10-30 Thread Pavel Yaskevich via cfe-commits

xedin wrote:

No worries, I can just rebase and push force, that should do it :)

https://github.com/llvm/llvm-project/pull/108631
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2024-10-30 Thread Pavel Yaskevich via cfe-commits

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

>From a66d820647c927dee23498cd12338748f4079688 Mon Sep 17 00:00:00 2001
From: Pavel Yaskevich 
Date: Wed, 20 Dec 2023 14:04:22 -0800
Subject: [PATCH] [clang/AST] Make it possible to use SwiftAttr in type context

Swift ClangImporter now supports concurrency annotations on imported 
declarations
and their parameters/results, to make it possible to use imported APIs in Swift
safely there has to be a way to annotate individual parameters and result types
with relevant attributes that indicate that e.g. a block is called on a 
particular
actor or it accepts a `Sendable` parameter.

To faciliate that `SwiftAttr` is switched from `InheritableAttr` which is a 
declaration
attribute to `DeclOrTypeAttr`. To support this attribute in type context we 
need access
to its "Attribute" argument which requires `AttributedType` to be extended to 
include
`Attr *` when available instead of just `attr::Kind` otherwise it won't be 
possible to
determine what attribute should be imported.
---
 clang/docs/ReleaseNotes.rst   | 13 
 clang/include/clang/AST/ASTContext.h  |  7 ++
 clang/include/clang/AST/PropertiesBase.td |  1 +
 clang/include/clang/AST/Type.h| 42 +---
 clang/include/clang/AST/TypeProperties.td |  8 ++-
 clang/include/clang/Basic/Attr.td |  2 +-
 clang/include/clang/Basic/AttrDocs.td |  4 +-
 .../clang/Serialization/ASTRecordWriter.h |  2 +
 clang/lib/AST/ASTContext.cpp  | 48 ++---
 clang/lib/AST/ASTDiagnostic.cpp   |  6 +-
 clang/lib/AST/ASTImporter.cpp |  5 +-
 clang/lib/AST/Type.cpp| 20 +-
 clang/lib/AST/TypePrinter.cpp |  9 +++
 clang/lib/Sema/SemaDecl.cpp   |  4 +-
 clang/lib/Sema/SemaDeclObjC.cpp   |  4 +-
 clang/lib/Sema/SemaExpr.cpp   |  3 +-
 clang/lib/Sema/SemaExprObjC.cpp   | 29 +++-
 clang/lib/Sema/SemaObjCProperty.cpp   |  4 +-
 clang/lib/Sema/SemaSwift.cpp  |  7 +-
 clang/lib/Sema/SemaType.cpp   | 67 +--
 clang/lib/Sema/TreeTransform.h|  3 +-
 clang/test/AST/attr-swift_attr.m  | 47 -
 .../test/SemaObjC/validate-attr-swift_attr.m  |  4 ++
 23 files changed, 255 insertions(+), 84 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 1a179e63f902f3..5d4d5b2319688f 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -338,6 +338,19 @@ Removed Compiler Flags
 Attribute Changes in Clang
 --
 
+- The ``swift_attr`` can now be applied to types. To make it possible to use 
imported APIs
+  in Swift safely there has to be a way to annotate individual parameters and 
result types
+  with relevant attributes that indicate that e.g. a block is called on a 
particular actor
+  or it accepts a Sendable or global-actor (i.e. ``@MainActor``) isolated 
parameter.
+
+  For example:
+
+  .. code-block:: objc
+
+ @interface MyService
+   -(void) handle: (void (^ __attribute__((swift_attr("@Sendable"(id)) 
handler;
+ @end
+
 - Clang now disallows more than one ``__attribute__((ownership_returns(class, 
idx)))`` with
   different class names attached to one function.
 
diff --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 07b4e36f3ef05e..4c1455a3e1bbf2 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -1719,8 +1719,15 @@ class ASTContext : public RefCountedBase {
   QualType getInjectedClassNameType(CXXRecordDecl *Decl, QualType TST) const;
 
   QualType getAttributedType(attr::Kind attrKind, QualType modifiedType,
+ QualType equivalentType,
+ const Attr *attr = nullptr) const;
+
+  QualType getAttributedType(const Attr *attr, QualType modifiedType,
  QualType equivalentType) const;
 
+  QualType getAttributedType(NullabilityKind nullability, QualType 
modifiedType,
+ QualType equivalentType);
+
   QualType getBTFTagAttributedType(const BTFTypeTagAttr *BTFAttr,
QualType Wrapped) const;
 
diff --git a/clang/include/clang/AST/PropertiesBase.td 
b/clang/include/clang/AST/PropertiesBase.td
index 3057669e3758b5..5f3a885832e2e4 100644
--- a/clang/include/clang/AST/PropertiesBase.td
+++ b/clang/include/clang/AST/PropertiesBase.td
@@ -76,6 +76,7 @@ def APValue : PropertyType { let PassByReference = 1; }
 def APValueKind : EnumPropertyType<"APValue::ValueKind">;
 def ArraySizeModifier : EnumPropertyType<"ArraySizeModifier">;
 def AttrKind : EnumPropertyType<"attr::Kind">;
+def Attr : PropertyType<"const Attr *">;
 def AutoTypeKeyword : EnumPropertyType;
 def Bool : PropertyType<"bool">;
 

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

2024-10-30 Thread Pavel Yaskevich via cfe-commits

xedin wrote:

@erichkeane friendly ping about this, I replied to your last question wondering 
if it would be okay to land this or should I close since it has been awhile now.

https://github.com/llvm/llvm-project/pull/108631
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2024-10-30 Thread Pavel Yaskevich via cfe-commits

xedin wrote:

@erichkeane I don't think swift_attr is intended in that context but I don't 
see how these changes regress existing uses.

https://github.com/llvm/llvm-project/pull/108631
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2024-10-30 Thread Pavel Yaskevich via cfe-commits

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

>From a66d820647c927dee23498cd12338748f4079688 Mon Sep 17 00:00:00 2001
From: Pavel Yaskevich 
Date: Wed, 20 Dec 2023 14:04:22 -0800
Subject: [PATCH] [clang/AST] Make it possible to use SwiftAttr in type context

Swift ClangImporter now supports concurrency annotations on imported 
declarations
and their parameters/results, to make it possible to use imported APIs in Swift
safely there has to be a way to annotate individual parameters and result types
with relevant attributes that indicate that e.g. a block is called on a 
particular
actor or it accepts a `Sendable` parameter.

To faciliate that `SwiftAttr` is switched from `InheritableAttr` which is a 
declaration
attribute to `DeclOrTypeAttr`. To support this attribute in type context we 
need access
to its "Attribute" argument which requires `AttributedType` to be extended to 
include
`Attr *` when available instead of just `attr::Kind` otherwise it won't be 
possible to
determine what attribute should be imported.
---
 clang/docs/ReleaseNotes.rst   | 13 
 clang/include/clang/AST/ASTContext.h  |  7 ++
 clang/include/clang/AST/PropertiesBase.td |  1 +
 clang/include/clang/AST/Type.h| 42 +---
 clang/include/clang/AST/TypeProperties.td |  8 ++-
 clang/include/clang/Basic/Attr.td |  2 +-
 clang/include/clang/Basic/AttrDocs.td |  4 +-
 .../clang/Serialization/ASTRecordWriter.h |  2 +
 clang/lib/AST/ASTContext.cpp  | 48 ++---
 clang/lib/AST/ASTDiagnostic.cpp   |  6 +-
 clang/lib/AST/ASTImporter.cpp |  5 +-
 clang/lib/AST/Type.cpp| 20 +-
 clang/lib/AST/TypePrinter.cpp |  9 +++
 clang/lib/Sema/SemaDecl.cpp   |  4 +-
 clang/lib/Sema/SemaDeclObjC.cpp   |  4 +-
 clang/lib/Sema/SemaExpr.cpp   |  3 +-
 clang/lib/Sema/SemaExprObjC.cpp   | 29 +++-
 clang/lib/Sema/SemaObjCProperty.cpp   |  4 +-
 clang/lib/Sema/SemaSwift.cpp  |  7 +-
 clang/lib/Sema/SemaType.cpp   | 67 +--
 clang/lib/Sema/TreeTransform.h|  3 +-
 clang/test/AST/attr-swift_attr.m  | 47 -
 .../test/SemaObjC/validate-attr-swift_attr.m  |  4 ++
 23 files changed, 255 insertions(+), 84 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 1a179e63f902f3..5d4d5b2319688f 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -338,6 +338,19 @@ Removed Compiler Flags
 Attribute Changes in Clang
 --
 
+- The ``swift_attr`` can now be applied to types. To make it possible to use 
imported APIs
+  in Swift safely there has to be a way to annotate individual parameters and 
result types
+  with relevant attributes that indicate that e.g. a block is called on a 
particular actor
+  or it accepts a Sendable or global-actor (i.e. ``@MainActor``) isolated 
parameter.
+
+  For example:
+
+  .. code-block:: objc
+
+ @interface MyService
+   -(void) handle: (void (^ __attribute__((swift_attr("@Sendable"(id)) 
handler;
+ @end
+
 - Clang now disallows more than one ``__attribute__((ownership_returns(class, 
idx)))`` with
   different class names attached to one function.
 
diff --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 07b4e36f3ef05e..4c1455a3e1bbf2 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -1719,8 +1719,15 @@ class ASTContext : public RefCountedBase {
   QualType getInjectedClassNameType(CXXRecordDecl *Decl, QualType TST) const;
 
   QualType getAttributedType(attr::Kind attrKind, QualType modifiedType,
+ QualType equivalentType,
+ const Attr *attr = nullptr) const;
+
+  QualType getAttributedType(const Attr *attr, QualType modifiedType,
  QualType equivalentType) const;
 
+  QualType getAttributedType(NullabilityKind nullability, QualType 
modifiedType,
+ QualType equivalentType);
+
   QualType getBTFTagAttributedType(const BTFTypeTagAttr *BTFAttr,
QualType Wrapped) const;
 
diff --git a/clang/include/clang/AST/PropertiesBase.td 
b/clang/include/clang/AST/PropertiesBase.td
index 3057669e3758b5..5f3a885832e2e4 100644
--- a/clang/include/clang/AST/PropertiesBase.td
+++ b/clang/include/clang/AST/PropertiesBase.td
@@ -76,6 +76,7 @@ def APValue : PropertyType { let PassByReference = 1; }
 def APValueKind : EnumPropertyType<"APValue::ValueKind">;
 def ArraySizeModifier : EnumPropertyType<"ArraySizeModifier">;
 def AttrKind : EnumPropertyType<"attr::Kind">;
+def Attr : PropertyType<"const Attr *">;
 def AutoTypeKeyword : EnumPropertyType;
 def Bool : PropertyType<"bool">;
 

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

2024-10-30 Thread Pavel Yaskevich via cfe-commits

xedin wrote:

@erichkeane CI are green, could you please merge since I don't have 
permissions?...

https://github.com/llvm/llvm-project/pull/108631
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2024-10-30 Thread Pavel Yaskevich via cfe-commits

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

>From a66d820647c927dee23498cd12338748f4079688 Mon Sep 17 00:00:00 2001
From: Pavel Yaskevich 
Date: Wed, 20 Dec 2023 14:04:22 -0800
Subject: [PATCH] [clang/AST] Make it possible to use SwiftAttr in type context

Swift ClangImporter now supports concurrency annotations on imported 
declarations
and their parameters/results, to make it possible to use imported APIs in Swift
safely there has to be a way to annotate individual parameters and result types
with relevant attributes that indicate that e.g. a block is called on a 
particular
actor or it accepts a `Sendable` parameter.

To faciliate that `SwiftAttr` is switched from `InheritableAttr` which is a 
declaration
attribute to `DeclOrTypeAttr`. To support this attribute in type context we 
need access
to its "Attribute" argument which requires `AttributedType` to be extended to 
include
`Attr *` when available instead of just `attr::Kind` otherwise it won't be 
possible to
determine what attribute should be imported.
---
 clang/docs/ReleaseNotes.rst   | 13 
 clang/include/clang/AST/ASTContext.h  |  7 ++
 clang/include/clang/AST/PropertiesBase.td |  1 +
 clang/include/clang/AST/Type.h| 42 +---
 clang/include/clang/AST/TypeProperties.td |  8 ++-
 clang/include/clang/Basic/Attr.td |  2 +-
 clang/include/clang/Basic/AttrDocs.td |  4 +-
 .../clang/Serialization/ASTRecordWriter.h |  2 +
 clang/lib/AST/ASTContext.cpp  | 48 ++---
 clang/lib/AST/ASTDiagnostic.cpp   |  6 +-
 clang/lib/AST/ASTImporter.cpp |  5 +-
 clang/lib/AST/Type.cpp| 20 +-
 clang/lib/AST/TypePrinter.cpp |  9 +++
 clang/lib/Sema/SemaDecl.cpp   |  4 +-
 clang/lib/Sema/SemaDeclObjC.cpp   |  4 +-
 clang/lib/Sema/SemaExpr.cpp   |  3 +-
 clang/lib/Sema/SemaExprObjC.cpp   | 29 +++-
 clang/lib/Sema/SemaObjCProperty.cpp   |  4 +-
 clang/lib/Sema/SemaSwift.cpp  |  7 +-
 clang/lib/Sema/SemaType.cpp   | 67 +--
 clang/lib/Sema/TreeTransform.h|  3 +-
 clang/test/AST/attr-swift_attr.m  | 47 -
 .../test/SemaObjC/validate-attr-swift_attr.m  |  4 ++
 23 files changed, 255 insertions(+), 84 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 1a179e63f902f3..5d4d5b2319688f 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -338,6 +338,19 @@ Removed Compiler Flags
 Attribute Changes in Clang
 --
 
+- The ``swift_attr`` can now be applied to types. To make it possible to use 
imported APIs
+  in Swift safely there has to be a way to annotate individual parameters and 
result types
+  with relevant attributes that indicate that e.g. a block is called on a 
particular actor
+  or it accepts a Sendable or global-actor (i.e. ``@MainActor``) isolated 
parameter.
+
+  For example:
+
+  .. code-block:: objc
+
+ @interface MyService
+   -(void) handle: (void (^ __attribute__((swift_attr("@Sendable"(id)) 
handler;
+ @end
+
 - Clang now disallows more than one ``__attribute__((ownership_returns(class, 
idx)))`` with
   different class names attached to one function.
 
diff --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 07b4e36f3ef05e..4c1455a3e1bbf2 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -1719,8 +1719,15 @@ class ASTContext : public RefCountedBase {
   QualType getInjectedClassNameType(CXXRecordDecl *Decl, QualType TST) const;
 
   QualType getAttributedType(attr::Kind attrKind, QualType modifiedType,
+ QualType equivalentType,
+ const Attr *attr = nullptr) const;
+
+  QualType getAttributedType(const Attr *attr, QualType modifiedType,
  QualType equivalentType) const;
 
+  QualType getAttributedType(NullabilityKind nullability, QualType 
modifiedType,
+ QualType equivalentType);
+
   QualType getBTFTagAttributedType(const BTFTypeTagAttr *BTFAttr,
QualType Wrapped) const;
 
diff --git a/clang/include/clang/AST/PropertiesBase.td 
b/clang/include/clang/AST/PropertiesBase.td
index 3057669e3758b5..5f3a885832e2e4 100644
--- a/clang/include/clang/AST/PropertiesBase.td
+++ b/clang/include/clang/AST/PropertiesBase.td
@@ -76,6 +76,7 @@ def APValue : PropertyType { let PassByReference = 1; }
 def APValueKind : EnumPropertyType<"APValue::ValueKind">;
 def ArraySizeModifier : EnumPropertyType<"ArraySizeModifier">;
 def AttrKind : EnumPropertyType<"attr::Kind">;
+def Attr : PropertyType<"const Attr *">;
 def AutoTypeKeyword : EnumPropertyType;
 def Bool : PropertyType<"bool">;
 

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

2024-09-18 Thread Pavel Yaskevich via cfe-commits


@@ -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;

xedin wrote:

Sure!

https://github.com/llvm/llvm-project/pull/108631
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2024-09-26 Thread Pavel Yaskevich via cfe-commits

xedin wrote:

> That being said, one question is whether we actually need type attributes to 
> be propagated in this case for Swift's interop.

I don't think we do, we need swift_attr to help us augment Objective-C APIs to 
make existing frameworks pray well with Swift concurrency. I think C++ 
Interoperability only uses them in limited set of cases which don't involve 
templates.

https://github.com/llvm/llvm-project/pull/108631
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2024-09-26 Thread Pavel Yaskevich via cfe-commits

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

>From c8784f8c9b0d7c66d924736476e7e112a92cf20a Mon Sep 17 00:00:00 2001
From: Pavel Yaskevich 
Date: Wed, 20 Dec 2023 14:04:22 -0800
Subject: [PATCH] [clang/AST] Make it possible to use SwiftAttr in type context

Swift ClangImporter now supports concurrency annotations on imported 
declarations
and their parameters/results, to make it possible to use imported APIs in Swift
safely there has to be a way to annotate individual parameters and result types
with relevant attributes that indicate that e.g. a block is called on a 
particular
actor or it accepts a `Sendable` parameter.

To faciliate that `SwiftAttr` is switched from `InheritableAttr` which is a 
declaration
attribute to `DeclOrTypeAttr`. To support this attribute in type context we 
need access
to its "Attribute" argument which requires `AttributedType` to be extended to 
include
`Attr *` when available instead of just `attr::Kind` otherwise it won't be 
possible to
determine what attribute should be imported.
---
 clang/docs/ReleaseNotes.rst   | 13 
 clang/include/clang/AST/ASTContext.h  |  7 ++
 clang/include/clang/AST/PropertiesBase.td |  1 +
 clang/include/clang/AST/Type.h| 42 +---
 clang/include/clang/AST/TypeProperties.td |  8 ++-
 clang/include/clang/Basic/Attr.td |  2 +-
 clang/include/clang/Basic/AttrDocs.td |  4 +-
 .../clang/Serialization/ASTRecordWriter.h |  2 +
 clang/lib/AST/ASTContext.cpp  | 48 ++---
 clang/lib/AST/ASTDiagnostic.cpp   |  6 +-
 clang/lib/AST/ASTImporter.cpp |  5 +-
 clang/lib/AST/Type.cpp| 20 +-
 clang/lib/AST/TypePrinter.cpp |  9 +++
 clang/lib/Sema/SemaDecl.cpp   |  4 +-
 clang/lib/Sema/SemaDeclObjC.cpp   |  4 +-
 clang/lib/Sema/SemaExpr.cpp   |  3 +-
 clang/lib/Sema/SemaExprObjC.cpp   | 29 +++-
 clang/lib/Sema/SemaObjCProperty.cpp   |  4 +-
 clang/lib/Sema/SemaSwift.cpp  |  7 +-
 clang/lib/Sema/SemaType.cpp   | 67 +--
 clang/lib/Sema/TreeTransform.h|  3 +-
 clang/test/AST/attr-swift_attr.m  | 47 -
 .../test/SemaObjC/validate-attr-swift_attr.m  |  4 ++
 23 files changed, 255 insertions(+), 84 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 14907e7db18de3..1b9baeb2f40543 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -241,6 +241,19 @@ Removed Compiler Flags
 Attribute Changes in Clang
 --
 
+- The ``swift_attr`` can now be applied to types. To make it possible to use 
imported APIs
+  in Swift safely there has to be a way to annotate individual parameters and 
result types
+  with relevant attributes that indicate that e.g. a block is called on a 
particular actor
+  or it accepts a Sendable or global-actor (i.e. ``@MainActor``) isolated 
parameter.
+
+  For example:
+
+  .. code-block:: objc
+
+ @interface MyService
+   -(void) handle: (void (^ __attribute__((swift_attr("@Sendable"(id)) 
handler;
+ @end
+
 - Clang now disallows more than one ``__attribute__((ownership_returns(class, 
idx)))`` with
   different class names attached to one function.
 
diff --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index fbf38ab4da6c8c..4fda4bc82bd920 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -1710,8 +1710,15 @@ class ASTContext : public RefCountedBase {
   QualType getInjectedClassNameType(CXXRecordDecl *Decl, QualType TST) const;
 
   QualType getAttributedType(attr::Kind attrKind, QualType modifiedType,
+ QualType equivalentType,
+ const Attr *attr = nullptr) const;
+
+  QualType getAttributedType(const Attr *attr, QualType modifiedType,
  QualType equivalentType) const;
 
+  QualType getAttributedType(NullabilityKind nullability, QualType 
modifiedType,
+ QualType equivalentType);
+
   QualType getBTFTagAttributedType(const BTFTypeTagAttr *BTFAttr,
QualType Wrapped) const;
 
diff --git a/clang/include/clang/AST/PropertiesBase.td 
b/clang/include/clang/AST/PropertiesBase.td
index 3057669e3758b5..5f3a885832e2e4 100644
--- a/clang/include/clang/AST/PropertiesBase.td
+++ b/clang/include/clang/AST/PropertiesBase.td
@@ -76,6 +76,7 @@ def APValue : PropertyType { let PassByReference = 1; }
 def APValueKind : EnumPropertyType<"APValue::ValueKind">;
 def ArraySizeModifier : EnumPropertyType<"ArraySizeModifier">;
 def AttrKind : EnumPropertyType<"attr::Kind">;
+def Attr : PropertyType<"const Attr *">;
 def AutoTypeKeyword : EnumPropertyType;
 def Bool : PropertyType<"bool">;
 

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

2024-09-26 Thread Pavel Yaskevich via cfe-commits

xedin wrote:

Updated release notes and added block tests requested by @Xazax-hun.

https://github.com/llvm/llvm-project/pull/108631
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2024-09-26 Thread Pavel Yaskevich via cfe-commits


@@ -7147,6 +7147,60 @@ static bool 
HandleWebAssemblyFuncrefAttr(TypeProcessingState &State,
   return false;
 }
 
+static void HandleSwiftAttr(TypeProcessingState &State, TypeAttrLocation TAL,
+QualType &QT, ParsedAttr &PAttr) {
+  if (TAL == TAL_DeclName)
+return;
+
+  Sema &S = State.getSema();
+  auto &D = State.getDeclarator();
+
+  // If the attribute appears in declaration specifiers
+  // it should be handled as a declaration attribute,
+  // unless it's associated with a type or a function
+  // prototype (i.e. appears on a parameter or result type).
+  if (State.isProcessingDeclSpec()) {
+if (!(D.isPrototypeContext() ||
+  D.getContext() == DeclaratorContext::TypeName))
+  return;
+
+if (auto *chunk = D.getInnermostNonParenChunk()) {
+  moveAttrFromListToList(PAttr, State.getCurrentAttributes(),
+ const_cast(chunk)->getAttrs());
+  return;
+}
+  }
+
+  StringRef Str;
+  if (!S.checkStringLiteralArgumentAttr(PAttr, 0, Str)) {
+PAttr.setInvalid();
+return;
+  }
+
+  // If the attribute as attached to a paren move it closer to
+  // the declarator. This can happen in block declarations when
+  // an attribute is placed before `^` i.e. `(__attribute__((...)) ^)`.

xedin wrote:

Done! I remembered why I didn't add that - it required `-fblocks`.

https://github.com/llvm/llvm-project/pull/108631
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2024-09-20 Thread Pavel Yaskevich via cfe-commits


@@ -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;

xedin wrote:

In fact I added that assert to `getAttribute(...)` method on ASTContext already.

https://github.com/llvm/llvm-project/pull/108631
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2024-09-20 Thread Pavel Yaskevich via cfe-commits


@@ -7147,6 +7147,60 @@ static bool 
HandleWebAssemblyFuncrefAttr(TypeProcessingState &State,
   return false;
 }
 
+static void HandleSwiftAttr(TypeProcessingState &State, TypeAttrLocation TAL,
+QualType &QT, ParsedAttr &PAttr) {
+  if (TAL == TAL_DeclName)
+return;
+
+  Sema &S = State.getSema();
+  auto &D = State.getDeclarator();
+
+  // If the attribute appears in declaration specifiers
+  // it should be handled as a declaration attribute,
+  // unless it's associated with a type or a function
+  // prototype (i.e. appears on a parameter or result type).
+  if (State.isProcessingDeclSpec()) {
+if (!(D.isPrototypeContext() ||
+  D.getContext() == DeclaratorContext::TypeName))
+  return;
+
+if (auto *chunk = D.getInnermostNonParenChunk()) {
+  moveAttrFromListToList(PAttr, State.getCurrentAttributes(),
+ const_cast(chunk)->getAttrs());
+  return;
+}
+  }
+
+  StringRef Str;
+  if (!S.checkStringLiteralArgumentAttr(PAttr, 0, Str)) {
+PAttr.setInvalid();
+return;
+  }
+
+  // If the attribute as attached to a paren move it closer to
+  // the declarator. This can happen in block declarations when
+  // an attribute is placed before `^` i.e. `(__attribute__((...)) ^)`.

xedin wrote:

This actually applies more on the Swift side, I have multiple tests for this in 
ClangImporter but I'm not sure how to test this here since it doesn't really 
matter for clang AST where the attribute ends up being located.

https://github.com/llvm/llvm-project/pull/108631
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2024-09-20 Thread Pavel Yaskevich via cfe-commits


@@ -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;

xedin wrote:

✅ 

https://github.com/llvm/llvm-project/pull/108631
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2024-09-20 Thread Pavel Yaskevich via cfe-commits

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

>From bd447428181ec9ab38679625fd3b3b422eb18446 Mon Sep 17 00:00:00 2001
From: Pavel Yaskevich 
Date: Wed, 20 Dec 2023 14:04:22 -0800
Subject: [PATCH] [clang/AST] Make it possible to use SwiftAttr in type context

Swift ClangImporter now supports concurrency annotations on imported 
declarations
and their parameters/results, to make it possible to use imported APIs in Swift
safely there has to be a way to annotate individual parameters and result types
with relevant attributes that indicate that e.g. a block is called on a 
particular
actor or it accepts a `Sendable` parameter.

To faciliate that `SwiftAttr` is switched from `InheritableAttr` which is a 
declaration
attribute to `DeclOrTypeAttr`. To support this attribute in type context we 
need access
to its "Attribute" argument which requires `AttributedType` to be extended to 
include
`Attr *` when available instead of just `attr::Kind` otherwise it won't be 
possible to
determine what attribute should be imported.
---
 clang/include/clang/AST/ASTContext.h  |  7 ++
 clang/include/clang/AST/PropertiesBase.td |  1 +
 clang/include/clang/AST/Type.h| 42 +---
 clang/include/clang/AST/TypeProperties.td |  8 ++-
 clang/include/clang/Basic/Attr.td |  2 +-
 clang/include/clang/Basic/AttrDocs.td |  4 +-
 .../clang/Serialization/ASTRecordWriter.h |  2 +
 clang/lib/AST/ASTContext.cpp  | 51 +++---
 clang/lib/AST/ASTDiagnostic.cpp   |  6 +-
 clang/lib/AST/ASTImporter.cpp |  5 +-
 clang/lib/AST/Type.cpp| 20 +-
 clang/lib/AST/TypePrinter.cpp |  9 +++
 clang/lib/Sema/SemaDecl.cpp   |  4 +-
 clang/lib/Sema/SemaDeclObjC.cpp   |  4 +-
 clang/lib/Sema/SemaExpr.cpp   |  3 +-
 clang/lib/Sema/SemaExprObjC.cpp   | 29 +++-
 clang/lib/Sema/SemaObjCProperty.cpp   |  4 +-
 clang/lib/Sema/SemaSwift.cpp  |  7 +-
 clang/lib/Sema/SemaType.cpp   | 67 +--
 clang/lib/Sema/TreeTransform.h|  3 +-
 clang/test/AST/attr-swift_attr.m  | 31 +
 .../test/SemaObjC/validate-attr-swift_attr.m  |  4 ++
 22 files changed, 229 insertions(+), 84 deletions(-)

diff --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 168bdca3c880b2..f49bb7afce2336 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -1677,8 +1677,15 @@ class ASTContext : public RefCountedBase {
   QualType getInjectedClassNameType(CXXRecordDecl *Decl, QualType TST) const;
 
   QualType getAttributedType(attr::Kind attrKind, QualType modifiedType,
+ QualType equivalentType,
+ const Attr *attr = nullptr) const;
+
+  QualType getAttributedType(const Attr *attr, QualType modifiedType,
  QualType equivalentType) const;
 
+  QualType getAttributedType(NullabilityKind nullability, QualType 
modifiedType,
+ QualType equivalentType);
+
   QualType getBTFTagAttributedType(const BTFTypeTagAttr *BTFAttr,
QualType Wrapped);
 
diff --git a/clang/include/clang/AST/PropertiesBase.td 
b/clang/include/clang/AST/PropertiesBase.td
index 9b934b20cf2559..0d1712a1fe15fd 100644
--- a/clang/include/clang/AST/PropertiesBase.td
+++ b/clang/include/clang/AST/PropertiesBase.td
@@ -76,6 +76,7 @@ def APValue : PropertyType { let PassByReference = 1; }
 def APValueKind : EnumPropertyType<"APValue::ValueKind">;
 def ArraySizeModifier : EnumPropertyType<"ArraySizeModifier">;
 def AttrKind : EnumPropertyType<"attr::Kind">;
+def Attr : PropertyType<"const Attr *">;
 def AutoTypeKeyword : EnumPropertyType;
 def Bool : PropertyType<"bool">;
 def BuiltinTypeKind : EnumPropertyType<"BuiltinType::Kind">;
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index ef36a73716454f..860f5fce150449 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -68,6 +68,7 @@ class ValueDecl;
 class TagDecl;
 class TemplateParameterList;
 class Type;
+class Attr;
 
 enum {
   TypeAlignmentInBits = 4,
@@ -6037,21 +6038,29 @@ 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)
-  : Type(Attributed, canon, equivalent->getDependence()),
-ModifiedType(modified), EquivalentType(equivalent) {
-AttributedTypeBits.AttrKind = attrKind;
-  }
+  : AttributedType(canon, attrKind, nullptr, modified, equivalent) {}
+
+  AttributedType(QualType cano

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

2024-09-20 Thread Pavel Yaskevich via cfe-commits


@@ -8732,6 +8786,11 @@ static void processTypeAttrs(TypeProcessingState &state, 
QualType &type,
 case ParsedAttr::AT_HLSLParamModifier: {
   HandleHLSLParamModifierAttr(state, type, attr, state.getSema());
   attr.setUsedAsTypeAttr();
+   break;
+   }

xedin wrote:

✅ 

https://github.com/llvm/llvm-project/pull/108631
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2024-09-20 Thread Pavel Yaskevich via cfe-commits


@@ -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);

xedin wrote:

✅ 

https://github.com/llvm/llvm-project/pull/108631
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2024-09-20 Thread Pavel Yaskevich via cfe-commits


@@ -7163,7 +7217,8 @@ static QualType 
rebuildAttributedTypeWithoutNullability(ASTContext &Ctx,
   Ctx, Attributed->getModifiedType());
   assert(Modified.getTypePtr() != Attributed->getModifiedType().getTypePtr());
   return Ctx.getAttributedType(Attributed->getAttrKind(), Modified,
-   Attributed->getEquivalentType());
+   Attributed->getEquivalentType(),
+   
 Attributed->getAttr());

xedin wrote:

✅ 

https://github.com/llvm/llvm-project/pull/108631
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2024-09-20 Thread Pavel Yaskevich via cfe-commits

xedin wrote:

I addressed most of the comments. A few points to add:

- I'm not sure what to make of the comment regarding templates if somebody 
could point me to the right direction I can make appropriate changes
- I'd need some guidance regarding release note
- I'd prefer to keep AttributedType changes in this PR since they are integral 
part of the swift_attr change.

https://github.com/llvm/llvm-project/pull/108631
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2024-11-07 Thread Pavel Yaskevich via cfe-commits

xedin wrote:

I think if `noderef` attribute instantiations in your example are considered 
unique when they appear in different spots then we should have two distinct 
attributed types but it sounds like both of `noderef` should have one `Attr *` 
instantiation...

https://github.com/llvm/llvm-project/pull/108631
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2024-09-17 Thread Pavel Yaskevich via cfe-commits


@@ -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);

xedin wrote:

I think adding `attr` to profile is a better approach, I'll look into that.

https://github.com/llvm/llvm-project/pull/108631
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2024-09-17 Thread Pavel Yaskevich via cfe-commits


@@ -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;

xedin wrote:

If I remember correct the `Attr *` is not always there (nullable or something) 
that's why we need both `Attr *` and `attrKind`

https://github.com/llvm/llvm-project/pull/108631
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2024-09-17 Thread Pavel Yaskevich via cfe-commits


@@ -8732,6 +8786,11 @@ static void processTypeAttrs(TypeProcessingState &state, 
QualType &type,
 case ParsedAttr::AT_HLSLParamModifier: {
   HandleHLSLParamModifierAttr(state, type, attr, state.getSema());
   attr.setUsedAsTypeAttr();
+   break;
+   }

xedin wrote:

Oh, it might be tabs vs. spaces :/

https://github.com/llvm/llvm-project/pull/108631
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits