[PATCH] D19876: Add an AST matcher for string-literal length

Etienne Bergeron via cfe-commits cfe-commits at lists.llvm.org
Tue May 3 20:32:10 PDT 2016


etienneb added inline comments.

================
Comment at: include/clang/ASTMatchers/ASTMatchers.h:1578
@@ +1577,3 @@
+/// \endcode
+AST_MATCHER_P(StringLiteral, lengthIs, unsigned, N) {
+  return Node.getLength() == N;
----------------
aaron.ballman wrote:
> Perhaps we can adjust the `hasSize()` matcher instead? It currently works with ConstantArrayType, but it seems reasonable for it to also work with StringLiteral.
I didn't like the term "size" as it typically refer to the size in bytes.
Which is not the same for a wide-string.

Now, there is two different convention for naming matchers:
  hasLength   and  lengthIs  ?

Any toughs on that?




http://reviews.llvm.org/D19876





More information about the cfe-commits mailing list