[PATCH] D33094: [ASTMatchers] Add clang-query support for equals matcher

Peter Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon May 22 02:04:52 PDT 2017


Lekensteyn added inline comments.


================
Comment at: include/clang/ASTMatchers/ASTMatchers.h:3846
+                                                          CXXBoolLiteralExpr,
+                                                          IntegerLiteral),
+                          unsigned, Value, 1) {
----------------
aaron.ballman wrote:
> Is there a reason to not allow the equals matcher to do something like `floatingLiteral(equals(1))`? Sure, the user could always write `1.0`, but it seems somewhat hostile to require it.
The ValueMatcher for float does not accept integers at the moment, adding FloatingLiteral now results in a compile error. It can be added though (might do this as well in the next revision, either in the existing patches or a new one).


================
Comment at: unittests/ASTMatchers/Dynamic/RegistryTest.cpp:534
+  EXPECT_TRUE(matches("double x = 12e-1;", DoubleStmt));
+  EXPECT_FALSE(matches("double x = 1.23;", DoubleStmt));
+
----------------
aaron.ballman wrote:
> Can you add tests for floating literals with suffixes (f, l)?
will do


================
Comment at: unittests/ASTMatchers/Dynamic/RegistryTest.cpp:545
+      .getTypedMatcher<Stmt>();
+  EXPECT_TRUE(matches("int x = 'x';", CharStmt));
+  EXPECT_FALSE(matches("int x = 120;", CharStmt));
----------------
aaron.ballman wrote:
> Can you add some tests involving the other character literal types (L, u, U, u8)?
will do


https://reviews.llvm.org/D33094





More information about the cfe-commits mailing list