Skip to content

Expect all expressions to have a type after type checking. #10106

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 5, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions lib/AST/ASTVerifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,19 @@ class Verifier : public ASTWalker {
bool shouldVerify(Decl *S) { return true; }

// Default cases for whether we should verify a checked subtree.
bool shouldVerifyChecked(Expr *E) { return !E->getType().isNull(); }
bool shouldVerifyChecked(Expr *E) {
if (!E->getType()) {
// For @objc enums, we serialize the pre-type-checked integer
// literal raw values, and thus when they are deserialized
// they do not have a type on them.
if (!isa<IntegerLiteralExpr>(E)) {
Out << "expression has no type\n";
E->print(Out);
abort();
}
}
return true;
}
bool shouldVerifyChecked(Stmt *S) { return true; }
bool shouldVerifyChecked(Pattern *S) { return S->hasType(); }
bool shouldVerifyChecked(Decl *S) { return true; }
Expand Down Expand Up @@ -506,8 +518,9 @@ class Verifier : public ASTWalker {
// Some imported expressions don't have types, even in checked mode.
// TODO: eliminate all these
if (!E->getType()) {
// The raw value of an imported EnumElementDecl doesn't seem to have
// a type for some reason.
// For @objc enums, we serialize the pre-type-checked integer
// literal raw values, and thus when they are deserialized
// they do not have a type on them.
if (!isa<IntegerLiteralExpr>(E)) {
Out << "expression has no type\n";
E->print(Out);
Expand Down