https://github.com/literally-anything updated https://github.com/llvm/llvm-project/pull/180672
>From 8a1a7a1057bb96b177b91bd7ef5bfc3f7a8bd525 Mon Sep 17 00:00:00 2001 From: Hunter Baker <[email protected]> Date: Mon, 9 Feb 2026 22:55:30 -0500 Subject: [PATCH 1/2] [APINotes] Fix fatal error when using Type key on FieldDecl When using a Type key on fields of structs or clases, clang hits a fatal error: "llvm_unreachable("API notes allowed a type on an unknown declaration")". This commit fixes that by adding the missing case to the if statement for FieldDecl. --- clang/lib/Sema/SemaAPINotes.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/clang/lib/Sema/SemaAPINotes.cpp b/clang/lib/Sema/SemaAPINotes.cpp index 059eb0dd767b7..12929895b3789 100644 --- a/clang/lib/Sema/SemaAPINotes.cpp +++ b/clang/lib/Sema/SemaAPINotes.cpp @@ -409,6 +409,12 @@ void Sema::ApplyAPINotesType(Decl *D, StringRef TypeString) { property->getType(), Type)) { property->setType(Type, TypeInfo); } + } else if (auto field = dyn_cast<FieldDecl>(D)) { + if (!checkAPINotesReplacementType(*this, field->getLocation(), + field->getType(), Type)) { + field->setType(Type); + field->setTypeSourceInfo(TypeInfo); + } } else { llvm_unreachable("API notes allowed a type on an unknown declaration"); } >From 2e8222605f89d8afbd24a8eddd44152604ce0795 Mon Sep 17 00:00:00 2001 From: Hunter Baker <[email protected]> Date: Mon, 9 Feb 2026 23:01:31 -0500 Subject: [PATCH 2/2] [APINotes] Add test for Type key struct fields --- clang/test/APINotes/Inputs/Headers/Fields.apinotes | 1 + clang/test/APINotes/Inputs/Headers/Fields.h | 2 ++ clang/test/APINotes/fields.cpp | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/clang/test/APINotes/Inputs/Headers/Fields.apinotes b/clang/test/APINotes/Inputs/Headers/Fields.apinotes index 931da52ba29d1..44545ab8c7d27 100644 --- a/clang/test/APINotes/Inputs/Headers/Fields.apinotes +++ b/clang/test/APINotes/Inputs/Headers/Fields.apinotes @@ -4,6 +4,7 @@ Tags: - Name: IntWrapper Fields: - Name: value + Type: ValueType Availability: none AvailabilityMsg: "oh no" - Name: Outer diff --git a/clang/test/APINotes/Inputs/Headers/Fields.h b/clang/test/APINotes/Inputs/Headers/Fields.h index dbd342da47789..cc2bc5814c00a 100644 --- a/clang/test/APINotes/Inputs/Headers/Fields.h +++ b/clang/test/APINotes/Inputs/Headers/Fields.h @@ -1,3 +1,5 @@ +enum class ValueType {}; + struct IntWrapper { int value; diff --git a/clang/test/APINotes/fields.cpp b/clang/test/APINotes/fields.cpp index 8dea2229b4e0a..1522f098634cd 100644 --- a/clang/test/APINotes/fields.cpp +++ b/clang/test/APINotes/fields.cpp @@ -6,7 +6,7 @@ #include "Fields.h" // CHECK-FIELD: Dumping IntWrapper::value: -// CHECK-FIELD-NEXT: FieldDecl {{.+}} value +// CHECK-FIELD-NEXT: FieldDecl {{.+}} value 'ValueType' // CHECK-FIELD: UnavailableAttr {{.+}} <<invalid sloc>> "oh no" // CHECK-DEEP-FIELD: Dumping Outer::Inner::value: _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
