Skip to content

Instantly share code, notes, and snippets.

Clangd Matcher Generation LSP Extension

Overview

This document outlines a plan for extending the Language Server Protocol (LSP) to enable editors to obtain clang-query matcher strings for code at the cursor position. This feature will help developers generate matcher expressions that can be used as the basis for clang-tidy checks or standalone clang-query queries.

Table of Contents

  1. Motivation
  2. Design Goals
@LegalizeAdulthood
LegalizeAdulthood / TransformerTextLanguage.md
Created November 7, 2025 03:00
Transformer Text Language Design Plan

Transformer Text Language Design Plan

Executive Summary

This document outlines a plan for creating a text input language to describe transformer library expressions (ASTEdits and associated components) that are passed to makeRule. This language would be analogous to clang-query's text input language for AST matchers, enabling declarative specification of code transformations.

Background

Current State

  • clang-query: Provides text-based matcher specification (e.g., match functionDecl())
@LegalizeAdulthood
LegalizeAdulthood / custom-clang-tidy.md
Last active November 6, 2025 07:03
Configurable Replacement Check Plan for clang-tidy

Configurable Replacement Check Plan for clang-tidy

Overview

This document outlines a comprehensive plan for implementing a configurable clang-tidy check that combines:

  1. AST Matching: Uses clang-query-style matcher expressions to select AST nodes
  2. Node Binding: Binds matched AST nodes to named identifiers
  3. Template Replacement: Uses Transformer's Stencil system for code generation
  4. Fix-it Generation: Generates suggested fix-its for matched code patterns

This check type enables users to define custom refactoring rules through configuration without writing C++ code.

@LegalizeAdulthood
LegalizeAdulthood / NuGetCaching.md
Last active April 29, 2025 15:54
Using NuGet Package Caching with VcPkg and GitHub Actions

Using NuGet Package Caching with VcPkg and GitHub Actions

The GitHub Actions Cache mechanism has been removed from vcpkg, so you can't use x-gha in VCPKG_BINARY_SOURCES as a way to re-use built products from one build to the next anymore. I was using x-gha because the setup was trivial for all platforms: just set a couple environment variables.

You can use NuGet packages to achieve the same purpose, although the setup is a little more complicated. Here's what I learned while setting this up for the first time for use with GitHub Actions.

1. GitHub Classic Personal Access Token

@LegalizeAdulthood
LegalizeAdulthood / ReadMe.md
Last active April 2, 2025 21:48
Simple vcpkg overlay setup

Simple vcpkg Overlay Ports Setup

The file vcpkg-configuration.json uses an existing vcpkg as the default registry; this assumes vcpkg as a git submodule. The baseline value is the commit hash of the vcpkg submodule. Update the hash as needed to reflect the actual version of the vcpkg registry you've got checked out as a submodule.

Overlay Ports

Use a directory vcpkg-overlays to contain the overlay ports;

@LegalizeAdulthood
LegalizeAdulthood / asm-dump.md
Created January 7, 2025 16:51
Disassemble an Object File with MSVC Linker
@LegalizeAdulthood
LegalizeAdulthood / CMakePresets.json
Last active March 13, 2024 07:47
clang CMake Presets
{
"version": 6,
"cmakeMinimumRequired": {
"major": 3,
"minor": 23,
"patch": 0
},
"configurePresets": [
{
"name": "sibling-build-preset",
@LegalizeAdulthood
LegalizeAdulthood / latest-cmake.sh
Last active February 21, 2024 15:49
Install latest CMake on ubuntu
# run this script with sudo
# From <https://askubuntu.com/questions/355565/how-do-i-install-the-latest-version-of-cmake-from-the-command-line>
apt remove --purge --auto-remove cmake
apt update
apt install -y software-properties-common lsb-release && \
apt clean all
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null
apt-add-repository "deb https://apt.kitware.com/ubuntu/ $(lsb_release -cs) main"
apt update
apt install kitware-archive-keyring
@LegalizeAdulthood
LegalizeAdulthood / PortingFromMFCToWxWidgets.md
Last active November 15, 2025 17:31
Porting from MFC to wxWidgets
@LegalizeAdulthood
LegalizeAdulthood / SpaceshipOperator.txt
Last active January 4, 2022 03:04
A counterintuitive breaking change related to new comparisons C++17 vs. C++20
comp.lang.c++ #1074341 (1)
From: Andrey Tarasevich <[email protected]>
[1] A counterintuitive breaking change related to new comparisons
Date: Mon Jan 03 10:48:42 MST 2022
Lines: 42
A colleague discovered that switching from `-stc=c++17` to `-std=c++20`
in their project resulted in a different behavior from some associative
containers. A bit of research allowed to narrow down the culprit to what
can be demonstrated by the following minimalist example