[clang] [clang][nullability] allow _Nonnull etc on nullable class types (PR #82705)

Sam McCall via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 11 06:55:16 PDT 2024


================
@@ -5955,6 +5955,20 @@ static void handleBuiltinAliasAttr(Sema &S, Decl *D,
   D->addAttr(::new (S.Context) BuiltinAliasAttr(S.Context, AL, Ident));
 }
 
+static void handleNullableTypeAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
+  if (AL.isUsedAsTypeAttr())
+    return;
+
+  if (auto *CRD = dyn_cast<CXXRecordDecl>(D);
+      !D || !(CRD->isClass() || CRD->isStruct())) {
----------------
sam-mccall wrote:

Oops, this was supposed to be `!CRD`! Fixed & will add a testcase.

> Struct as the Subject in Attr.td 

Yeah, unfortunately that doesn't seem to work with attributes that can also appear on types :-(

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


More information about the cfe-commits mailing list