summaryrefslogtreecommitdiffstats
path: root/unittests
diff options
context:
space:
mode:
authorClement Courbet <courbet@google.com>2017-07-11 15:45:22 +0000
committerClement Courbet <courbet@google.com>2017-07-11 15:45:22 +0000
commite575997e85ce57a89dd5ba926dac7f40e7fffe76 (patch)
tree22906b1f49c8626863aef7f158752227006b78b2 /unittests
parent1e30b7a60a9a2bfc5657b59bfe8cab0bec8ef957 (diff)
[ASTMatchers][NFC] integerLiteral(): Mention negative integers in
documentation. Trying to match integerLiteral(-1) will silently fail, because an numeric literal is always positive. - Update the documentation to explain how to match negative numeric literals. - Add a unit test. Differential Revision: https://reviews.llvm.org/D35196 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@307663 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r--unittests/ASTMatchers/ASTMatchersNodeTest.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/unittests/ASTMatchers/ASTMatchersNodeTest.cpp b/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
index dfaa441cd7..58c26eafd7 100644
--- a/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ b/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -666,6 +666,12 @@ TEST(Matcher, IntegerLiterals) {
EXPECT_TRUE(notMatches("int i = 'a';", HasIntLiteral));
EXPECT_TRUE(notMatches("int i = 1e10;", HasIntLiteral));
EXPECT_TRUE(notMatches("int i = 10.0;", HasIntLiteral));
+
+ // Negative integers.
+ EXPECT_TRUE(
+ matches("int i = -10;",
+ unaryOperator(hasOperatorName("-"),
+ hasUnaryOperand(integerLiteral(equals(10))))));
}
TEST(Matcher, FloatLiterals) {