During explicit modular build, PCM files are typically specified via the -fmodule-file=<path> command-line option. Early during the compilation, Clang uses the ASTReader to read their contents and caches the result so that the module isn't loaded implicitly later on. A listener is attached to the ASTReader to collect names of the modules read from the PCM files. However, if the PCM has already been loaded previously via PCH:
- the ASTReader doesn't do anything for the second time,
- the listener is not invoked at all,
- the module load result is not cached,
- the compilation fails when attempting to load the module implicitly later on.
This patch solves this problem by attaching the listener to the ASTReader for PCH reading as well.
Why drop the <name>= argument? Isn't it better to keep that information, rather than forcing the reader to crack open the file to know what's inside?