зеркало из https://github.com/microsoft/clang-1.git
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:
Родитель
5e4cb347cb
Коммит
96872c4470
|
@ -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()));
|
||||
|
|
Загрузка…
Ссылка в новой задаче