summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Format/CleanupTest.cpp
diff options
context:
space:
mode:
authorEric Liu <ioeric@google.com>2016-07-11 13:53:12 +0000
committerEric Liu <ioeric@google.com>2016-07-11 13:53:12 +0000
commit4f8d99433da80161f85988052f96bc7dc621c4eb (patch)
treee926d386edbf05c0d8346483a53ac49678e2f284 /clang/unittests/Format/CleanupTest.cpp
parent4d8500396454334975ab8bb6766d6521c5140b13 (diff)
downloadbcm5719-llvm-4f8d99433da80161f85988052f96bc7dc621c4eb.tar.gz
bcm5719-llvm-4f8d99433da80161f85988052f96bc7dc621c4eb.zip
Make tooling::applyAllReplacements return llvm::Expected<string> instead of empty string to indicate potential error.
Summary: return llvm::Expected<> to carry error status and error information. This is the first step towards introducing "Error" into tooling::Replacements. Reviewers: djasper, klimek Subscribers: ioeric, klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D21601 llvm-svn: 275062
Diffstat (limited to 'clang/unittests/Format/CleanupTest.cpp')
-rw-r--r--clang/unittests/Format/CleanupTest.cpp28
1 files changed, 19 insertions, 9 deletions
diff --git a/clang/unittests/Format/CleanupTest.cpp b/clang/unittests/Format/CleanupTest.cpp
index f51e3acf9ac..5f85c53b780 100644
--- a/clang/unittests/Format/CleanupTest.cpp
+++ b/clang/unittests/Format/CleanupTest.cpp
@@ -25,9 +25,9 @@ protected:
const FormatStyle &Style = getLLVMStyle()) {
tooling::Replacements Replaces = format::cleanup(Style, Code, Ranges);
- std::string Result = applyAllReplacements(Code, Replaces);
- EXPECT_NE("", Result);
- return Result;
+ auto Result = applyAllReplacements(Code, Replaces);
+ EXPECT_TRUE(static_cast<bool>(Result));
+ return *Result;
}
};
@@ -254,16 +254,26 @@ protected:
inline std::string apply(StringRef Code,
const tooling::Replacements Replaces) {
- return applyAllReplacements(
- Code, cleanupAroundReplacements(Code, Replaces, Style));
+ auto CleanReplaces = cleanupAroundReplacements(Code, Replaces, Style);
+ EXPECT_TRUE(static_cast<bool>(CleanReplaces))
+ << llvm::toString(CleanReplaces.takeError()) << "\n";
+ auto Result = applyAllReplacements(Code, *CleanReplaces);
+ EXPECT_TRUE(static_cast<bool>(Result));
+ return *Result;
}
inline std::string formatAndApply(StringRef Code,
const tooling::Replacements Replaces) {
- return applyAllReplacements(
- Code,
- formatReplacements(
- Code, cleanupAroundReplacements(Code, Replaces, Style), Style));
+
+ auto CleanReplaces = cleanupAroundReplacements(Code, Replaces, Style);
+ EXPECT_TRUE(static_cast<bool>(CleanReplaces))
+ << llvm::toString(CleanReplaces.takeError()) << "\n";
+ auto FormattedReplaces = formatReplacements(Code, *CleanReplaces, Style);
+ EXPECT_TRUE(static_cast<bool>(FormattedReplaces))
+ << llvm::toString(FormattedReplaces.takeError()) << "\n";
+ auto Result = applyAllReplacements(Code, *FormattedReplaces);
+ EXPECT_TRUE(static_cast<bool>(Result));
+ return *Result;
}
int getOffset(StringRef Code, int Line, int Column) {
OpenPOWER on IntegriCloud