+
//===--- CommandLineSourceLoc.h - Parsing for source locations-*- C++ -*---===//
//
// The LLVM Compiler Infrastructure
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);
};
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"),
Opts.DisableFree = DisableFree;
Opts.EmptyInputOnly = EmptyInputOnly;
Opts.FixItAll = FixItAll;
+ Opts.FixItLocations = FixItAtLocations;
Opts.RelocatablePCH = RelocatablePCH;
Opts.ShowStats = Stats;
Opts.ShowTimers = TimeReport;
"Rewrite Blocks to C"),
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
//===----------------------------------------------------------------------===//
/// 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";
}
}
}
// 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;
}
}
// 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;