Skip to content

Commit 363b504

Browse files
committed
Skip _ var decls in VarScopeVisitor
Signed-off-by: Anna Rift <[email protected]>
1 parent c554c9b commit 363b504

File tree

3 files changed

+12
-1308
lines changed

3 files changed

+12
-1308
lines changed

frontend/lib/resolution/VarScopeVisitor.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -454,19 +454,18 @@ void VarScopeVisitor::exit(const NamedDecl* ast, RV& rv) {
454454
// is there an analysis that does need to handle loop indices?
455455
if (!isLoopIndex(ast)) {
456456
if (auto vld = ast->toVarLikeDecl()) {
457-
const AstNode* astForDeclProps;
458-
459457
const AstNode* parent;
460458
const AstNode* initExpr;
461459
QualifiedType initType;
462460
Qualifier intentOrKind;
463461
bool isFormal;
464462

465463
auto maybeOuterTuple = outermostContainingTuple();
466-
if (const TupleDecl* outerTuple =
464+
if (vld->name() == USTR("_") && maybeOuterTuple) {
465+
// Skip _ ident in tuple
466+
} else if (const TupleDecl* outerTuple =
467467
(maybeOuterTuple ? maybeOuterTuple->toTupleDecl() : nullptr)) {
468-
astForDeclProps = outerTuple;
469-
468+
parent = parsing::parentAst(context, outerTuple);
470469
initExpr = outerTuple->initExpression();
471470
auto parentInitExpr = tupleInitExprsStack.back();
472471
if (parentInitExpr) {
@@ -480,19 +479,20 @@ void VarScopeVisitor::exit(const NamedDecl* ast, RV& rv) {
480479
parentInitTupleType->elementType(indexWithinContainingTuple(ast));
481480
}
482481
intentOrKind = (Qualifier)outerTuple->intentOrKind();
483-
} else {
484-
astForDeclProps = vld;
482+
isFormal = outerTuple->isFormal() || outerTuple->isVarArgFormal() || outerTuple->isTupleDeclFormal();
485483

484+
handleDeclaration(vld, parent, initExpr, initType, intentOrKind, isFormal,
485+
rv);
486+
} else {
487+
parent = parsing::parentAst(context, vld);
486488
initExpr = vld->initExpression();
487489
initType = initExpr ? rv.byAst(initExpr).type() : QualifiedType();
488490
intentOrKind = vld->storageKind();
489-
}
490-
parent = parsing::parentAst(context, astForDeclProps);
491-
isFormal =
492-
astForDeclProps->isFormal() || astForDeclProps->isVarArgFormal();
491+
isFormal = vld->isFormal() || vld->isVarArgFormal();
493492

494-
handleDeclaration(vld, parent, initExpr, initType, intentOrKind, isFormal,
493+
handleDeclaration(vld, parent, initExpr, initType, intentOrKind, isFormal,
495494
rv);
495+
}
496496
}
497497
}
498498

frontend/lib/resolution/copy-elision.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -387,8 +387,6 @@ void FindElidedCopies::handleDeclaration(const VarLikeDecl* ast,
387387
// for (int i = 0; i < tupleExprInit->numActuals(); i++) {
388388
// auto actual = tupleExprInit->actual(i);
389389
// if (actual->isTuple()) {
390-
// // processSingleDeclHelper(ast, actual, QualifiedType(),
391-
// // isFormal, intentOrKind, rv);
392390
// handleDeclaration(ast, parent, actual, QualifiedType(), intentOrKind,
393391
// isFormal, rv);
394392
// } else {
@@ -398,7 +396,6 @@ void FindElidedCopies::handleDeclaration(const VarLikeDecl* ast,
398396
// if (rv.hasId(lhsVarId) && rv.hasId(rhsVarId)) {
399397
// if (lhsType.type() && lhsType.type()->isTupleType()) {
400398
// const TupleType* ttype = lhsType.type()->toTupleType();
401-
// CHPL_ASSERT(ttype->numElements() == tupleExprInit->numActuals());
402399
// QualifiedType lhsEltType = ttype->elementType(i);
403400

404401
// QualifiedType rhsType = rv.byId(rhsVarId).type();

0 commit comments

Comments
 (0)