Add a new cc1 option -fix-what-you-can which when combined with the fix-it mode
will apply all fixes even when there were other errors in the file.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111020 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Rewrite/FixItRewriter.cpp b/lib/Rewrite/FixItRewriter.cpp
index 29ac7e3..875af7a 100644
--- a/lib/Rewrite/FixItRewriter.cpp
+++ b/lib/Rewrite/FixItRewriter.cpp
@@ -27,10 +27,10 @@
FixItRewriter::FixItRewriter(Diagnostic &Diags, SourceManager &SourceMgr,
const LangOptions &LangOpts,
- FixItPathRewriter *PathRewriter)
+ FixItOptions *FixItOpts)
: Diags(Diags),
Rewrite(SourceMgr, LangOpts),
- PathRewriter(PathRewriter),
+ FixItOpts(FixItOpts),
NumFailures(0) {
Client = Diags.getClient();
Diags.setClient(this);
@@ -49,7 +49,7 @@
}
bool FixItRewriter::WriteFixedFiles() {
- if (NumFailures > 0) {
+ if (NumFailures > 0 && !FixItOpts->FixWhatYouCan) {
Diag(FullSourceLoc(), diag::warn_fixit_no_changes);
return true;
}
@@ -57,8 +57,8 @@
for (iterator I = buffer_begin(), E = buffer_end(); I != E; ++I) {
const FileEntry *Entry = Rewrite.getSourceMgr().getFileEntryForID(I->first);
std::string Filename = Entry->getName();
- if (PathRewriter)
- Filename = PathRewriter->RewriteFilename(Filename);
+ if (FixItOpts)
+ Filename = FixItOpts->RewriteFilename(Filename);
std::string Err;
llvm::raw_fd_ostream OS(Filename.c_str(), Err,
llvm::raw_fd_ostream::F_Binary);
@@ -164,4 +164,4 @@
Diags.setClient(this);
}
-FixItPathRewriter::~FixItPathRewriter() {}
+FixItOptions::~FixItOptions() {}