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
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class DependencyScanningWorker {
/// \returns false if clang errors occurred (with diagnostics reported to
/// \c DiagConsumer), true otherwise.
bool computeDependencies(
StringRef WorkingDirectory, const std::vector<std::string> &CommandLine,
StringRef WorkingDirectory, ArrayRef<std::string> CommandLine,
DependencyConsumer &DepConsumer, DependencyActionController &Controller,
DiagnosticConsumer &DiagConsumer,
std::optional<llvm::MemoryBufferRef> TUBuffer = std::nullopt);
Expand All @@ -111,7 +111,7 @@ class DependencyScanningWorker {
/// \returns A \c StringError with the diagnostic output if clang errors
/// occurred, success otherwise.
llvm::Error computeDependencies(
StringRef WorkingDirectory, const std::vector<std::string> &CommandLine,
StringRef WorkingDirectory, ArrayRef<std::string> CommandLine,
DependencyConsumer &Consumer, DependencyActionController &Controller,
std::optional<llvm::MemoryBufferRef> TUBuffer = std::nullopt);

Expand All @@ -125,7 +125,7 @@ class DependencyScanningWorker {
/// @param CommandLine The commandline used for the scan.
/// @return Error if the initializaiton fails.
llvm::Error initializeCompilerInstanceWithContextOrError(
StringRef CWD, const std::vector<std::string> &CommandLine);
StringRef CWD, ArrayRef<std::string> CommandLine);

/// @brief Performaces dependency scanning for the module whose name is
/// specified.
Expand All @@ -147,9 +147,9 @@ class DependencyScanningWorker {
/// three methods return a flag to indicate if the call is successful.
/// The initialization function asks the client for a DiagnosticsConsumer
/// that it direct the diagnostics to.
bool initializeCompilerInstanceWithContext(
StringRef CWD, const std::vector<std::string> &CommandLine,
DiagnosticConsumer *DC = nullptr);
bool initializeCompilerInstanceWithContext(StringRef CWD,
ArrayRef<std::string> CommandLine,
DiagnosticConsumer *DC = nullptr);
bool
computeDependenciesByNameWithContext(StringRef ModuleName,
DependencyConsumer &Consumer,
Expand All @@ -172,7 +172,7 @@ class DependencyScanningWorker {
/// Actually carries out the scan. If \c OverlayFS is provided, it must be
/// based on top of DepFS.
bool scanDependencies(
StringRef WorkingDirectory, const std::vector<std::string> &CommandLine,
StringRef WorkingDirectory, ArrayRef<std::string> CommandLine,
DependencyConsumer &Consumer, DependencyActionController &Controller,
DiagnosticConsumer &DC,
IntrusiveRefCntPtr<llvm::vfs::FileSystem> OverlayFS = nullptr);
Expand Down
13 changes: 7 additions & 6 deletions clang/include/clang/Tooling/DependencyScanningTool.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class DependencyScanningTool {
/// \returns A \c StringError with the diagnostic output if clang errors
/// occurred, dependency file contents otherwise.
llvm::Expected<std::string>
getDependencyFile(const std::vector<std::string> &CommandLine, StringRef CWD);
getDependencyFile(ArrayRef<std::string> CommandLine, StringRef CWD);

/// Collect the module dependency in P1689 format for C++20 named modules.
///
Expand Down Expand Up @@ -92,7 +92,7 @@ class DependencyScanningTool {
/// occurred, \c TranslationUnitDeps otherwise.
llvm::Expected<dependencies::TranslationUnitDeps>
getTranslationUnitDependencies(
const std::vector<std::string> &CommandLine, StringRef CWD,
ArrayRef<std::string> CommandLine, StringRef CWD,
const llvm::DenseSet<dependencies::ModuleID> &AlreadySeen,
dependencies::LookupModuleOutputCallback LookupModuleOutput,
std::optional<llvm::MemoryBufferRef> TUBuffer = std::nullopt);
Expand All @@ -104,8 +104,8 @@ class DependencyScanningTool {
/// CompilerInstanceWithContext. We are keeping it here so that it is easier
/// to coordinate with Swift and C-API changes.
llvm::Expected<dependencies::TranslationUnitDeps> getModuleDependencies(
StringRef ModuleName, const std::vector<std::string> &CommandLine,
StringRef CWD, const llvm::DenseSet<dependencies::ModuleID> &AlreadySeen,
StringRef ModuleName, ArrayRef<std::string> CommandLine, StringRef CWD,
const llvm::DenseSet<dependencies::ModuleID> &AlreadySeen,
dependencies::LookupModuleOutputCallback LookupModuleOutput);

/// The following three methods provide a new interface to perform
Expand All @@ -119,8 +119,9 @@ class DependencyScanningTool {
/// @param CWD The current working directory used during the scan.
/// @param CommandLine The commandline used for the scan.
/// @return Error if the initializaiton fails.
llvm::Error initializeCompilerInstanceWithContext(
StringRef CWD, const std::vector<std::string> &CommandLine);
llvm::Error
initializeCompilerInstanceWithContext(StringRef CWD,
ArrayRef<std::string> CommandLine);

/// @brief Computes the dependeny for the module named ModuleName.
/// @param ModuleName The name of the module for which this method computes
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/DependencyScanning/DependencyScannerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,7 @@ bool CompilerInstanceWithContext::computeDependencies(
// file. In this case, we call BeginSourceFile to initialize.
std::unique_ptr<FrontendAction> Action =
std::make_unique<PreprocessOnlyAction>();
auto InputFile = CI.getFrontendOpts().Inputs.begin();
auto *InputFile = CI.getFrontendOpts().Inputs.begin();
bool ActionBeginSucceeded = Action->BeginSourceFile(CI, *InputFile);
assert(ActionBeginSucceeded && "Action BeginSourceFile must succeed");
(void)ActionBeginSucceeded;
Expand Down
22 changes: 10 additions & 12 deletions clang/lib/DependencyScanning/DependencyScanningWorker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ DependencyScanningWorker::~DependencyScanningWorker() = default;
DependencyActionController::~DependencyActionController() = default;

llvm::Error DependencyScanningWorker::computeDependencies(
StringRef WorkingDirectory, const std::vector<std::string> &CommandLine,
StringRef WorkingDirectory, ArrayRef<std::string> CommandLine,
DependencyConsumer &Consumer, DependencyActionController &Controller,
std::optional<llvm::MemoryBufferRef> TUBuffer) {
// Capture the emitted diagnostics and report them to the client
Expand Down Expand Up @@ -71,8 +71,7 @@ static bool forEachDriverJob(
}

static bool createAndRunToolInvocation(
const std::vector<std::string> &CommandLine,
DependencyScanningAction &Action,
ArrayRef<std::string> CommandLine, DependencyScanningAction &Action,
IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS,
std::shared_ptr<clang::PCHContainerOperations> &PCHContainerOps,
DiagnosticsEngine &Diags) {
Expand All @@ -86,7 +85,7 @@ static bool createAndRunToolInvocation(
}

bool DependencyScanningWorker::scanDependencies(
StringRef WorkingDirectory, const std::vector<std::string> &CommandLine,
StringRef WorkingDirectory, ArrayRef<std::string> CommandLine,
DependencyConsumer &Consumer, DependencyActionController &Controller,
DiagnosticConsumer &DC,
IntrusiveRefCntPtr<llvm::vfs::FileSystem> OverlayFS) {
Expand Down Expand Up @@ -151,24 +150,24 @@ bool DependencyScanningWorker::scanDependencies(
}

bool DependencyScanningWorker::computeDependencies(
StringRef WorkingDirectory, const std::vector<std::string> &CommandLine,
StringRef WorkingDirectory, ArrayRef<std::string> CommandLine,
DependencyConsumer &Consumer, DependencyActionController &Controller,
DiagnosticConsumer &DC, std::optional<llvm::MemoryBufferRef> TUBuffer) {
if (TUBuffer) {
auto [FinalFS, FinalCommandLine] = initVFSForTUBufferScanning(
DepFS, CommandLine, WorkingDirectory, *TUBuffer);
return scanDependencies(WorkingDirectory, FinalCommandLine, Consumer,
Controller, DC, FinalFS);
} else {
DepFS->setCurrentWorkingDirectory(WorkingDirectory);
return scanDependencies(WorkingDirectory, CommandLine, Consumer, Controller,
DC);
}

DepFS->setCurrentWorkingDirectory(WorkingDirectory);
return scanDependencies(WorkingDirectory, CommandLine, Consumer, Controller,
DC);
}

llvm::Error
DependencyScanningWorker::initializeCompilerInstanceWithContextOrError(
StringRef CWD, const std::vector<std::string> &CommandLine) {
StringRef CWD, ArrayRef<std::string> CommandLine) {
bool Success = initializeCompilerInstanceWithContext(CWD, CommandLine);
return CIWithContext->handleReturnStatus(Success);
}
Expand All @@ -189,8 +188,7 @@ DependencyScanningWorker::finalizeCompilerInstanceWithContextOrError() {
}

bool DependencyScanningWorker::initializeCompilerInstanceWithContext(
StringRef CWD, const std::vector<std::string> &CommandLine,
DiagnosticConsumer *DC) {
StringRef CWD, ArrayRef<std::string> CommandLine, DiagnosticConsumer *DC) {
CIWithContext =
std::make_unique<CompilerInstanceWithContext>(*this, CWD, CommandLine);
return CIWithContext->initialize(DC);
Expand Down
13 changes: 7 additions & 6 deletions clang/lib/Tooling/DependencyScanningTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,9 @@ class MakeDependencyPrinterConsumer : public DependencyConsumer {
};
} // anonymous namespace

llvm::Expected<std::string> DependencyScanningTool::getDependencyFile(
const std::vector<std::string> &CommandLine, StringRef CWD) {
llvm::Expected<std::string>
DependencyScanningTool::getDependencyFile(ArrayRef<std::string> CommandLine,
StringRef CWD) {
MakeDependencyPrinterConsumer Consumer;
CallbackActionController Controller(nullptr);
auto Result =
Expand Down Expand Up @@ -141,7 +142,7 @@ llvm::Expected<P1689Rule> DependencyScanningTool::getP1689ModuleDependencyFile(

llvm::Expected<TranslationUnitDeps>
DependencyScanningTool::getTranslationUnitDependencies(
const std::vector<std::string> &CommandLine, StringRef CWD,
ArrayRef<std::string> CommandLine, StringRef CWD,
const llvm::DenseSet<ModuleID> &AlreadySeen,
LookupModuleOutputCallback LookupModuleOutput,
std::optional<llvm::MemoryBufferRef> TUBuffer) {
Expand All @@ -157,8 +158,8 @@ DependencyScanningTool::getTranslationUnitDependencies(

llvm::Expected<TranslationUnitDeps>
DependencyScanningTool::getModuleDependencies(
StringRef ModuleName, const std::vector<std::string> &CommandLine,
StringRef CWD, const llvm::DenseSet<ModuleID> &AlreadySeen,
StringRef ModuleName, ArrayRef<std::string> CommandLine, StringRef CWD,
const llvm::DenseSet<ModuleID> &AlreadySeen,
LookupModuleOutputCallback LookupModuleOutput) {
FullDependencyConsumer Consumer(AlreadySeen);
CallbackActionController Controller(LookupModuleOutput);
Expand All @@ -179,7 +180,7 @@ DependencyScanningTool::getModuleDependencies(
}

llvm::Error DependencyScanningTool::initializeCompilerInstanceWithContext(
StringRef CWD, const std::vector<std::string> &CommandLine) {
StringRef CWD, ArrayRef<std::string> CommandLine) {
return Worker.initializeCompilerInstanceWithContextOrError(CWD, CommandLine);
}

Expand Down
Loading