Skip to content

Commit a575283

Browse files
authored
Merge pull request #10106 from rudkx/verify-expressions-have-types
Expect all expressions to have a type after type checking.
2 parents 0c10834 + 692c559 commit a575283

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

lib/AST/ASTVerifier.cpp

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,19 @@ class Verifier : public ASTWalker {
446446
bool shouldVerify(Decl *S) { return true; }
447447

448448
// Default cases for whether we should verify a checked subtree.
449-
bool shouldVerifyChecked(Expr *E) { return !E->getType().isNull(); }
449+
bool shouldVerifyChecked(Expr *E) {
450+
if (!E->getType()) {
451+
// For @objc enums, we serialize the pre-type-checked integer
452+
// literal raw values, and thus when they are deserialized
453+
// they do not have a type on them.
454+
if (!isa<IntegerLiteralExpr>(E)) {
455+
Out << "expression has no type\n";
456+
E->print(Out);
457+
abort();
458+
}
459+
}
460+
return true;
461+
}
450462
bool shouldVerifyChecked(Stmt *S) { return true; }
451463
bool shouldVerifyChecked(Pattern *S) { return S->hasType(); }
452464
bool shouldVerifyChecked(Decl *S) { return true; }
@@ -506,8 +518,9 @@ class Verifier : public ASTWalker {
506518
// Some imported expressions don't have types, even in checked mode.
507519
// TODO: eliminate all these
508520
if (!E->getType()) {
509-
// The raw value of an imported EnumElementDecl doesn't seem to have
510-
// a type for some reason.
521+
// For @objc enums, we serialize the pre-type-checked integer
522+
// literal raw values, and thus when they are deserialized
523+
// they do not have a type on them.
511524
if (!isa<IntegerLiteralExpr>(E)) {
512525
Out << "expression has no type\n";
513526
E->print(Out);

0 commit comments

Comments
 (0)