[PATCH] D157777: [ASTMatcher] Add matcher for 'MacroQualifiedType'

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 14 10:57:08 PDT 2023


aaron.ballman added inline comments.


================
Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:7261
 
+/// Matches macro qualified types.
+///
----------------
How about: Matches qualified types when the qualifier is applied via a macro.

and then a second example like:
```
int * const qual_ptr;

#define nonnull _Nonnull
int * const nonnull macro_qual_ptr;
```
where we match `macro_qual_ptr` but not `qual_ptr`.


================
Comment at: clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp:1842-1847
+  EXPECT_TRUE(matches(R"(
+        #define CDECL __attribute__((cdecl))
+        typedef void (CDECL *X)();
+      )",
+                      typedefDecl(hasName("X"), hasType(pointerType(pointee(
+                                                    macroQualifiedType()))))));
----------------
I'd appreciate extra test coverage from the example I posted above.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157777



More information about the cfe-commits mailing list