Can we assert-fail earlier when reading bad PCH files?

Hi,

I've noticed that the compiler assert-fails pretty far down the call stack when reading out-of-date PCH files. Can we assert-fail a bit earlier?

For example, we could change ASTReader::ReadControlBlock to do this:

2267 switch ((ControlRecordTypes)Stream.readRecord(Entry.ID, Record, &Blob)) {
2268 case METADATA: {
2269 assert(Record.size() >= 8 && "malformed control block in module"); // New

Currently we hit an 'index out of bound' assertion in SmallVector when reading stale PCH files.

I can send a patch in if this seems worthwhile.

vedant

We shouldn’t be asserting on out-of-date module files at all, we should be cleanly failing with the “module file is out of date” error code.