Refactor with Clang Tooling at code::dive 2018

I delivered a talk about writing a refactoring tool with Clang Tooling at code::dive in November. It was uploaded to YouTube today:

The slides are available here and the code samples are here.

This was a fun talk to deliver as I got to demo some features which had never been seen by anyone before. For people who are already familiar with clang-tidy and clang-query, the interesting content starts about 15 minutes in. There I start to show new features in the clang-query interpreter command line.

The existing clang-query interpreter lacks many features which the replxx library provides, such as syntax highlighting and portable code completion:

It also allows scrolling through results to make a selection:

A really nice feature is value-based code-completion instead of type-based code completion. Existing code completion only completes candidates based on type-compatibility. It recognizes that a parameterCountIs() matcher can be used with a functionDecl() matcher for example. If the code completion already on the command line is sufficiently constrained so that there is only one result already, the code completion is able to complete candidates based on that one result node:

Another major problem with clang-query currently is that it is hard to know which parenthesis represents the closing of which matcher. The syntax highlighting of replxx help with this, along with a brace matching feature I wrote for it:

I’m working on upstreaming those features to replxx and Clang to make them available for everyone, but for now it is possible to experiment with some of the features on my Compiler Explorer instance on ce.steveire.com.

I wrote about the AST-Matcher and Source Location/Source Range discovery features on my blog here since delivering the talk. I also wrote about Composing AST Matchers, which was part of the tips and tricks section of the talk. Over on the Visual C++ blog, I wrote about distributing the refactoring task among computers on the network using Icecream. My blogs on that platform can be seen in the Clang category.

All of that blog content is repeated in the code::dive presentation, but some people prefer to learn from conference videos instead of blogs, so this might help the content reach a larger audience. Let me know if there is more you would like to see about clang-query!

Advertisements

10 Responses to “Refactor with Clang Tooling at code::dive 2018”

  1. Daniel Kim Says:

    Your presentation material link is broken. You linked “steveire.com/CodeDive2018Presentation.pdf” but it opens “https://steveire.wordpress.com/2019/01/02/refactor-with-clang-tooling-at-codedive-2018/steveire.com/CodeDive2018Presentation.pdf” in chrome.
    I already got pdf from “https://steveire.com/CodeDive2018Presentation.pdf”. I just want to let you know because this presentation is interesting.

  2. steveire Says:

    Thanks, I fixed the link!

  3. Yitzhak Mandelbaum Says:

    Steve, you mentioned in the talk (IIRC) a way to avoid matching against code that is generated by the compiler (like generated constructors/methods and range-fors). Can you expand on that? Have you augmented the AST to expose this property and/or added controls for how matchers work (which I remember us discussing on the bug for ignoreImplicit())?

  4. Ubuntu Weekly Newsletter Issue 560 – Mags Forum Technology Says:

    […] https://steveire.wordpress.com/2019/…codedive-2018/ […]

  5. Sys Says:

    Impressive!

  6. vps for gsa search engine ranker reviews Says:

    Gsa Vps Server

    Refactor with Clang Tooling at code::dive 2018 | Steveire

  7. tech blog search Says:

    blog Techno

    Refactor with Clang Tooling at code::dive 2018 | Steveire

  8. tech blogspot Says:

    best blog designs 2019

    Refactor with Clang Tooling at code::dive 2018 | Steveire

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s


%d bloggers like this: