1 //===- ArgumentsAdjusters.h - Command line arguments adjuster ---*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file declares type ArgumentsAdjuster and functions to create several
11 // useful argument adjusters.
12 // ArgumentsAdjusters modify command line arguments obtained from a compilation
13 // database before they are used to run a frontend action.
15 //===----------------------------------------------------------------------===//
17 #ifndef LLVM_CLANG_TOOLING_ARGUMENTSADJUSTERS_H
18 #define LLVM_CLANG_TOOLING_ARGUMENTSADJUSTERS_H
20 #include "clang/Basic/LLVM.h"
21 #include "llvm/ADT/StringRef.h"
29 /// A sequence of command line arguments.
30 using CommandLineArguments = std::vector<std::string>;
32 /// A prototype of a command line adjuster.
34 /// Command line argument adjuster is responsible for command line arguments
35 /// modification before the arguments are used to run a frontend action.
36 using ArgumentsAdjuster = std::function<CommandLineArguments(
37 const CommandLineArguments &, StringRef Filename)>;
39 /// Gets an argument adjuster that converts input command line arguments
40 /// to the "syntax check only" variant.
41 ArgumentsAdjuster getClangSyntaxOnlyAdjuster();
43 /// Gets an argument adjuster which removes output-related command line
45 ArgumentsAdjuster getClangStripOutputAdjuster();
47 /// Gets an argument adjuster which removes dependency-file
48 /// related command line arguments.
49 ArgumentsAdjuster getClangStripDependencyFileAdjuster();
51 enum class ArgumentInsertPosition { BEGIN, END };
53 /// Gets an argument adjuster which inserts \p Extra arguments in the
54 /// specified position.
55 ArgumentsAdjuster getInsertArgumentAdjuster(const CommandLineArguments &Extra,
56 ArgumentInsertPosition Pos);
58 /// Gets an argument adjuster which inserts an \p Extra argument in the
59 /// specified position.
60 ArgumentsAdjuster getInsertArgumentAdjuster(
62 ArgumentInsertPosition Pos = ArgumentInsertPosition::END);
64 /// Gets an argument adjuster which adjusts the arguments in sequence
65 /// with the \p First adjuster and then with the \p Second one.
66 ArgumentsAdjuster combineAdjusters(ArgumentsAdjuster First,
67 ArgumentsAdjuster Second);
69 } // namespace tooling
72 #endif // LLVM_CLANG_TOOLING_ARGUMENTSADJUSTERS_H