[clang] [clang] Add clang::preferred_type attribute for bitfields (PR #69104)

Vlad Serebrennikov via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 20 12:43:09 PDT 2023


================
@@ -5910,6 +5910,51 @@ static void handleBuiltinAliasAttr(Sema &S, Decl *D,
   D->addAttr(::new (S.Context) BuiltinAliasAttr(S.Context, AL, Ident));
 }
 
+static void handlePreferredTypeAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
+  if (!AL.hasParsedType()) {
+    S.Diag(AL.getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1;
+    return;
+  }
+
+  TypeSourceInfo *ParmTSI = nullptr;
+  QualType QT = S.GetTypeFromParser(AL.getTypeArg(), &ParmTSI);
+  QT->getAsTagDecl()->setCompleteDefinitionRequired();
----------------
Endilll wrote:

I've changed this so that `preferred_type` accepts only complete types. We can lift this up later if it's too restrictive. I just don't want to deal with consequences of incomplete types in this PR.

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


More information about the cfe-commits mailing list