jfb accepted this revision.
jfb added a comment.
This revision is now accepted and ready to land.

A few nits, but this is good otherwise!



================
Comment at: clang/lib/Sema/SemaInit.cpp:1013
 
-  auto *ParentRD =
-      Entity.getParent()->getType()->castAs<RecordType>()->getDecl();
-  if (CXXRecordDecl *CXXRD = dyn_cast<CXXRecordDecl>(ParentRD))
-    if (CXXRD->getNumBases())
-      return false;
+  // Allows elide brace initialization for aggregates with empty base
+  if (Entity.getKind() == InitializedEntity::EK_Base) {
----------------
"Allow eliding brace initialization".

Also, period at the end of the sentence.



================
Comment at: clang/lib/Sema/SemaInit.cpp:1018
+    if (CXXRecordDecl *CXXRD = dyn_cast<CXXRecordDecl>(ParentRD)) {
+      if (CXXRD->getNumBases() == 1) {
+        return ParentRD->field_begin() == ParentRD->field_end();
----------------
Multiple empty bases isn't a common thing, right? I don't think so, but would 
rather check.


================
Comment at: clang/lib/Sema/SemaInit.cpp:1025
 
-  auto FieldIt = ParentRD->field_begin();
-  assert(FieldIt != ParentRD->field_end() &&
-         "no fields but have initializer for member?");
-  return ++FieldIt == ParentRD->field_end();
+  // Allows elide brace initilization for aggregates with one member
+  if (Entity.getKind() == InitializedEntity::EK_Member) {
----------------
Same here.


================
Comment at: clang/test/SemaCXX/aggregate-initialization.cpp:183
+  OnionBaseClass<int, 3> u = {1, 2, 3};
+  OnionBaseClass<int, 3> t = {{{1, 2, 3}}};
+
----------------
Haha I like the name! 🧅😭


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100057

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
  • [PATCH] D1000... Hana Dusíková via Phabricator via cfe-commits
    • [PATCH] ... Michael Schellenberger Costa via Phabricator via cfe-commits
    • [PATCH] ... Hana Dusíková via Phabricator via cfe-commits
    • [PATCH] ... Roman Lebedev via Phabricator via cfe-commits
    • [PATCH] ... Hana Dusíková via Phabricator via cfe-commits
    • [PATCH] ... JF Bastien via Phabricator via cfe-commits
    • [PATCH] ... Hana Dusíková via Phabricator via cfe-commits
    • [PATCH] ... Hana Dusíková via Phabricator via cfe-commits
    • [PATCH] ... Louis Dionne via Phabricator via cfe-commits
    • [PATCH] ... Richard Smith - zygoloid via Phabricator via cfe-commits
    • [PATCH] ... Hana Dusíková via Phabricator via cfe-commits
    • [PATCH] ... Aaron Ballman via Phabricator via cfe-commits
    • [PATCH] ... Aaron Ballman via Phabricator via cfe-commits

Reply via email to