Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:37:12

0001 //===- ArgumentsAdjusters.h - Command line arguments adjuster ---*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 // This file declares type ArgumentsAdjuster and functions to create several
0010 // useful argument adjusters.
0011 // ArgumentsAdjusters modify command line arguments obtained from a compilation
0012 // database before they are used to run a frontend action.
0013 //
0014 //===----------------------------------------------------------------------===//
0015 
0016 #ifndef LLVM_CLANG_TOOLING_ARGUMENTSADJUSTERS_H
0017 #define LLVM_CLANG_TOOLING_ARGUMENTSADJUSTERS_H
0018 
0019 #include "clang/Basic/LLVM.h"
0020 #include "llvm/ADT/StringRef.h"
0021 #include <functional>
0022 #include <string>
0023 #include <vector>
0024 
0025 namespace clang {
0026 namespace tooling {
0027 
0028 /// A sequence of command line arguments.
0029 using CommandLineArguments = std::vector<std::string>;
0030 
0031 /// A prototype of a command line adjuster.
0032 ///
0033 /// Command line argument adjuster is responsible for command line arguments
0034 /// modification before the arguments are used to run a frontend action.
0035 using ArgumentsAdjuster = std::function<CommandLineArguments(
0036     const CommandLineArguments &, StringRef Filename)>;
0037 
0038 /// Gets an argument adjuster that converts input command line arguments
0039 /// to the "syntax check only" variant.
0040 ArgumentsAdjuster getClangSyntaxOnlyAdjuster();
0041 
0042 /// Gets an argument adjuster which removes output-related command line
0043 /// arguments.
0044 ArgumentsAdjuster getClangStripOutputAdjuster();
0045 
0046 /// Gets an argument adjuster which removes dependency-file
0047 /// related command line arguments.
0048 ArgumentsAdjuster getClangStripDependencyFileAdjuster();
0049 
0050 enum class ArgumentInsertPosition { BEGIN, END };
0051 
0052 /// Gets an argument adjuster which inserts \p Extra arguments in the
0053 /// specified position.
0054 ArgumentsAdjuster getInsertArgumentAdjuster(const CommandLineArguments &Extra,
0055                                             ArgumentInsertPosition Pos);
0056 
0057 /// Gets an argument adjuster which inserts an \p Extra argument in the
0058 /// specified position.
0059 ArgumentsAdjuster getInsertArgumentAdjuster(
0060     const char *Extra,
0061     ArgumentInsertPosition Pos = ArgumentInsertPosition::END);
0062 
0063 /// Gets an argument adjuster which strips plugin related command line
0064 /// arguments.
0065 ArgumentsAdjuster getStripPluginsAdjuster();
0066 
0067 /// Gets an argument adjuster which adjusts the arguments in sequence
0068 /// with the \p First adjuster and then with the \p Second one.
0069 ArgumentsAdjuster combineAdjusters(ArgumentsAdjuster First,
0070                                    ArgumentsAdjuster Second);
0071 
0072 } // namespace tooling
0073 } // namespace clang
0074 
0075 #endif // LLVM_CLANG_TOOLING_ARGUMENTSADJUSTERS_H