[clang] [clang] Fix comma location tracking inside ParenListExpr. (PR #199411)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 23 06:34:50 PDT 2026


================
@@ -4958,33 +4958,42 @@ SourceLocation DesignatedInitUpdateExpr::getEndLoc() const {
 }
 
 ParenListExpr::ParenListExpr(SourceLocation LParenLoc, ArrayRef<Expr *> Exprs,
-                             SourceLocation RParenLoc)
+                             SourceLocation RParenLoc,
+                             ArrayRef<SourceLocation> CommaLocs)
     : Expr(ParenListExprClass, QualType(), VK_PRValue, OK_Ordinary),
-      LParenLoc(LParenLoc), RParenLoc(RParenLoc) {
+      LParenLoc(LParenLoc), RParenLoc(RParenLoc), NumCommas(CommaLocs.size()) {
+  assert((CommaLocs.empty() || CommaLocs.size() + 1 == Exprs.size()) &&
----------------
erichkeane wrote:

I kinda disagree, we SHOULD make sure we fill them in with 'invalid' locations, if only for AST fidelity.  In the case of the importer, I'd expect that will later fill it in with the 'correct' locations anyway, correct/  Empty source locations are cheap.

I think the 'default' argument here should go away, and we should require the comma locs all the time, and force all callers to give us the comma locs, even if they have to fill it with invalid.

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


More information about the cfe-commits mailing list