[cfe-commits] r111105 - in /cfe/trunk/lib/Rewrite: FixItRewriter.cpp FrontendActions.cpp
Nick Lewycky
nicholas at mxc.ca
Sun Aug 15 09:47:39 PDT 2010
Author: nicholas
Date: Sun Aug 15 11:47:39 2010
New Revision: 111105
URL: http://llvm.org/viewvc/llvm-project?rev=111105&view=rev
Log:
Make the FixItOptions object required instead of optional.
Modified:
cfe/trunk/lib/Rewrite/FixItRewriter.cpp
cfe/trunk/lib/Rewrite/FrontendActions.cpp
Modified: cfe/trunk/lib/Rewrite/FixItRewriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Rewrite/FixItRewriter.cpp?rev=111105&r1=111104&r2=111105&view=diff
==============================================================================
--- cfe/trunk/lib/Rewrite/FixItRewriter.cpp (original)
+++ cfe/trunk/lib/Rewrite/FixItRewriter.cpp Sun Aug 15 11:47:39 2010
@@ -49,16 +49,14 @@
}
bool FixItRewriter::WriteFixedFiles() {
- if (NumFailures > 0 && (!FixItOpts || !FixItOpts->FixWhatYouCan)) {
+ if (NumFailures > 0 && !FixItOpts->FixWhatYouCan) {
Diag(FullSourceLoc(), diag::warn_fixit_no_changes);
return true;
}
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 (FixItOpts)
- Filename = FixItOpts->RewriteFilename(Filename);
+ std::string Filename = FixItOpts->RewriteFilename(Entry->getName());
std::string Err;
llvm::raw_fd_ostream OS(Filename.c_str(), Err,
llvm::raw_fd_ostream::F_Binary);
Modified: cfe/trunk/lib/Rewrite/FrontendActions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Rewrite/FrontendActions.cpp?rev=111105&r1=111104&r2=111105&view=diff
==============================================================================
--- cfe/trunk/lib/Rewrite/FrontendActions.cpp (original)
+++ cfe/trunk/lib/Rewrite/FrontendActions.cpp Sun Aug 15 11:47:39 2010
@@ -42,6 +42,11 @@
return new ASTConsumer();
}
+class FixItRewriteInPlace : public FixItOptions {
+public:
+ std::string RewriteFilename(const std::string &Filename) { return Filename; }
+};
+
class FixItActionSuffixInserter : public FixItOptions {
std::string NewSuffix;
@@ -67,7 +72,8 @@
FixItOpts.reset(new FixItActionSuffixInserter(FEOpts.FixItSuffix,
FEOpts.FixWhatYouCan));
} else {
- FixItOpts.reset();
+ FixItOpts.reset(new FixItRewriteInPlace);
+ FixItOpts->FixWhatYouCan = FEOpts.FixWhatYouCan;
}
Rewriter.reset(new FixItRewriter(CI.getDiagnostics(), CI.getSourceManager(),
CI.getLangOpts(), FixItOpts.get()));
More information about the cfe-commits
mailing list