• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===--- ArgumentsAdjusters.h - Command line arguments adjuster -*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file declares typedef 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.
14 //
15 //===----------------------------------------------------------------------===//
16 
17 #ifndef LLVM_CLANG_TOOLING_ARGUMENTSADJUSTERS_H
18 #define LLVM_CLANG_TOOLING_ARGUMENTSADJUSTERS_H
19 
20 #include <functional>
21 #include <string>
22 #include <vector>
23 
24 namespace clang {
25 namespace tooling {
26 
27 /// \brief A sequence of command line arguments.
28 typedef std::vector<std::string> CommandLineArguments;
29 
30 /// \brief A prototype of a command line adjuster.
31 ///
32 /// Command line argument adjuster is responsible for command line arguments
33 /// modification before the arguments are used to run a frontend action.
34 typedef std::function<CommandLineArguments(const CommandLineArguments &)>
35     ArgumentsAdjuster;
36 
37 /// \brief Gets an argument adjuster that converts input command line arguments
38 /// to the "syntax check only" variant.
39 ArgumentsAdjuster getClangSyntaxOnlyAdjuster();
40 
41 /// \brief Gets an argument adjuster which removes output-related command line
42 /// arguments.
43 ArgumentsAdjuster getClangStripOutputAdjuster();
44 
45 enum class ArgumentInsertPosition { BEGIN, END };
46 
47 /// \brief Gets an argument adjuster which inserts \p Extra arguments in the
48 /// specified position.
49 ArgumentsAdjuster getInsertArgumentAdjuster(const CommandLineArguments &Extra,
50                                             ArgumentInsertPosition Pos);
51 
52 /// \brief Gets an argument adjuster which inserts an \p Extra argument in the
53 /// specified position.
54 ArgumentsAdjuster getInsertArgumentAdjuster(
55     const char *Extra,
56     ArgumentInsertPosition Pos = ArgumentInsertPosition::END);
57 
58 /// \brief Gets an argument adjuster which adjusts the arguments in sequence
59 /// with the \p First adjuster and then with the \p Second one.
60 ArgumentsAdjuster combineAdjusters(ArgumentsAdjuster First,
61                                    ArgumentsAdjuster Second);
62 
63 } // namespace tooling
64 } // namespace clang
65 
66 #endif // LLVM_CLANG_TOOLING_ARGUMENTSADJUSTERS_H
67 
68