clang  14.0.0git
ArgumentsAdjusters.h
Go to the documentation of this file.
1 //===- ArgumentsAdjusters.h - Command line arguments adjuster ---*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file declares type ArgumentsAdjuster and functions to create several
10 // useful argument adjusters.
11 // ArgumentsAdjusters modify command line arguments obtained from a compilation
12 // database before they are used to run a frontend action.
13 //
14 //===----------------------------------------------------------------------===//
15 
16 #ifndef LLVM_CLANG_TOOLING_ARGUMENTSADJUSTERS_H
17 #define LLVM_CLANG_TOOLING_ARGUMENTSADJUSTERS_H
18 
19 #include "clang/Basic/LLVM.h"
20 #include "llvm/ADT/StringRef.h"
21 #include <functional>
22 #include <string>
23 #include <vector>
24 
25 namespace clang {
26 namespace tooling {
27 
28 /// A sequence of command line arguments.
29 using CommandLineArguments = std::vector<std::string>;
30 
31 /// A prototype of a command line adjuster.
32 ///
33 /// Command line argument adjuster is responsible for command line arguments
34 /// modification before the arguments are used to run a frontend action.
35 using ArgumentsAdjuster = std::function<CommandLineArguments(
36  const CommandLineArguments &, StringRef Filename)>;
37 
38 /// Gets an argument adjuster that converts input command line arguments
39 /// to the "syntax check only" variant.
41 
42 /// Gets an argument adjuster which removes output-related command line
43 /// arguments.
45 
46 /// Gets an argument adjuster which removes dependency-file
47 /// related command line arguments.
49 
51 
52 /// Gets an argument adjuster which inserts \p Extra arguments in the
53 /// specified position.
56 
57 /// Gets an argument adjuster which inserts an \p Extra argument in the
58 /// specified position.
60  const char *Extra,
62 
63 /// Gets an argument adjuster which strips plugin related command line
64 /// arguments.
66 
67 /// Gets an argument adjuster which adjusts the arguments in sequence
68 /// with the \p First adjuster and then with the \p Second one.
70  ArgumentsAdjuster Second);
71 
72 } // namespace tooling
73 } // namespace clang
74 
75 #endif // LLVM_CLANG_TOOLING_ARGUMENTSADJUSTERS_H
clang::tooling::ArgumentsAdjuster
std::function< CommandLineArguments(const CommandLineArguments &, StringRef Filename)> ArgumentsAdjuster
A prototype of a command line adjuster.
Definition: ArgumentsAdjusters.h:36
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:118
Filename
StringRef Filename
Definition: Format.cpp:2333
clang::tooling::getClangStripOutputAdjuster
ArgumentsAdjuster getClangStripOutputAdjuster()
Gets an argument adjuster which removes output-related command line arguments.
Definition: ArgumentsAdjusters.cpp:71
clang::tooling::CommandLineArguments
std::vector< std::string > CommandLineArguments
A sequence of command line arguments.
Definition: ArgumentsAdjusters.h:29
clang::tooling::ArgumentInsertPosition::END
@ END
clang::tooling::ArgumentInsertPosition::BEGIN
@ BEGIN
clang::tooling::getStripPluginsAdjuster
ArgumentsAdjuster getStripPluginsAdjuster()
Gets an argument adjuster which strips plugin related command line arguments.
Definition: ArgumentsAdjusters.cpp:152
LLVM.h
clang::tooling::ArgumentInsertPosition
ArgumentInsertPosition
Definition: ArgumentsAdjusters.h:50
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:141
clang::tooling::getClangSyntaxOnlyAdjuster
ArgumentsAdjuster getClangSyntaxOnlyAdjuster()
Gets an argument adjuster that converts input command line arguments to the "syntax check only" varia...
Definition: ArgumentsAdjusters.cpp:35
clang
Definition: CalledOnceCheck.h:17
clang::tooling::getClangStripDependencyFileAdjuster
ArgumentsAdjuster getClangStripDependencyFileAdjuster()
Gets an argument adjuster which removes dependency-file related command line arguments.
Definition: ArgumentsAdjusters.cpp:89