[PATCH] D98407: [clang-query] Add syntax highlight for clang-query scripts.

Ella Ma via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 12 02:09:56 PST 2021


OikawaKirie added a comment.

In D98407#2619177 <https://reviews.llvm.org/D98407#2619177>, @njames93 wrote:

> Matchers change over time, so it may be wise to create a script to parse `clang/lib/ASTMatchers/Dynamic/Registry.cpp` and extract the matcher definitions from there. Save manually updating of this.

F15833616: UpdateSyntax.py <https://reviews.llvm.org/F15833616>

I wrote this demo script to extract the matchers from the file `clang/lib/ASTMatchers/Dynamic/Registry.cpp` as you mentioned. However, there are still some missing matchers (`fixedPointLiteral`, `hasAnyBody`, `templateArgumentLoc` and `traverse`) in addition to the two matchers (`findAll` and `equalsNode`) that are mentioned to be missing in the comments of function `RegistryMaps::RegistryMaps`. I am not very sure whether the comment mentioned all of the missing matchers, or I missed some registries other places in this file.

My list of matchers is extracted from the file `clang/docs/LibASTMatchersReference.html` through the following commands.

  pandoc clang/docs/LibASTMatchersReference.html -t markdown - | grep '^\[\(.*\)\]{#.*}' | sed 's/\[\(.*\)]{#.*\}/\1/g' | sort | uniq

And the list generated with the commands above seems more reliable. However, this solution requires `pandoc`, maybe the specific version of mine, and it cannot automatically update the syntax file.

Therefore, I suggest we just add this syntax file and ask other developers to update the HTML document together with the syntax file manually. If we really need such a syntax definition. Or, I can still create a stand-alone repo to provide this syntax file as a plugin.

And just as what has been mentioned by @dblaikie, the extension name also needs to be determined. The`*.cq` name is what I am using. If you have other suggestions, I will update that.

Thanks for the suggestions.



================
Comment at: llvm/utils/vim/ftdetect/clang-query.vim:1
+au BufRead,BufNewfile *.cq set filetype=clang-query
----------------
dblaikie wrote:
> Is there precedent for this file extension? Any concerns about what it might overlap with?
No, there isn't. The test case of clang-query uses `*.script` (e.g. `clang-tools-extra/test/clang-query/Inputs/foo.script`), but it seems not good enough.
Besides, the help message of clang-query does not provide any hints either.

The `*.cq` is what I am using.


================
Comment at: llvm/utils/vim/syntax/clang-query.vim:492
+	\ whileStmt
+	\ withInitializer
+
----------------
dblaikie wrote:
> Guess there's no chance of generating this list from some other existing source-of-truth?
This list was generated from `clang/docs/LibASTMatchersReference.html` :-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98407



More information about the llvm-commits mailing list