Make the FixItOptions object required instead of optional.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111105 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Nick Lewycky 2010-08-15 16:47:39 +00:00
Родитель 5e4cb347cb
Коммит 96872c4470
2 изменённых файлов: 9 добавлений и 5 удалений

Просмотреть файл

@ -49,16 +49,14 @@ bool FixItRewriter::WriteFixedFile(FileID ID, llvm::raw_ostream &OS) {
}
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);

Просмотреть файл

@ -42,6 +42,11 @@ ASTConsumer *FixItAction::CreateASTConsumer(CompilerInstance &CI,
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 @@ bool FixItAction::BeginSourceFileAction(CompilerInstance &CI,
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()));