[cfe-commits] r87046 - in /cfe/trunk: include/clang/Frontend/CommandLineSourceLoc.h include/clang/Frontend/FrontendOptions.h tools/clang-cc/Options.cpp tools/clang-cc/clang-cc.cpp
Daniel Dunbar
daniel at zuster.org
Thu Nov 12 15:52:56 PST 2009
Author: ddunbar
Date: Thu Nov 12 17:52:56 2009
New Revision: 87046
URL: http://llvm.org/viewvc/llvm-project?rev=87046&view=rev
Log:
Move FixItAtLocations into FrontendOptions
Modified:
cfe/trunk/include/clang/Frontend/CommandLineSourceLoc.h
cfe/trunk/include/clang/Frontend/FrontendOptions.h
cfe/trunk/tools/clang-cc/Options.cpp
cfe/trunk/tools/clang-cc/clang-cc.cpp
Modified: cfe/trunk/include/clang/Frontend/CommandLineSourceLoc.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CommandLineSourceLoc.h?rev=87046&r1=87045&r2=87046&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/CommandLineSourceLoc.h (original)
+++ cfe/trunk/include/clang/Frontend/CommandLineSourceLoc.h Thu Nov 12 17:52:56 2009
@@ -1,3 +1,4 @@
+
//===--- CommandLineSourceLoc.h - Parsing for source locations-*- C++ -*---===//
//
// The LLVM Compiler Infrastructure
@@ -37,7 +38,7 @@
class parser<clang::ParsedSourceLocation>
: public basic_parser<clang::ParsedSourceLocation> {
public:
- bool parse(Option &O, StringRef ArgName, StringRef ArgValue,
+ inline bool parse(Option &O, StringRef ArgName, StringRef ArgValue,
clang::ParsedSourceLocation &Val);
};
Modified: cfe/trunk/include/clang/Frontend/FrontendOptions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendOptions.h?rev=87046&r1=87045&r2=87046&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/FrontendOptions.h (original)
+++ cfe/trunk/include/clang/Frontend/FrontendOptions.h Thu Nov 12 17:52:56 2009
@@ -10,6 +10,7 @@
#ifndef LLVM_CLANG_FRONTEND_FRONTENDOPTIONS_H
#define LLVM_CLANG_FRONTEND_FRONTENDOPTIONS_H
+#include "clang/Frontend/CommandLineSourceLoc.h"
#include <string>
#include <vector>
@@ -36,6 +37,9 @@
/// 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;
+
public:
FrontendOptions() {
DisableFree = 0;
Modified: cfe/trunk/tools/clang-cc/Options.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-cc/Options.cpp?rev=87046&r1=87045&r2=87046&view=diff
==============================================================================
--- cfe/trunk/tools/clang-cc/Options.cpp (original)
+++ cfe/trunk/tools/clang-cc/Options.cpp Thu Nov 12 17:52:56 2009
@@ -313,6 +313,10 @@
static llvm::cl::opt<bool>
FixItAll("fixit", llvm::cl::desc("Apply fix-it advice to the input source"));
+static llvm::cl::list<ParsedSourceLocation>
+FixItAtLocations("fixit-at", llvm::cl::value_desc("source-location"),
+ llvm::cl::desc("Perform Fix-It modifications at the given source location"));
+
static llvm::cl::opt<std::string>
OutputFile("o",
llvm::cl::value_desc("path"),
@@ -757,6 +761,7 @@
Opts.DisableFree = DisableFree;
Opts.EmptyInputOnly = EmptyInputOnly;
Opts.FixItAll = FixItAll;
+ Opts.FixItLocations = FixItAtLocations;
Opts.RelocatablePCH = RelocatablePCH;
Opts.ShowStats = Stats;
Opts.ShowTimers = TimeReport;
Modified: cfe/trunk/tools/clang-cc/clang-cc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-cc/clang-cc.cpp?rev=87046&r1=87045&r2=87046&view=diff
==============================================================================
--- cfe/trunk/tools/clang-cc/clang-cc.cpp (original)
+++ cfe/trunk/tools/clang-cc/clang-cc.cpp Thu Nov 12 17:52:56 2009
@@ -211,14 +211,6 @@
clEnumValEnd));
//===----------------------------------------------------------------------===//
-// Frontend Options
-//===----------------------------------------------------------------------===//
-
-static llvm::cl::list<ParsedSourceLocation>
-FixItAtLocations("fixit-at", llvm::cl::value_desc("source-location"),
- llvm::cl::desc("Perform Fix-It modifications at the given source location"));
-
-//===----------------------------------------------------------------------===//
// Language Options
//===----------------------------------------------------------------------===//
@@ -445,20 +437,21 @@
/// AddFixItLocations - Add any individual user specified "fix-it" locations,
/// and return true on success (if any were added).
static bool AddFixItLocations(FixItRewriter *FixItRewrite,
- FileManager &FileMgr) {
+ FileManager &FileMgr,
+ const std::vector<ParsedSourceLocation> &Locs) {
bool AddedFixItLocation = false;
- for (unsigned i = 0, e = FixItAtLocations.size(); i != e; ++i) {
- if (const FileEntry *File = FileMgr.getFile(FixItAtLocations[i].FileName)) {
+ for (unsigned i = 0, e = Locs.size(); i != e; ++i) {
+ if (const FileEntry *File = FileMgr.getFile(Locs[i].FileName)) {
RequestedSourceLocation Requested;
Requested.File = File;
- Requested.Line = FixItAtLocations[i].Line;
- Requested.Column = FixItAtLocations[i].Column;
+ Requested.Line = Locs[i].Line;
+ Requested.Column = Locs[i].Column;
FixItRewrite->addFixItLocation(Requested);
AddedFixItLocation = true;
} else {
llvm::errs() << "FIX-IT could not find file \""
- << FixItAtLocations[i].FileName << "\"\n";
+ << Locs[i].FileName << "\"\n";
}
}
@@ -517,7 +510,7 @@
}
// Fix-its can change semantics, disallow with any IRgen action.
- if (FEOpts.FixItAll || !FixItAtLocations.empty()) {
+ if (FEOpts.FixItAll || !FEOpts.FixItLocations.empty()) {
PP.getDiagnostics().Report(diag::err_fe_no_fixit_and_codegen);
return 0;
}
@@ -655,12 +648,13 @@
}
// Check if we want a fix-it rewriter.
- if (FEOpts.FixItAll || !FixItAtLocations.empty()) {
+ if (FEOpts.FixItAll || !FEOpts.FixItLocations.empty()) {
FixItRewrite = new FixItRewriter(PP.getDiagnostics(),
PP.getSourceManager(),
PP.getLangOptions());
- if (!FixItAtLocations.empty() &&
- !AddFixItLocations(FixItRewrite, PP.getFileManager())) {
+ if (!FEOpts.FixItLocations.empty() &&
+ !AddFixItLocations(FixItRewrite, PP.getFileManager(),
+ FEOpts.FixItLocations)) {
// All of the fix-it locations were bad. Don't fix anything.
delete FixItRewrite;
FixItRewrite = 0;
More information about the cfe-commits
mailing list