Skip to content

Commit 2e82367

Browse files
committed
[AST] Enforce that TupleExprs and ParenExprs dont have param flags
Tuple and paren types may still have parameter type flags in certain cases, but they should never make it into expressions.
1 parent 77e6c08 commit 2e82367

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

lib/AST/ASTVerifier.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,6 +1136,7 @@ class Verifier : public ASTWalker {
11361136
}
11371137

11381138
void verifyChecked(TupleExpr *E) {
1139+
PrettyStackTraceExpr debugStack(Ctx, "verifying TupleExpr", E);
11391140
const TupleType *exprTy = E->getType()->castTo<TupleType>();
11401141
for_each(exprTy->getElements().begin(), exprTy->getElements().end(),
11411142
E->getElements().begin(),
@@ -1148,8 +1149,14 @@ class Verifier : public ASTWalker {
11481149
Out << elt->getType() << "\n";
11491150
abort();
11501151
}
1152+
if (!field.getParameterFlags().isNone()) {
1153+
Out << "TupleExpr has non-empty parameter flags?\n";
1154+
Out << "sub expr: \n";
1155+
elt->dump(Out);
1156+
Out << "\n";
1157+
abort();
1158+
}
11511159
});
1152-
// FIXME: Check all the variadic elements.
11531160
verifyCheckedBase(E);
11541161
}
11551162

@@ -1970,10 +1977,15 @@ class Verifier : public ASTWalker {
19701977

19711978
void verifyChecked(ParenExpr *E) {
19721979
PrettyStackTraceExpr debugStack(Ctx, "verifying ParenExpr", E);
1973-
if (!isa<ParenType>(E->getType().getPointer())) {
1980+
auto ty = dyn_cast<ParenType>(E->getType().getPointer());
1981+
if (!ty) {
19741982
Out << "ParenExpr not of ParenType\n";
19751983
abort();
19761984
}
1985+
if (!ty->getParameterFlags().isNone()) {
1986+
Out << "ParenExpr has non-empty parameter flags?\n";
1987+
abort();
1988+
}
19771989
verifyCheckedBase(E);
19781990
}
19791991

0 commit comments

Comments
 (0)