Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clang/include/clang/Frontend/CompilerInstance.h
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,7 @@ class CompilerInstance : public ModuleLoader {

std::pair<std::shared_ptr<llvm::cas::ObjectStore>,
std::shared_ptr<llvm::cas::ActionCache>>
createCASDatabases();
getOrCreateCASDatabases();
};

} // end namespace clang
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Frontend/CompileJobCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ std::optional<int> CompileJobCache::initialize(CompilerInstance &Clang) {
if (!CacheCompileJob)
return std::nullopt;

std::tie(CAS, Cache) = Clang.createCASDatabases();
std::tie(CAS, Cache) = Clang.getOrCreateCASDatabases();
if (!CAS || !Cache)
return 1; // Exit with error!

Expand Down
10 changes: 7 additions & 3 deletions clang/lib/Frontend/CompilerInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,10 @@ void CompilerInstance::createVirtualFileSystem(
DiagnosticsEngine Diags(DiagnosticIDs::create(), DiagOpts, DC,
/*ShouldOwnClient=*/false);

std::tie(CAS, ActionCache) =
getInvocation().getCASOpts().getOrCreateDatabases(
Diags, /*CreateEmptyCASOnFailure=*/false);

VFS = createVFSFromCompilerInvocation(getInvocation(), Diags,
std::move(BaseFS), CAS);
// FIXME: Should this go into createVFSFromCompilerInvocation?
Expand Down Expand Up @@ -970,7 +974,7 @@ llvm::vfs::OutputBackend &CompilerInstance::getOrCreateOutputManager() {

std::pair<std::shared_ptr<llvm::cas::ObjectStore>,
std::shared_ptr<llvm::cas::ActionCache>>
CompilerInstance::createCASDatabases() {
CompilerInstance::getOrCreateCASDatabases() {
// Create a new CAS databases from the CompilerInvocation. Future calls to
// createFileManager() will use the same CAS.
std::tie(CAS, ActionCache) =
Expand All @@ -982,13 +986,13 @@ CompilerInstance::createCASDatabases() {

llvm::cas::ObjectStore &CompilerInstance::getOrCreateObjectStore() {
if (!CAS)
createCASDatabases();
getOrCreateCASDatabases();
return *CAS;
}

llvm::cas::ActionCache &CompilerInstance::getOrCreateActionCache() {
if (!ActionCache)
createCASDatabases();
getOrCreateCASDatabases();
return *ActionCache;
}

Expand Down
3 changes: 0 additions & 3 deletions clang/lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1536,9 +1536,6 @@ createBaseFS(const FileSystemOptions &FSOpts, const FrontendOptions &FEOpts,
const CASOptions &CASOpts, DiagnosticsEngine &Diags,
IntrusiveRefCntPtr<llvm::vfs::FileSystem> BaseFS,
std::shared_ptr<llvm::cas::ObjectStore> OverrideCAS) {
if (!OverrideCAS)
return BaseFS;

if (FSOpts.CASFileSystemRootID.empty() && FEOpts.CASIncludeTreeID.empty())
return BaseFS;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,10 +282,11 @@ void dependencies::addReversePrefixMappingFileSystem(
llvm::PrefixMapper ReverseMapper;
ReverseMapper.addInverseRange(PrefixMapper.getMappings());
ReverseMapper.sort();
std::unique_ptr<llvm::vfs::FileSystem> FS =
IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS =
llvm::vfs::createPrefixMappingFileSystem(
std::move(ReverseMapper), &ScanInstance.getVirtualFileSystem());

ScanInstance.setVirtualFileSystem(FS);
ScanInstance.getFileManager().setVirtualFileSystem(std::move(FS));
}

Expand Down
2 changes: 1 addition & 1 deletion clang/test/CAS/output-path-error.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@
// RUN: cat %t/output.txt | FileCheck %s --check-prefix=ERROR

// CACHE-MISS: remark: compile job cache miss
// ERROR: fatal error: CAS missing expected root-id
// ERROR: fatal error: CAS filesystem cannot be initialized from root-id 'llvmcas://{{.*}}': cannot get reference to root FS