[PATCH] D155895: Anonymous unions should be transparent wrt `[[clang::trivial_abi]]`.

Ɓukasz Anforowicz via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 21 15:37:21 PDT 2023


lukasza marked 5 inline comments as done.
lukasza added inline comments.


================
Comment at: clang/lib/Sema/SemaDeclCXX.cpp:10325
 
-  for (const auto *FD : RD.fields()) {
-    // Ill-formed if the field is an ObjectiveC pointer or of a type that is
-    // non-trivial for the purpose of calls.
-    QualType FT = FD->getType();
-    if (FT.getObjCLifetime() == Qualifiers::OCL_Weak) {
-      PrintDiagAndRemoveAttr(4);
-      return;
-    }
-
-    if (const auto *RT = FT->getBaseElementTypeUnsafe()->getAs<RecordType>())
-      if (!RT->isDependentType() &&
-          !cast<CXXRecordDecl>(RT->getDecl())->canPassInRegisters()) {
-        PrintDiagAndRemoveAttr(5);
+  std::queue<const RecordDecl *> RecordsWithFieldsToCheck;
+  RecordsWithFieldsToCheck.push(&RD);
----------------
gribozavr2 wrote:
> It looks like we don't need to visit the fields in a specific order. If that's the case, please use SmallVector and pop_back_val. (See AnalyzeImplicitConversions for an example of a typical worklist algorithm.)
There is no strong requirement to visit the fields in a specific order.  It seemed nice to report the first field in source order that causes trouble (rather than reporting an deterministically arbitrary field).  OTOH, using `SmallVector` will indeed result in simpler code.

Done?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D155895/new/

https://reviews.llvm.org/D155895



More information about the cfe-commits mailing list