This patch is the first of two in refactoring Clang's dependency scanning tooling to remove its dependency on clangDriver. It separates Tooling/DependencyScanningTool.cpp from the rest of clangDependencyScanning and moves clangDependencyScanning out of clangTooling into its own library. No functional changes are introduced. The follow-up patch (#169964) will restrict clangDependencyScanning to handling only -cc1 command line inputs and will move all functionality related to handling driver commands into clangTooling. (Tooling/DependencyScanningTool.cpp). This is part of a broader effort to support driver-managed builds for compilations using C++ named modules and/or Clang modules. It is required for linking the dependency scanning tooling against the driver without introducing cyclic dependencies, which would otherwise cause build failures when dynamic linking is enabled. The RFC for this change can be found here: https://discourse.llvm.org/t/rfc-new-clangoptions-library-remove-dependency-on-clangdriver-from-clangfrontend-and-flangfrontend/88773?u=naveen-seth
39 lines
1.3 KiB
C++
39 lines
1.3 KiB
C++
//===- DependencyScanningUtils.cpp - Common Scanning Utilities ------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "clang/DependencyScanning/DependencyScanningUtils.h"
|
|
|
|
using namespace clang;
|
|
using namespace dependencies;
|
|
|
|
TranslationUnitDeps FullDependencyConsumer::takeTranslationUnitDeps() {
|
|
TranslationUnitDeps TU;
|
|
|
|
TU.ID.ContextHash = std::move(ContextHash);
|
|
TU.ID.ModuleName = std::move(ModuleName);
|
|
TU.NamedModuleDeps = std::move(NamedModuleDeps);
|
|
TU.FileDeps = std::move(Dependencies);
|
|
TU.PrebuiltModuleDeps = std::move(PrebuiltModuleDeps);
|
|
TU.VisibleModules = std::move(VisibleModules);
|
|
TU.Commands = std::move(Commands);
|
|
|
|
for (auto &&M : ClangModuleDeps) {
|
|
auto &MD = M.second;
|
|
// TODO: Avoid handleModuleDependency even being called for modules
|
|
// we've already seen.
|
|
if (AlreadySeen.count(M.first))
|
|
continue;
|
|
TU.ModuleGraph.push_back(std::move(MD));
|
|
}
|
|
TU.ClangModuleDeps = std::move(DirectModuleDeps);
|
|
|
|
return TU;
|
|
}
|
|
|
|
CallbackActionController::~CallbackActionController() {}
|