[clang] [clang] Sequence C++20 Parenthesized List Init (PR #83476)

Shafik Yaghmour via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 29 13:52:22 PST 2024


================
@@ -17615,31 +17615,28 @@ class SequenceChecker : public ConstEvaluatedExprVisitor<SequenceChecker> {
       return VisitExpr(CCE);
 
     // In C++11, list initializations are sequenced.
-    SmallVector<SequenceTree::Seq, 32> Elts;
-    SequenceTree::Seq Parent = Region;
-    for (CXXConstructExpr::const_arg_iterator I = CCE->arg_begin(),
-                                              E = CCE->arg_end();
-         I != E; ++I) {
-      Region = Tree.allocate(Parent);
-      Elts.push_back(Region);
-      Visit(*I);
-    }
-
-    // Forget that the initializers are sequenced.
-    Region = Parent;
-    for (unsigned I = 0; I < Elts.size(); ++I)
-      Tree.merge(Elts[I]);
+    SequenceExpressionsInOrder({CCE->getArgs(), CCE->getNumArgs()});
----------------
shafik wrote:

I took me a bit of checking to convince myself this was doing the right thing. It might be nice to refactor `CXXConstructExpr` to have an a member that does the same as `ILE->inits()` and returns an `ArrayRef`. It looks like do similar things to create an `ArrayRef` in other places as well but probably should be a second PR.

Maybe change this to `llvm::ArrayRef(CCE->getArgs(), CCE->getNumArgs())` to make it more explicit for now.

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


More information about the cfe-commits mailing list