aboutsummaryrefslogtreecommitdiff
path: root/clang/unittests/Tooling/TransformerTest.cpp
diff options
context:
space:
mode:
authorYitzhak Mandelbaum <yitzhakm@google.com>2020-10-22 14:03:59 +0000
committerYitzhak Mandelbaum <yitzhakm@google.com>2020-10-22 21:29:03 +0000
commit6f8f5cb77efd100e5d4916db871b18c88cf49ed0 (patch)
treea3b2cab3537e8afcd537f2174242e1a560ddcbac /clang/unittests/Tooling/TransformerTest.cpp
parent8277a513c74b53e5ad7f482f76b27bc8609c66ae (diff)
downloadllvm-6f8f5cb77efd100e5d4916db871b18c88cf49ed0.zip
llvm-6f8f5cb77efd100e5d4916db871b18c88cf49ed0.tar.gz
llvm-6f8f5cb77efd100e5d4916db871b18c88cf49ed0.tar.bz2
[libTooling] Add function to Transformer to create a no-op edit.
This functionality is commonly needed in clang tidy checks (based on transformer) that only print warnings, without suggesting any edits. The no-op edit allows the user to associate a diagnostic message with a source location. Differential Revision: https://reviews.llvm.org/D89961
Diffstat (limited to 'clang/unittests/Tooling/TransformerTest.cpp')
-rw-r--r--clang/unittests/Tooling/TransformerTest.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/clang/unittests/Tooling/TransformerTest.cpp b/clang/unittests/Tooling/TransformerTest.cpp
index a8d6d3d..ff735cd 100644
--- a/clang/unittests/Tooling/TransformerTest.cpp
+++ b/clang/unittests/Tooling/TransformerTest.cpp
@@ -426,6 +426,14 @@ TEST_F(TransformerTest, NoEdits) {
testRule(makeRule(returnStmt().bind("return"), noEdits()), Input, Input);
}
+TEST_F(TransformerTest, NoopEdit) {
+ using transformer::node;
+ using transformer::noopEdit;
+ std::string Input = "int f(int x) { return x; }";
+ testRule(makeRule(returnStmt().bind("return"), noopEdit(node("return"))),
+ Input, Input);
+}
+
TEST_F(TransformerTest, IfBound2Args) {
using transformer::ifBound;
std::string Input = "int f(int x) { return x; }";