• 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 "clang/Basic/LLVM.h"
21 #include "llvm/ADT/StringRef.h"
22 #include <functional>
23 #include <string>
24 #include <vector>
25 
26 namespace clang {
27 namespace tooling {
28 
29 /// \brief A sequence of command line arguments.
30 typedef std::vector<std::string> CommandLineArguments;
31 
32 /// \brief A prototype of a command line adjuster.
33 ///
34 /// Command line argument adjuster is responsible for command line arguments
35 /// modification before the arguments are used to run a frontend action.
36 typedef std::function<CommandLineArguments(
37     const CommandLineArguments &, StringRef Filename)> ArgumentsAdjuster;
38 
39 /// \brief Gets an argument adjuster that converts input command line arguments
40 /// to the "syntax check only" variant.
41 ArgumentsAdjuster getClangSyntaxOnlyAdjuster();
42 
43 /// \brief Gets an argument adjuster which removes output-related command line
44 /// arguments.
45 ArgumentsAdjuster getClangStripOutputAdjuster();
46 
47 enum class ArgumentInsertPosition { BEGIN, END };
48 
49 /// \brief Gets an argument adjuster which inserts \p Extra arguments in the
50 /// specified position.
51 ArgumentsAdjuster getInsertArgumentAdjuster(const CommandLineArguments &Extra,
52                                             ArgumentInsertPosition Pos);
53 
54 /// \brief Gets an argument adjuster which inserts an \p Extra argument in the
55 /// specified position.
56 ArgumentsAdjuster getInsertArgumentAdjuster(
57     const char *Extra,
58     ArgumentInsertPosition Pos = ArgumentInsertPosition::END);
59 
60 /// \brief Gets an argument adjuster which adjusts the arguments in sequence
61 /// with the \p First adjuster and then with the \p Second one.
62 ArgumentsAdjuster combineAdjusters(ArgumentsAdjuster First,
63                                    ArgumentsAdjuster Second);
64 
65 } // namespace tooling
66 } // namespace clang
67 
68 #endif // LLVM_CLANG_TOOLING_ARGUMENTSADJUSTERS_H
69 
70