aboutsummaryrefslogtreecommitdiff
path: root/include/clang/Tooling
diff options
context:
space:
mode:
authorSimon Atanasyan <satanasyan@mips.com>2012-05-09 16:18:30 +0000
committerSimon Atanasyan <satanasyan@mips.com>2012-05-09 16:18:30 +0000
commita01ddc787b5c8b1cf11e975d3586908d3629954c (patch)
tree5358de2a3762116e1e2e6887a43bcd2993859778 /include/clang/Tooling
parent4c4cc16dbb4ab44909ea3cbb43609ef5ea19b9d2 (diff)
Declare abstract class ArgumentsAdjuster. This abstract interface describes
a command line argument adjuster, which is responsible for command line arguments modification before the arguments are used to run a frontend action. Define class ClangSyntaxOnlyAdjuster implements ArgumentsAdjuster interface. This class converts input command line arguments to the "syntax check only" variant. Reviewed by Manuel Klimek. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156478 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Tooling')
-rw-r--r--include/clang/Tooling/ArgumentsAdjusters.h56
-rw-r--r--include/clang/Tooling/Tooling.h12
2 files changed, 68 insertions, 0 deletions
diff --git a/include/clang/Tooling/ArgumentsAdjusters.h b/include/clang/Tooling/ArgumentsAdjusters.h
new file mode 100644
index 0000000000..28d2a38a4c
--- /dev/null
+++ b/include/clang/Tooling/ArgumentsAdjusters.h
@@ -0,0 +1,56 @@
+//===--- ArgumentsAdjusters.h - Command line arguments adjuster -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file declares base abstract class ArgumentsAdjuster and its descendants.
+// These classes are intended to modify command line arguments obtained from
+// a compilation database before they are used to run a frontend action.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_TOOLING_ARGUMENTSADJUSTERS_H
+#define LLVM_CLANG_TOOLING_ARGUMENTSADJUSTERS_H
+
+#include <string>
+#include <vector>
+
+namespace clang {
+
+namespace tooling {
+
+/// \brief A sequence of command line arguments.
+typedef std::vector<std::string> CommandLineArguments;
+
+/// \brief Abstract interface for a command line adjusters.
+///
+/// This abstract interface describes a command line argument adjuster,
+/// which is responsible for command line arguments modification before
+/// the arguments are used to run a frontend action.
+class ArgumentsAdjuster {
+public:
+ /// \brief Returns adjusted command line arguments.
+ ///
+ /// \param Args Input sequence of command line arguments.
+ ///
+ /// \returns Modified sequence of command line arguments.
+ virtual CommandLineArguments Adjust(const CommandLineArguments &Args) = 0;
+};
+
+/// \brief Syntax check only command line adjuster.
+///
+/// This class implements ArgumentsAdjuster interface and converts input
+/// command line arguments to the "syntax check only" variant.
+class ClangSyntaxOnlyAdjuster : public ArgumentsAdjuster {
+ virtual CommandLineArguments Adjust(const CommandLineArguments &Args);
+};
+
+} // end namespace tooling
+} // end namespace clang
+
+#endif // LLVM_CLANG_TOOLING_ARGUMENTSADJUSTERS_H
+
diff --git a/include/clang/Tooling/Tooling.h b/include/clang/Tooling/Tooling.h
index ff66616dfc..ecf14181de 100644
--- a/include/clang/Tooling/Tooling.h
+++ b/include/clang/Tooling/Tooling.h
@@ -35,6 +35,7 @@
#include "clang/Basic/FileManager.h"
#include "clang/Basic/LLVM.h"
#include "clang/Driver/Util.h"
+#include "clang/Tooling/ArgumentsAdjusters.h"
#include "clang/Tooling/CompilationDatabase.h"
#include <string>
#include <vector>
@@ -138,6 +139,10 @@ class ToolInvocation {
/// \brief Utility to run a FrontendAction over a set of files.
///
/// This class is written to be usable for command line utilities.
+/// By default the class uses ClangSyntaxOnlyAdjuster to modify
+/// command line arguments before the arguments are used to run
+/// a frontend action. One could install another command line
+/// arguments adjuster by call setArgumentsAdjuster() method.
class ClangTool {
public:
/// \brief Constructs a clang tool to run over a list of files.
@@ -155,6 +160,11 @@ class ClangTool {
/// \param Content A null terminated buffer of the file's content.
void mapVirtualFile(StringRef FilePath, StringRef Content);
+ /// \brief Install command line arguments adjuster.
+ ///
+ /// \param Adjuster Command line arguments adjuster.
+ void setArgumentsAdjuster(ArgumentsAdjuster *Adjuster);
+
/// Runs a frontend action over all files specified in the command line.
///
/// \param ActionFactory Factory generating the frontend actions. The function
@@ -174,6 +184,8 @@ class ClangTool {
FileManager Files;
// Contains a list of pairs (<file name>, <file content>).
std::vector< std::pair<StringRef, StringRef> > MappedFileContents;
+
+ llvm::OwningPtr<ArgumentsAdjuster> ArgsAdjuster;
};
template <typename T>