[llvm-branch-commits] [clang] [clang][test] add testing for the AST matcher reference (PR #94248)
Julian Schmidt via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Jun 4 16:45:11 PDT 2024
================
@@ -176,11 +176,13 @@ inline internal::TrueMatcher anything() { return internal::TrueMatcher(); }
/// \code
/// int X;
/// namespace NS {
-/// int Y;
+/// int Y;
/// } // namespace NS
/// \endcode
-/// decl(hasDeclContext(translationUnitDecl()))
-/// matches "int X", but not "int Y".
+/// \compile_args{-std=c++}
+/// The matcher \matcher{namedDecl(hasDeclContext(translationUnitDecl()))}
+/// matches \match{type=name$X} and \match{type=name$NS},
----------------
5chmidti wrote:
Using `type=name` can be generally considered to be a style/readability/expressiveness choice if the AST node supports it. The `X` example would probably be better spelling the declaration out, the same goes for `Y` (probably remnants of the early days). There may be other trivial examples that could be spelled out.
There are for sure some more trivial cases which could be spelled out. I'll check on the documentation again tomorrow and provide some updates (also w.r.t to your other comment).
If we wanted to spell out the namespace, we could, but that would require writing the `NS` in a single line. It's an artificial limitation in the script that can probably be implemented if we want to have the option.
https://github.com/llvm/llvm-project/pull/94248
More information about the llvm-branch-commits
mailing list