ArgumentsAdjusters.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- ArgumentsAdjusters.h - Command line arguments adjuster ---*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. //
  14. // This file declares type ArgumentsAdjuster and functions to create several
  15. // useful argument adjusters.
  16. // ArgumentsAdjusters modify command line arguments obtained from a compilation
  17. // database before they are used to run a frontend action.
  18. //
  19. //===----------------------------------------------------------------------===//
  20. #ifndef LLVM_CLANG_TOOLING_ARGUMENTSADJUSTERS_H
  21. #define LLVM_CLANG_TOOLING_ARGUMENTSADJUSTERS_H
  22. #include "clang/Basic/LLVM.h"
  23. #include "llvm/ADT/StringRef.h"
  24. #include <functional>
  25. #include <string>
  26. #include <vector>
  27. namespace clang {
  28. namespace tooling {
  29. /// A sequence of command line arguments.
  30. using CommandLineArguments = std::vector<std::string>;
  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. /// Gets an argument adjuster that converts input command line arguments
  38. /// to the "syntax check only" variant.
  39. ArgumentsAdjuster getClangSyntaxOnlyAdjuster();
  40. /// Gets an argument adjuster which removes output-related command line
  41. /// arguments.
  42. ArgumentsAdjuster getClangStripOutputAdjuster();
  43. /// Gets an argument adjuster which removes dependency-file
  44. /// related command line arguments.
  45. ArgumentsAdjuster getClangStripDependencyFileAdjuster();
  46. enum class ArgumentInsertPosition { BEGIN, END };
  47. /// Gets an argument adjuster which inserts \p Extra arguments in the
  48. /// specified position.
  49. ArgumentsAdjuster getInsertArgumentAdjuster(const CommandLineArguments &Extra,
  50. ArgumentInsertPosition Pos);
  51. /// Gets an argument adjuster which inserts an \p Extra argument in the
  52. /// specified position.
  53. ArgumentsAdjuster getInsertArgumentAdjuster(
  54. const char *Extra,
  55. ArgumentInsertPosition Pos = ArgumentInsertPosition::END);
  56. /// Gets an argument adjuster which strips plugin related command line
  57. /// arguments.
  58. ArgumentsAdjuster getStripPluginsAdjuster();
  59. /// Gets an argument adjuster which adjusts the arguments in sequence
  60. /// with the \p First adjuster and then with the \p Second one.
  61. ArgumentsAdjuster combineAdjusters(ArgumentsAdjuster First,
  62. ArgumentsAdjuster Second);
  63. } // namespace tooling
  64. } // namespace clang
  65. #endif // LLVM_CLANG_TOOLING_ARGUMENTSADJUSTERS_H
  66. #ifdef __GNUC__
  67. #pragma GCC diagnostic pop
  68. #endif