[clang] [clang][sema]`no address_space attribute found at the expected location!` assertion fail (PR #216348)

Shengxin Pei via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 19 01:10:26 PDT 2026


================
@@ -6343,11 +6343,17 @@ namespace {
   };
 } // end anonymous namespace
 
-static void
-fillDependentAddressSpaceTypeLoc(DependentAddressSpaceTypeLoc DASTL,
-                                 const ParsedAttributesView &Attrs) {
-  for (const ParsedAttr &AL : Attrs) {
-    if (AL.getKind() == ParsedAttr::AT_AddressSpace) {
+static void fillDependentAddressSpaceTypeLoc(
+    DependentAddressSpaceTypeLoc DASTL,
+    ArrayRef<const ParsedAttributesView *> AttrLists) {
+  for (const ParsedAttributesView *Attrs : AttrLists) {
+    for (const ParsedAttr &AL : *Attrs) {
+      if (AL.getKind() != ParsedAttr::AT_AddressSpace)
+        continue;
+      // Skip an attribute that did not produce a type: one diagnosed as
+      // invalid, or one whose argument is missing or is not an expression.
+      if (AL.isInvalid() || AL.getNumArgs() != 1 || !AL.isArgExpr(0))
+        continue;
----------------
TPPPP72 wrote:

So why we need these? Before, we assert when `AL.getKind() == ParserAttr::AT_AddressSpace` we can certainly get a valid one, right?

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


More information about the cfe-commits mailing list