Lines Matching +full:overlay +full:- +full:relative
1 //===--- PrecompiledPreamble.cpp - Build precompiled preambles --*- C++ -*-===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
11 //===----------------------------------------------------------------------===//
28 #include "llvm/Config/llvm-config.h"
49 #warning "Unknown platform. Defaulting to UNIX-style paths for in-memory PCHs"
59 // so we create an in-memory VFS with just that and overlay it on top.
62 PCHFS->addFile(PCHFilename, 0, std::move(PCHBuffer));
63 IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> Overlay(
65 Overlay->pushOverlay(PCHFS);
66 return Overlay;
74 // spuriously added by '-isystem' (e.g. to suppress warnings from those
106 // (We have some false negatives if PP recovered e.g. <foo> -> "foo")
124 // ...relative to the including file.
128 if (IncludingFile->getDir())
129 NotFoundRelativeTo(IncludingFile->getDir());
131 // ...relative to the search paths.
198 // so it's not intended to be used outside preamble-handling.
204 // crash-recovery testing, which is the only case where the preamble files
212 // that we would never get a race condition in a multi-threaded setting
221 llvm::sys::path::append(TempPath, "preamble-%%%%%%.pch");
223 // Use the same owner-only file permissions as fs::createTemporaryFile().
243 TemporaryFiles::getInstance().addFile(this->FilePath);
263 *FileOS << Buffer->Data;
268 this->HasEmittedPreamblePCH = true;
288 std::unique_ptr<llvm::raw_pwrite_stream> FileOS; // null if in-memory
364 S->File = std::move(File);
369 S->Memory = std::move(Buf);
383 return File->getFilePath();
387 return StringRef(Memory->Data.data(), Memory->Data.size());
390 // Shrink in-memory buffers to fit.
391 // This incurs a copy, but preambles tend to be long-lived.
396 Memory->Data = decltype(Memory->Data)(Memory->Data);
423 FrontendOptions &FrontendOpts = PreambleInvocation->getFrontendOpts();
425 PreambleInvocation->getPreprocessorOpts();
443 std::vector<char> PreambleBytes(MainFileBuffer->getBufferStart(),
444 MainFileBuffer->getBufferStart() +
451 StoreInMemory ? getInMemoryPreamblePath() : Storage->filePath());
465 Clang->setInvocation(std::move(PreambleInvocation));
466 Clang->setDiagnostics(&Diagnostics);
469 if (!Clang->createTarget())
472 if (Clang->getFrontendOpts().Inputs.size() != 1 ||
473 Clang->getFrontendOpts().Inputs[0].getKind().getFormat() !=
475 Clang->getFrontendOpts().Inputs[0].getKind().getLanguage() ==
482 ProcessWarningOptions(Diagnostics, Clang->getDiagnosticOpts(), *VFS);
485 createVFSFromCompilerInvocation(Clang->getInvocation(), Diagnostics, VFS);
488 Clang->setFileManager(new FileManager(Clang->getFileSystemOpts(), VFS));
491 Clang->setSourceManager(
492 new SourceManager(Diagnostics, Clang->getFileManager()));
495 Clang->addDependencyCollector(PreambleDepCollector);
497 Clang->getLangOpts().CompilingPCH = true;
502 MainFileBuffer->getBuffer().slice(0, Bounds.Size), MainFilePath);
515 /*WritePCHFile=*/Storage->getKind() == PCHStorage::Kind::TempFile,
517 if (!Act->BeginSourceFile(*Clang.get(), Clang->getFrontendOpts().Inputs[0]))
520 // Performed after BeginSourceFile to ensure Clang->Preprocessor can be
527 Clang->getPreprocessor().addPPCallbacks(std::move(DelegatedPPCallbacks));
529 Clang->getPreprocessor().addCommentHandler(CommentHandler);
531 Clang->getPreprocessor().addPPCallbacks(
533 MissingFiles, Clang->getPreprocessor().getHeaderSearchInfo(),
534 Clang->getSourceManager()));
536 if (llvm::Error Err = Act->Execute())
542 Act->EndSourceFile();
544 if (!Act->hasEmittedPreamblePCH())
552 SourceManager &SourceMgr = Clang->getSourceManager();
553 for (auto &Filename : PreambleDepCollector->getDependencies()) {
554 auto MaybeFile = Clang->getFileManager().getOptionalFileRef(Filename);
575 Storage->shrink();
586 switch (Storage->getKind()) {
588 return Storage->memoryContents().size();
591 if (llvm::sys::fs::file_size(Storage->filePath(), Result))
613 PreambleInvocation->getPreprocessorOpts();
617 // the main-file buffer within the precompiled preamble to fit the
624 // The preamble has not changed. We may be able to re-use the precompiled
652 PreambleFileHash::createForMemoryBuffer(RB.second->getMemBufferRef());
670 if (OverridenFileBuffer->second != F.second)
685 // This file was remapped; check whether the newly-mapped file
687 if (Overridden->second != F.second)
704 // consider the preamble out-of-date.
706 if (Status->isRegularFile())
736 assert(this->Storage != nullptr);
799 if (VFS == RealFS || VFS->exists(PCHPath))
801 auto Buf = RealFS->getBufferForFile(PCHPath);
809 // We have a slight inconsistency here -- we're using the VFS to
814 // For in-memory preamble, we have to provide a VFS overlay that makes it
841 return "build-preamble.error";