Home | History | Annotate | Download | only in Tooling
      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 base abstract class ArgumentsAdjuster and its descendants.
     11 // These classes are intended to modify command line arguments obtained from
     12 // a compilation 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 <string>
     20 #include <vector>
     21 
     22 namespace clang {
     23 
     24 namespace tooling {
     25 
     26 /// \brief A sequence of command line arguments.
     27 typedef std::vector<std::string> CommandLineArguments;
     28 
     29 /// \brief Abstract interface for a command line adjusters.
     30 ///
     31 /// This abstract interface describes a command line argument adjuster,
     32 /// which is responsible for command line arguments modification before
     33 /// the arguments are used to run a frontend action.
     34 class ArgumentsAdjuster {
     35   virtual void anchor();
     36 public:
     37   /// \brief Returns adjusted command line arguments.
     38   ///
     39   /// \param Args Input sequence of command line arguments.
     40   ///
     41   /// \returns Modified sequence of command line arguments.
     42   virtual CommandLineArguments Adjust(const CommandLineArguments &Args) = 0;
     43   virtual ~ArgumentsAdjuster() {
     44   }
     45 };
     46 
     47 /// \brief Syntax check only command line adjuster.
     48 ///
     49 /// This class implements ArgumentsAdjuster interface and converts input
     50 /// command line arguments to the "syntax check only" variant.
     51 class ClangSyntaxOnlyAdjuster : public ArgumentsAdjuster {
     52   virtual CommandLineArguments Adjust(const CommandLineArguments &Args);
     53 };
     54 
     55 /// \brief An argument adjuster which removes output-related command line
     56 /// arguments.
     57 class ClangStripOutputAdjuster : public ArgumentsAdjuster {
     58   virtual CommandLineArguments Adjust(const CommandLineArguments &Args);
     59 };
     60 
     61 } // end namespace tooling
     62 } // end namespace clang
     63 
     64 #endif // LLVM_CLANG_TOOLING_ARGUMENTSADJUSTERS_H
     65 
     66