clang 8.0.0

ArgumentsAdjusters.h
Go to the documentation of this file.
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 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.
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 /// A sequence of command line arguments.
30 using CommandLineArguments = std::vector<std::string>;
31
32 /// 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 using ArgumentsAdjuster = std::function<CommandLineArguments(
37 const CommandLineArguments &, StringRef Filename)>;
38
39 /// Gets an argument adjuster that converts input command line arguments
40 /// to the "syntax check only" variant.
41 ArgumentsAdjuster getClangSyntaxOnlyAdjuster();
42
43 /// Gets an argument adjuster which removes output-related command line
44 /// arguments.
45 ArgumentsAdjuster getClangStripOutputAdjuster();
46
47 /// Gets an argument adjuster which removes dependency-file
48 /// related command line arguments.
49 ArgumentsAdjuster getClangStripDependencyFileAdjuster();
50
51 enum class ArgumentInsertPosition { BEGIN, END };
52
53 /// Gets an argument adjuster which inserts \p Extra arguments in the
54 /// specified position.
55 ArgumentsAdjuster getInsertArgumentAdjuster(const CommandLineArguments &Extra,
56 ArgumentInsertPosition Pos);
57
58 /// Gets an argument adjuster which inserts an \p Extra argument in the
59 /// specified position.
60 ArgumentsAdjuster getInsertArgumentAdjuster(
61 const char *Extra,
62 ArgumentInsertPosition Pos = ArgumentInsertPosition::END);
63
64 /// Gets an argument adjuster which strips plugin related command line
65 /// arguments.
66 ArgumentsAdjuster getStripPluginsAdjuster();
67
68 /// Gets an argument adjuster which adjusts the arguments in sequence
69 /// with the \p First adjuster and then with the \p Second one.
70 ArgumentsAdjuster combineAdjusters(ArgumentsAdjuster First,
71 ArgumentsAdjuster Second);
72
73 } // namespace tooling
74 } // namespace clang
75
76 #endif // LLVM_CLANG_TOOLING_ARGUMENTSADJUSTERS_H
clang::tooling::CommandLineArguments
std::vector< std::string > CommandLineArguments
A sequence of command line arguments.
Definition: ArgumentsAdjusters.h:30
clang::tooling::ArgumentInsertPosition::BEGIN
clang::tooling::getInsertArgumentAdjuster
ArgumentsAdjuster getInsertArgumentAdjuster(const CommandLineArguments &Extra, ArgumentInsertPosition Pos)
Gets an argument adjuster which inserts Extra arguments in the specified position.
Definition: ArgumentsAdjusters.cpp:77
clang::tooling::getClangStripDependencyFileAdjuster
ArgumentsAdjuster getClangStripDependencyFileAdjuster()
Gets an argument adjuster which removes dependency-file related command line arguments.
Definition: ArgumentsAdjusters.cpp:57
clang::tooling::combineAdjusters
ArgumentsAdjuster combineAdjusters(ArgumentsAdjuster First, ArgumentsAdjuster Second)
Gets an argument adjuster which adjusts the arguments in sequence with the First adjuster and then wi...
Definition: ArgumentsAdjusters.cpp:100
LLVM.h
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
clang::ComparisonCategoryType::First
Filename
StringRef Filename
Definition: Format.cpp:1629
clang::tooling::getClangStripOutputAdjuster
ArgumentsAdjuster getClangStripOutputAdjuster()
Gets an argument adjuster which removes output-related command line arguments.
Definition: ArgumentsAdjusters.cpp:39
clang::tooling::ArgumentsAdjuster
std::function< CommandLineArguments(const CommandLineArguments &, StringRef Filename)> ArgumentsAdjuster
A prototype of a command line adjuster.
Definition: ArgumentsAdjusters.h:37
clang::tooling::ArgumentInsertPosition
ArgumentInsertPosition
Definition: ArgumentsAdjusters.h:51
clang::tooling::ArgumentInsertPosition::END
clang
Dataflow Directional Tag Classes.
Definition: CFGReachabilityAnalysis.h:22
clang::tooling::getClangSyntaxOnlyAdjuster
ArgumentsAdjuster getClangSyntaxOnlyAdjuster()
Gets an argument adjuster that converts input command line arguments to the "syntax check only" varia...
Definition: ArgumentsAdjusters.cpp:24
clang::tooling::getStripPluginsAdjuster
ArgumentsAdjuster getStripPluginsAdjuster()
Gets an argument adjuster which strips plugin related command line arguments.
Definition: ArgumentsAdjusters.cpp:111