diff options
author | Eric Liu <ioeric@google.com> | 2016-08-01 10:16:37 +0000 |
---|---|---|
committer | Eric Liu <ioeric@google.com> | 2016-08-01 10:16:37 +0000 |
commit | 40ef2fb363bcd89cb4a88157f5fa97a38d795a1f (patch) | |
tree | 0817f1606ccb51b55370c8b10346d519be9aec97 /clang/lib/Format/TokenAnalyzer.cpp | |
parent | 5c9583981b5e73ac42d224ec97bd8470a384da26 (diff) | |
download | bcm5719-llvm-40ef2fb363bcd89cb4a88157f5fa97a38d795a1f.tar.gz bcm5719-llvm-40ef2fb363bcd89cb4a88157f5fa97a38d795a1f.zip |
Implement tooling::Replacements as a class.
Summary:
- Implement clang::tooling::Replacements as a class to provide interfaces to
control how replacements for a single file are combined and provide guarantee
on the order of replacements being applied.
- tooling::Replacements only contains replacements for the same file now.
Use std::map<std::string, tooling::Replacements> to represent multi-file
replacements.
- Error handling for the interface change will be improved in followup patches.
Reviewers: djasper, klimek
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D21748
llvm-svn: 277335
Diffstat (limited to 'clang/lib/Format/TokenAnalyzer.cpp')
-rw-r--r-- | clang/lib/Format/TokenAnalyzer.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/clang/lib/Format/TokenAnalyzer.cpp b/clang/lib/Format/TokenAnalyzer.cpp index 89ac35f3e84..7baba62f0a8 100644 --- a/clang/lib/Format/TokenAnalyzer.cpp +++ b/clang/lib/Format/TokenAnalyzer.cpp @@ -111,8 +111,8 @@ tooling::Replacements TokenAnalyzer::process() { DEBUG({ llvm::dbgs() << "Replacements for run " << Run << ":\n"; - for (tooling::Replacements::iterator I = RunResult.begin(), - E = RunResult.end(); + for (tooling::Replacements::const_iterator I = RunResult.begin(), + E = RunResult.end(); I != E; ++I) { llvm::dbgs() << I->toString() << "\n"; } @@ -120,7 +120,15 @@ tooling::Replacements TokenAnalyzer::process() { for (unsigned i = 0, e = AnnotatedLines.size(); i != e; ++i) { delete AnnotatedLines[i]; } - Result.insert(RunResult.begin(), RunResult.end()); + for (auto R : RunResult) { + auto Err = Result.add(R); + // FIXME: better error handling here. For now, simply return an empty + // Replacements to indicate failure. + if (Err) { + llvm::errs() << llvm::toString(std::move(Err)) << "\n"; + return tooling::Replacements(); + } + } } return Result; } |