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
13 changes: 10 additions & 3 deletions clang/include/clang/Frontend/CompilerInstance.h
Original file line number Diff line number Diff line change
Expand Up @@ -839,16 +839,23 @@ class CompilerInstance : public ModuleLoader {
class ThreadSafeCloneConfig {
IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS;
DiagnosticConsumer &DiagConsumer;
std::shared_ptr<ModuleDependencyCollector> ModuleDepCollector;

public:
ThreadSafeCloneConfig(IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS,
DiagnosticConsumer &DiagConsumer)
: VFS(std::move(VFS)), DiagConsumer(DiagConsumer) {
ThreadSafeCloneConfig(
IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS,
DiagnosticConsumer &DiagConsumer,
std::shared_ptr<ModuleDependencyCollector> ModuleDepCollector = nullptr)
: VFS(std::move(VFS)), DiagConsumer(DiagConsumer),
ModuleDepCollector(std::move(ModuleDepCollector)) {
assert(this->VFS && "Clone config requires non-null VFS");
}

IntrusiveRefCntPtr<llvm::vfs::FileSystem> getVFS() const { return VFS; }
DiagnosticConsumer &getDiagConsumer() const { return DiagConsumer; }
std::shared_ptr<ModuleDependencyCollector> getModuleDepCollector() const {
return ModuleDepCollector;
}
};

private:
Expand Down
12 changes: 8 additions & 4 deletions clang/lib/Frontend/CompilerInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1257,10 +1257,14 @@ std::unique_ptr<CompilerInstance> CompilerInstance::cloneForModuleCompileImpl(
Instance.GetDependencyDirectives =
GetDependencyDirectives->cloneFor(Instance.getFileManager());

// If we're collecting module dependencies, we need to share a collector
// between all of the module CompilerInstances. Other than that, we don't
// want to produce any dependency output from the module build.
Instance.setModuleDepCollector(getModuleDepCollector());
if (ThreadSafeConfig) {
Instance.setModuleDepCollector(ThreadSafeConfig->getModuleDepCollector());
} else {
// If we're collecting module dependencies, we need to share a collector
// between all of the module CompilerInstances. Other than that, we don't
// want to produce any dependency output from the module build.
Instance.setModuleDepCollector(getModuleDepCollector());
}
Inv.getDependencyOutputOpts() = DependencyOutputOptions();

return InstancePtr;
Expand Down
Loading