This is an archive of the discontinued LLVM Phabricator instance.

ASTReader: Bypass overridden files when reading PCHs
ClosedPublic

Authored by dexonsmith on Aug 24 2019, 7:36 PM.

Details

Summary

If contents of a file that is part of a PCM are overridden when reading
it, but weren't overridden when the PCM was being built, the ASTReader
will emit an error. Now it creates a separate FileEntry for recovery,
bypassing the overridden content instead of discarding it. The
pre-existing testcase clang/test/PCH/remap-file-from-pch.cpp confirms
that the new recovery method works correctly.

This resolves a long-standing FIXME to avoid hypothetically invalidating
another precompiled module that's already using the overridden contents.

This also removes ContentCache-related API that would be unsafe to use
across CompilerInstances in an implicit modules build. This helps to
unblock us sinking it from SourceManager into FileManager in the future,
which would allow us to delete InMemoryModuleCache.

Diff Detail

Event Timeline

dexonsmith created this revision.Aug 24 2019, 7:36 PM

Missing full context

New diff with full context.

bruno added a comment.Aug 28 2019, 4:56 PM

Nice! Is this something that can be tested for in unittests/Basic/FileManagerTest.cpp?

clang/include/clang/Basic/FileManager.h
338

Does it make sense to return/read from a FileEntryRef here? @arphaman, wdyt?

Added a FileManagerTest and changed FileManager::getBypassFile to use FileEntryRef.

dexonsmith marked 2 inline comments as done.Aug 28 2019, 6:32 PM
dexonsmith added inline comments.
clang/include/clang/Basic/FileManager.h
338

SGTM.

This revision is now accepted and ready to land.Aug 29 2019, 6:54 PM
bruno accepted this revision.Aug 30 2019, 10:22 AM

LGTM!

dexonsmith closed this revision.Aug 30 2019, 3:58 PM
dexonsmith marked an inline comment as done.

r370546.