From 40ef2fb363bcd89cb4a88157f5fa97a38d795a1f Mon Sep 17 00:00:00 2001 From: Eric Liu Date: Mon, 1 Aug 2016 10:16:37 +0000 Subject: 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 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 --- clang/lib/Format/WhitespaceManager.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'clang/lib/Format/WhitespaceManager.cpp') diff --git a/clang/lib/Format/WhitespaceManager.cpp b/clang/lib/Format/WhitespaceManager.cpp index 9cdba9df10a..8ca307bd165 100644 --- a/clang/lib/Format/WhitespaceManager.cpp +++ b/clang/lib/Format/WhitespaceManager.cpp @@ -502,8 +502,13 @@ void WhitespaceManager::storeReplacement(SourceRange Range, if (StringRef(SourceMgr.getCharacterData(Range.getBegin()), WhitespaceLength) == Text) return; - Replaces.insert(tooling::Replacement( + auto Err = Replaces.add(tooling::Replacement( SourceMgr, CharSourceRange::getCharRange(Range), Text)); + // FIXME: better error handling. For now, just print an error message in the + // release version. + if (Err) + llvm::errs() << llvm::toString(std::move(Err)) << "\n"; + assert(!Err); } void WhitespaceManager::appendNewlineText(std::string &Text, -- cgit v1.2.3