Skip to content

Commit 10c8f78

Browse files
committed
[clang][deps] Move SingleCommandCompilationDatabase to a header
This makes `SingleCommandCompilationDatabase` reusable.
1 parent 5c8c24d commit 10c8f78

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,24 @@ namespace dependencies {
3030

3131
class DependencyScanningWorkerFilesystem;
3232

33+
/// Compilation database that holds and reports a single compile command.
34+
class SingleCommandCompilationDatabase : public CompilationDatabase {
35+
CompileCommand Command;
36+
37+
public:
38+
SingleCommandCompilationDatabase(CompileCommand Cmd)
39+
: Command(std::move(Cmd)) {}
40+
41+
std::vector<CompileCommand>
42+
getCompileCommands(StringRef FilePath) const override {
43+
return {Command};
44+
}
45+
46+
std::vector<CompileCommand> getAllCompileCommands() const override {
47+
return {Command};
48+
}
49+
};
50+
3351
class DependencyConsumer {
3452
public:
3553
virtual ~DependencyConsumer() {}

clang/tools/clang-scan-deps/ClangScanDeps.cpp

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -201,24 +201,6 @@ llvm::cl::opt<bool> Verbose("v", llvm::cl::Optional,
201201

202202
} // end anonymous namespace
203203

204-
class SingleCommandCompilationDatabase : public tooling::CompilationDatabase {
205-
public:
206-
SingleCommandCompilationDatabase(tooling::CompileCommand Cmd)
207-
: Command(std::move(Cmd)) {}
208-
209-
std::vector<tooling::CompileCommand>
210-
getCompileCommands(StringRef FilePath) const override {
211-
return {Command};
212-
}
213-
214-
std::vector<tooling::CompileCommand> getAllCompileCommands() const override {
215-
return {Command};
216-
}
217-
218-
private:
219-
tooling::CompileCommand Command;
220-
};
221-
222204
/// Takes the result of a dependency scan and prints error / dependency files
223205
/// based on the result.
224206
///

0 commit comments

Comments
 (0)