aboutsummaryrefslogtreecommitdiff
path: root/include/clang
diff options
context:
space:
mode:
Diffstat (limited to 'include/clang')
-rw-r--r--include/clang/Driver/CC1Options.td4
-rw-r--r--include/clang/Frontend/FixItRewriter.h34
-rw-r--r--include/clang/Frontend/FrontendActions.h2
-rw-r--r--include/clang/Frontend/FrontendOptions.h4
4 files changed, 18 insertions, 26 deletions
diff --git a/include/clang/Driver/CC1Options.td b/include/clang/Driver/CC1Options.td
index e45cfa9920..9fd21e97a0 100644
--- a/include/clang/Driver/CC1Options.td
+++ b/include/clang/Driver/CC1Options.td
@@ -245,8 +245,6 @@ def x : Separate<"-x">, HelpText<"Input language type">;
def cxx_inheritance_view : Separate<"-cxx-inheritance-view">,
MetaVarName<"<class name>">,
HelpText<"View C++ inheritance for a specified class">;
-def fixit_at : Separate<"-fixit-at">, MetaVarName<"<source location>">,
- HelpText<"Perform Fix-It modifications at the given source location">;
def o : Separate<"-o">, MetaVarName<"<path>">, HelpText<"Specify output file">;
def load : Separate<"-load">, MetaVarName<"<dsopath>">,
HelpText<"Load the named plugin (dynamic shared object)">;
@@ -279,6 +277,8 @@ def fsyntax_only : Flag<"-fsyntax-only">,
HelpText<"Run parser and perform semantic analysis">;
def fixit : Flag<"-fixit">,
HelpText<"Apply fix-it advice to the input source">;
+def fixit_EQ : Joined<"-fixit=">,
+ HelpText<"Apply fix-it advice creating a file with the given suffix">;
def parse_print_callbacks : Flag<"-parse-print-callbacks">,
HelpText<"Run parser and print each callback invoked">;
def emit_html : Flag<"-emit-html">,
diff --git a/include/clang/Frontend/FixItRewriter.h b/include/clang/Frontend/FixItRewriter.h
index 95fd3da3c6..b432d747de 100644
--- a/include/clang/Frontend/FixItRewriter.h
+++ b/include/clang/Frontend/FixItRewriter.h
@@ -27,16 +27,13 @@ namespace clang {
class SourceManager;
class FileEntry;
-/// \brief Stores a source location in the form that it shows up on
-/// the Clang command line, e.g., file:line:column. A line and column of zero
-/// indicates the whole file.
-///
-/// FIXME: Would prefer to use real SourceLocations, but I don't see a
-/// good way to resolve them during parsing.
-struct RequestedSourceLocation {
- const FileEntry *File;
- unsigned Line;
- unsigned Column;
+class FixItPathRewriter {
+public:
+ virtual ~FixItPathRewriter();
+
+ /// \brief This file is about to be rewritten. Return the name of the file
+ /// that is okay to write to.
+ virtual std::string RewriteFilename(const std::string &Filename) = 0;
};
class FixItRewriter : public DiagnosticClient {
@@ -51,30 +48,23 @@ class FixItRewriter : public DiagnosticClient {
/// of error messages.
DiagnosticClient *Client;
+ /// \brief Turn an input path into an output path. NULL implies overwriting
+ /// the original.
+ FixItPathRewriter *PathRewriter;
+
/// \brief The number of rewriter failures.
unsigned NumFailures;
- /// \brief Locations at which we should perform fix-its.
- ///
- /// When empty, perform fix-it modifications everywhere.
- llvm::SmallVector<RequestedSourceLocation, 4> FixItLocations;
-
public:
typedef Rewriter::buffer_iterator iterator;
/// \brief Initialize a new fix-it rewriter.
FixItRewriter(Diagnostic &Diags, SourceManager &SourceMgr,
- const LangOptions &LangOpts);
+ const LangOptions &LangOpts, FixItPathRewriter *PathRewriter);
/// \brief Destroy the fix-it rewriter.
~FixItRewriter();
- /// \brief Add a location where fix-it modifications should be
- /// performed.
- void addFixItLocation(RequestedSourceLocation Loc) {
- FixItLocations.push_back(Loc);
- }
-
/// \brief Check whether there are modifications for a given file.
bool IsModified(FileID ID) const {
return Rewrite.getRewriteBufferFor(ID) != NULL;
diff --git a/include/clang/Frontend/FrontendActions.h b/include/clang/Frontend/FrontendActions.h
index 8c9ebca887..3ddd77dc39 100644
--- a/include/clang/Frontend/FrontendActions.h
+++ b/include/clang/Frontend/FrontendActions.h
@@ -16,6 +16,7 @@
namespace clang {
class FixItRewriter;
+class FixItPathRewriter;
//===----------------------------------------------------------------------===//
// Custom Consumer Actions
@@ -76,6 +77,7 @@ protected:
class FixItAction : public ASTFrontendAction {
private:
llvm::OwningPtr<FixItRewriter> Rewriter;
+ llvm::OwningPtr<FixItPathRewriter> PathRewriter;
protected:
diff --git a/include/clang/Frontend/FrontendOptions.h b/include/clang/Frontend/FrontendOptions.h
index 9f3e00dbc9..60512edd6c 100644
--- a/include/clang/Frontend/FrontendOptions.h
+++ b/include/clang/Frontend/FrontendOptions.h
@@ -92,8 +92,8 @@ public:
/// If given, the name for a C++ class to view the inheritance of.
std::string ViewClassInheritance;
- /// A list of locations to apply fix-its at.
- std::vector<ParsedSourceLocation> FixItLocations;
+ /// If given, the new suffix for fix-it rewritten files.
+ std::string FixItSuffix;
/// If given, enable code completion at the provided location.
ParsedSourceLocation CodeCompletionAt;