[PATCH] D107690: [Modules] Do not remove failed modules after the control block phase

Ben Barham via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 6 23:40:16 PDT 2021


bnbarham created this revision.
bnbarham added reviewers: vsapsai, dexonsmith.
Herald added a subscriber: kristof.beyls.
bnbarham requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Reading modules first reads each control block in the chain and then all
AST blocks.

The first phase is intended to find recoverable errors, eg. an out of
date or missing module. If any error occurs during this phase, it is
safe to remove all modules in the chain as no references to them will
exist.

While reading the AST blocks, however, various fields in ASTReader are
updated with references to the module. Removing modules at this point
can cause dangling pointers which can be accessed later. These would be
otherwise harmless, eg. a binary search over `GlobalSLocEntryMap` may
access a failed module that could error, but shouldn't crash.  Do not
remove modules in this phase, regardless of failures.

Since this is the case, it also doesn't make sense to return OutOfDate
during this phase, so remove the two cases where this happens.

When they were originally added these checks would return OutOfDate when
the serialized and current path didn't match up. This is not the same as
the existing check, which is now different since only the name as
written is serialized. This means the OutOfDate condition is really only
checking for an umbrella with a different *name* (assuming it exists in
the base directory). It is also skipped completely for frameworks since
these don't include `Headers/` in the name, causing no file entry to be
found.

Given all this, it seems safe to ignore this case entirely for now.
This makes the handling of an umbrella header/directory the same as
regular headers, which also don't check for differences in the path
caused by VFS.

Resolves rdar://79329355


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107690

Files:
  clang/lib/Serialization/ASTReader.cpp
  clang/test/VFS/module-header-mismatches.m
  clang/test/VFS/umbrella-mismatch.m

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D107690.364937.patch
Type: text/x-patch
Size: 9362 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210807/30275e98/attachment.bin>


More information about the cfe-commits mailing list