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/unittests/Tooling/RewriterTest.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/unittests/Tooling/RewriterTest.cpp')
-rw-r--r-- | clang/unittests/Tooling/RewriterTest.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/clang/unittests/Tooling/RewriterTest.cpp b/clang/unittests/Tooling/RewriterTest.cpp index e8afedb0117..4305d421e1c 100644 --- a/clang/unittests/Tooling/RewriterTest.cpp +++ b/clang/unittests/Tooling/RewriterTest.cpp @@ -39,8 +39,11 @@ TEST(Rewriter, ContinuesOverwritingFilesOnError) { TEST(Rewriter, AdjacentInsertAndDelete) { Replacements Replaces; - Replaces.insert(Replacement("<file>", 6, 6, "")); - Replaces.insert(Replacement("<file>", 6, 0, "replaced\n")); + auto Err = Replaces.add(Replacement("<file>", 6, 6, "")); + EXPECT_TRUE(!Err); + Replaces = + Replaces.merge(Replacements(Replacement("<file>", 6, 0, "replaced\n"))); + auto Rewritten = applyAllReplacements("line1\nline2\nline3\nline4", Replaces); EXPECT_TRUE(static_cast<bool>(Rewritten)); EXPECT_EQ("line1\nreplaced\nline3\nline4", *Rewritten); |