diff options
| author | Daniel Jasper <djasper@google.com> | 2015-02-02 23:04:00 +0000 |
|---|---|---|
| committer | Daniel Jasper <djasper@google.com> | 2015-02-02 23:04:00 +0000 |
| commit | 88de3d72845cab030d4cf9aa30c5bd421f7d8901 (patch) | |
| tree | 5e14b537ef39a3f2f17484d37dad6adfe60c0e8f /clang/unittests/ASTMatchers/ASTMatchersTest.cpp | |
| parent | a1c535b5e85e63ae216c23a3511e0c7634827909 (diff) | |
| download | bcm5719-llvm-88de3d72845cab030d4cf9aa30c5bd421f7d8901.tar.gz bcm5719-llvm-88de3d72845cab030d4cf9aa30c5bd421f7d8901.zip | |
Add some overloads so that floating point literals can be AST matched properly.
I am not entirely sure whether the implemented sematics are ideal. In
particular, should floatLiteral(equals(0.5)) match "0.5f" and should
floatLiteral(equals(0.5f)) match "0.5". With the overloads in this
patch, the answer to both questions is yes, but I am happy to change
that.
llvm-svn: 227892
Diffstat (limited to 'clang/unittests/ASTMatchers/ASTMatchersTest.cpp')
| -rw-r--r-- | clang/unittests/ASTMatchers/ASTMatchersTest.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/clang/unittests/ASTMatchers/ASTMatchersTest.cpp b/clang/unittests/ASTMatchers/ASTMatchersTest.cpp index d2e9ee19b2c..9cc011d3a6a 100644 --- a/clang/unittests/ASTMatchers/ASTMatchersTest.cpp +++ b/clang/unittests/ASTMatchers/ASTMatchersTest.cpp @@ -2104,8 +2104,16 @@ TEST(Matcher, FloatLiterals) { EXPECT_TRUE(matches("double i = 10.0;", HasFloatLiteral)); EXPECT_TRUE(matches("double i = 10.0L;", HasFloatLiteral)); EXPECT_TRUE(matches("double i = 1e10;", HasFloatLiteral)); + EXPECT_TRUE(matches("double i = 5.0;", floatLiteral(equals(5.0)))); + EXPECT_TRUE(matches("double i = 5.0;", floatLiteral(equals(5.0f)))); + EXPECT_TRUE( + matches("double i = 5.0;", floatLiteral(equals(llvm::APFloat(5.0))))); EXPECT_TRUE(notMatches("float i = 10;", HasFloatLiteral)); + EXPECT_TRUE(notMatches("double i = 5.0;", floatLiteral(equals(6.0)))); + EXPECT_TRUE(notMatches("double i = 5.0;", floatLiteral(equals(6.0f)))); + EXPECT_TRUE( + notMatches("double i = 5.0;", floatLiteral(equals(llvm::APFloat(6.0))))); } TEST(Matcher, NullPtrLiteral) { |

