[PATCH] D37474: [PCH] Allow VFS to be used for tests that generate PCH files

Cameron via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 5 06:52:02 PDT 2017


cameron314 created this revision.
Herald added a subscriber: mgorny.

When using a virtual file-system (VFS) and a preamble file (PCH) is generated, it is generated on-disk in the real file-system instead of in the VFS (which I guess makes sense, since the VFS is read-only). However, when subsequently reading the generated PCH, the frontend passes through the VFS it has been given -- resulting in an error and a failed parse (since the VFS doesn't contain the PCH; the real filesystem does).

This patch fixes that by detecting when a VFS is being used for a parse that needs to work with a PCH file, and creating an overlay VFS that includes the real file-system underneath. Since the PCH is hard-coded to always be on the real file-system, I believe this is the cleanest approach.

This allows tests to be written which make use of both PCH files and a VFS, like the one I've included here.

Note: This was originally part of the code to test the bug fixed in https://reviews.llvm.org/D20338, but while languishing in review it has since been fixed by somebody else in https://reviews.llvm.org/D27810. However, I feel it's still important to be able to test the frontend preamble code while at the same time making use of a VFS, so I've rebased that part of the patch (and my test to go with it).


https://reviews.llvm.org/D37474

Files:
  lib/Frontend/ASTUnit.cpp
  unittests/Frontend/CMakeLists.txt
  unittests/Frontend/PchPreambleTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37474.113850.patch
Type: text/x-patch
Size: 8061 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170905/8e940ded/attachment-0001.bin>


More information about the cfe-commits mailing list