Skip to content

Commit e86c7ef

Browse files
committed
[clang][deps] Stop using tooling::ToolAction
1 parent 30705c5 commit e86c7ef

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#include "clang/Tooling/DependencyScanning/DependencyScanningService.h"
2525
#include "clang/Tooling/DependencyScanning/InProcessModuleCache.h"
2626
#include "clang/Tooling/DependencyScanning/ModuleDepCollector.h"
27-
#include "clang/Tooling/Tooling.h"
2827
#include "llvm/ADT/IntrusiveRefCntPtr.h"
2928
#include "llvm/Support/Allocator.h"
3029
#include "llvm/Support/Error.h"
@@ -376,7 +375,7 @@ class ScanningDependencyDirectivesGetter : public DependencyDirectivesGetter {
376375

377376
/// A clang tool that runs the preprocessor in a mode that's optimized for
378377
/// dependency scanning for the given compiler invocation.
379-
class DependencyScanningAction : public tooling::ToolAction {
378+
class DependencyScanningAction {
380379
public:
381380
DependencyScanningAction(
382381
DependencyScanningService &Service, StringRef WorkingDirectory,
@@ -390,7 +389,7 @@ class DependencyScanningAction : public tooling::ToolAction {
390389
bool runInvocation(std::shared_ptr<CompilerInvocation> Invocation,
391390
FileManager *DriverFileMgr,
392391
std::shared_ptr<PCHContainerOperations> PCHContainerOps,
393-
DiagnosticConsumer *DiagConsumer) override {
392+
DiagnosticConsumer *DiagConsumer) {
394393
// Make a deep copy of the original Clang invocation.
395394
CompilerInvocation OriginalInvocation(*Invocation);
396395
// Restore the value of DisableFree, which may be modified by Tooling.
@@ -716,11 +715,19 @@ static bool createAndRunToolInvocation(
716715

717716
// Save executable path before providing CommandLine to ToolInvocation
718717
std::string Executable = CommandLine[0];
719-
ToolInvocation Invocation(std::move(CommandLine), &Action, &FM,
720-
PCHContainerOps);
721-
Invocation.setDiagnosticConsumer(Diags.getClient());
722-
Invocation.setDiagnosticOptions(&Diags.getDiagnosticOptions());
723-
if (!Invocation.run())
718+
719+
llvm::opt::ArgStringList Argv;
720+
for (const std::string &Str : ArrayRef(CommandLine).drop_front())
721+
Argv.push_back(Str.c_str());
722+
723+
auto Invocation = std::make_shared<CompilerInvocation>();
724+
if (!CompilerInvocation::CreateFromArgs(*Invocation, Argv, Diags)) {
725+
// FIXME: Should we just go on like cc1_main does?
726+
return false;
727+
}
728+
729+
if (!Action.runInvocation(std::move(Invocation), &FM, PCHContainerOps,
730+
Diags.getClient()))
724731
return false;
725732

726733
std::vector<std::string> Args = Action.takeLastCC1Arguments();

0 commit comments

Comments
 (0)