[PATCH] D111242: Add `TypeLoc`-related matchers.

James King via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 6 13:34:20 PDT 2021


jcking1034 marked an inline comment as not done.
jcking1034 added inline comments.


================
Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:6358
+/// \code
+///   int* x = 0;
+/// \endcode
----------------
ymandel wrote:
> I think you need a const here (to the right) to be considered a qualified type loc.
I've decided to use a different example to be a bit clearer.


================
Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:6400
+/// pointerTypeLoc(hasPointeeLoc(loc(asString("int"))))
+///   matches `int*`.
+AST_MATCHER_P(PointerTypeLoc, hasPointeeLoc, TypeLocMatcher, PointeeMatcher) {
----------------
ymandel wrote:
> I think `int` not `int*`?
I think this should be correct. If we were to look at `int** x`, `pointerTypeLoc(hasPointeeLoc(pointerTypeLoc(hasPointeeLoc(loc(asString("int"))))))` will match the whole `TypeLoc` and `pointerTypeLoc(hasPointeeLoc(loc(asString("int"))))` will match `int*`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D111242/new/

https://reviews.llvm.org/D111242



More information about the cfe-commits mailing list