[PATCH] D39842: Allow to store precompiled preambles in memory.

Ilya Biryukov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 14 07:06:44 PST 2017


ilya-biryukov added inline comments.


================
Comment at: lib/Frontend/ASTUnit.cpp:1028
+    IntrusiveRefCntPtr<vfs::FileSystem> OldVFS = VFS;
+    Preamble->AddImplicitPreamble(*CCInvocation, /*ref*/ VFS,
+                                  OverrideMainBuffer.get());
----------------
klimek wrote:
> Since when are we using the /*ref*/ annotation?
Oh, sorry, that's my thing. Slipped into this change.
Removed those.


================
Comment at: lib/Frontend/PrecompiledPreamble.cpp:206
+  std::unique_ptr<std::string> Storage;
+  if (InMemStorage) {
+    OS = llvm::make_unique<llvm::raw_string_ostream>(*InMemStorage);
----------------
klimek wrote:
> It looks like we should pass in the output stream, not the storage?
We're not actually using the `Storage` variable, it's a leftover from previous versions. Removed it.

Or did you mean that we should pass in the output stream directly to `PrecompilePreambleAction`'s constructor?


================
Comment at: lib/Frontend/PrecompiledPreamble.cpp:490
   PreprocessorOpts.DisablePCHValidation = true;
+  if (Storage.getKind() == PCHStorage::Kind::TempFile) {
+    const TempPCHFile &PCHFile = Storage.asFile();
----------------
klimek wrote:
> This looks a bit like we should push it into the PCHStorage.
I've extracted a function here to make the code read simpler.
However, I placed it directly into the `PrecompiledPreamble` instead of `PCHStorage` to keep `PCHStorage` responsible for just one thing: managing the `variant`-like union.


https://reviews.llvm.org/D39842





More information about the cfe-commits mailing list