#ifndef LLVM_CLANG_TOOLING_COMMONOPTIONSPARSER_H
#define LLVM_CLANG_TOOLING_COMMONOPTIONSPARSER_H
+#include "clang/Tooling/ArgumentsAdjusters.h"
#include "clang/Tooling/CompilationDatabase.h"
#include "llvm/Support/CommandLine.h"
std::vector<std::string> ExtraArgsAfter;
};
+class ArgumentsAdjustingCompilations : public CompilationDatabase {
+public:
+ ArgumentsAdjustingCompilations(
+ std::unique_ptr<CompilationDatabase> Compilations)
+ : Compilations(std::move(Compilations)) {}
+
+ void appendArgumentsAdjuster(ArgumentsAdjuster Adjuster);
+
+ std::vector<CompileCommand>
+ getCompileCommands(StringRef FilePath) const override;
+
+ std::vector<std::string> getAllFiles() const override;
+
+ std::vector<CompileCommand> getAllCompileCommands() const override;
+
+private:
+ std::unique_ptr<CompilationDatabase> Compilations;
+ std::vector<ArgumentsAdjuster> Adjusters;
+
+ std::vector<CompileCommand>
+ adjustCommands(std::vector<CompileCommand> Commands) const;
+};
+
} // namespace tooling
} // namespace clang
//===----------------------------------------------------------------------===//
#include "llvm/Support/CommandLine.h"
-#include "clang/Tooling/ArgumentsAdjusters.h"
#include "clang/Tooling/CommonOptionsParser.h"
#include "clang/Tooling/Tooling.h"
"\tsuffix of a path in the compile command database.\n"
"\n";
-namespace {
-class ArgumentsAdjustingCompilations : public CompilationDatabase {
-public:
- ArgumentsAdjustingCompilations(
- std::unique_ptr<CompilationDatabase> Compilations)
- : Compilations(std::move(Compilations)) {}
-
- void appendArgumentsAdjuster(ArgumentsAdjuster Adjuster) {
- Adjusters.push_back(std::move(Adjuster));
- }
-
- std::vector<CompileCommand>
- getCompileCommands(StringRef FilePath) const override {
- return adjustCommands(Compilations->getCompileCommands(FilePath));
- }
+void ArgumentsAdjustingCompilations::appendArgumentsAdjuster(
+ ArgumentsAdjuster Adjuster) {
+ Adjusters.push_back(std::move(Adjuster));
+}
- std::vector<std::string> getAllFiles() const override {
- return Compilations->getAllFiles();
- }
+std::vector<CompileCommand> ArgumentsAdjustingCompilations::getCompileCommands(
+ StringRef FilePath) const {
+ return adjustCommands(Compilations->getCompileCommands(FilePath));
+}
- std::vector<CompileCommand> getAllCompileCommands() const override {
- return adjustCommands(Compilations->getAllCompileCommands());
- }
+std::vector<std::string>
+ArgumentsAdjustingCompilations::getAllFiles() const {
+ return Compilations->getAllFiles();
+}
-private:
- std::unique_ptr<CompilationDatabase> Compilations;
- std::vector<ArgumentsAdjuster> Adjusters;
+std::vector<CompileCommand>
+ArgumentsAdjustingCompilations::getAllCompileCommands() const {
+ return adjustCommands(Compilations->getAllCompileCommands());
+}
- std::vector<CompileCommand>
- adjustCommands(std::vector<CompileCommand> Commands) const {
- for (CompileCommand &Command : Commands)
- for (const auto &Adjuster : Adjusters)
- Command.CommandLine = Adjuster(Command.CommandLine, Command.Filename);
- return Commands;
- }
-};
-} // namespace
+std::vector<CompileCommand> ArgumentsAdjustingCompilations::adjustCommands(
+ std::vector<CompileCommand> Commands) const {
+ for (CompileCommand &Command : Commands)
+ for (const auto &Adjuster : Adjusters)
+ Command.CommandLine = Adjuster(Command.CommandLine, Command.Filename);
+ return Commands;
+}
CommonOptionsParser::CommonOptionsParser(
int &argc, const char **argv, cl::OptionCategory &Category,