llvm-tooling
Expertise in LLVM tooling development including Clang plugins, LLDB debugger extensions, Clangd/LSP, and LibTooling. Use this skill when building source code analysis tools, refactoring tools, debugger extensions, or IDE integrations.
Install
mkdir -p .claude/skills/llvm-tooling && curl -L -o skill.zip "https://mcp.directory/api/skills/download/2792" && unzip -o skill.zip -d .claude/skills/llvm-tooling && rm skill.zipInstalls to .claude/skills/llvm-tooling
About this skill
LLVM Tooling Skill
This skill covers development of tools using LLVM/Clang infrastructure for source code analysis, debugging, and IDE integration.
Clang Plugin Development
Plugin Architecture
Clang plugins are dynamically loaded libraries that extend Clang's functionality during compilation.
#include "clang/Frontend/FrontendPluginRegistry.h"
#include "clang/AST/ASTConsumer.h"
#include "clang/AST/RecursiveASTVisitor.h"
class MyVisitor : public clang::RecursiveASTVisitor<MyVisitor> {
public:
bool VisitFunctionDecl(clang::FunctionDecl *FD) {
llvm::outs() << "Found function: " << FD->getName() << "\n";
return true;
}
};
class MyConsumer : public clang::ASTConsumer {
MyVisitor Visitor;
public:
void HandleTranslationUnit(clang::ASTContext &Context) override {
Visitor.TraverseDecl(Context.getTranslationUnitDecl());
}
};
class MyPlugin : public clang::PluginASTAction {
protected:
std::unique_ptr<clang::ASTConsumer> CreateASTConsumer(
clang::CompilerInstance &CI, llvm::StringRef) override {
return std::make_unique<MyConsumer>();
}
bool ParseArgs(const clang::CompilerInstance &CI,
const std::vector<std::string> &args) override {
return true;
}
};
static clang::FrontendPluginRegistry::Add<MyPlugin>
X("my-plugin", "My custom plugin description");
Running Clang Plugins
# Build plugin
clang++ -shared -fPIC -o MyPlugin.so MyPlugin.cpp \
$(llvm-config --cxxflags --ldflags)
# Run plugin
clang -Xclang -load -Xclang ./MyPlugin.so \
-Xclang -plugin -Xclang my-plugin \
source.cpp
LibTooling
Standalone Tools
#include "clang/Tooling/CommonOptionsParser.h"
#include "clang/Tooling/Tooling.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"
using namespace clang::tooling;
using namespace clang::ast_matchers;
// Define matcher
auto functionMatcher = functionDecl(hasName("targetFunction")).bind("func");
// Callback handler
class FunctionCallback : public MatchFinder::MatchCallback {
public:
void run(const MatchFinder::MatchResult &Result) override {
if (auto *FD = Result.Nodes.getNodeAs<FunctionDecl>("func")) {
llvm::outs() << "Found: " << FD->getQualifiedNameAsString() << "\n";
}
}
};
int main(int argc, const char **argv) {
auto ExpectedParser = CommonOptionsParser::create(argc, argv, MyCategory);
ClangTool Tool(ExpectedParser->getCompilations(),
ExpectedParser->getSourcePathList());
FunctionCallback Callback;
MatchFinder Finder;
Finder.addMatcher(functionMatcher, &Callback);
return Tool.run(newFrontendActionFactory(&Finder).get());
}
AST Matchers Reference
// Declaration matchers
functionDecl() // Match function declarations
varDecl() // Match variable declarations
recordDecl() // Match struct/class/union
fieldDecl() // Match class fields
cxxMethodDecl() // Match C++ methods
cxxConstructorDecl() // Match constructors
// Expression matchers
callExpr() // Match function calls
binaryOperator() // Match binary operators
unaryOperator() // Match unary operators
memberExpr() // Match member access
// Narrowing matchers
hasName("name") // Filter by name
hasType(asString("int")) // Filter by type
isPublic() // Filter by access specifier
hasAnyParameter(...) // Match parameters
// Traversal matchers
hasDescendant(...) // Match anywhere in subtree
hasAncestor(...) // Match in parent chain
has(...) // Match direct children
forEach(...) // Match all children
LLDB Extension Development
Python Commands
import lldb
def my_command(debugger, command, result, internal_dict):
"""Custom LLDB command implementation"""
target = debugger.GetSelectedTarget()
process = target.GetProcess()
thread = process.GetSelectedThread()
frame = thread.GetSelectedFrame()
# Get variable value
var = frame.FindVariable("my_var")
result.AppendMessage(f"my_var = {var.GetValue()}")
def __lldb_init_module(debugger, internal_dict):
debugger.HandleCommand(
'command script add -f my_module.my_command my_cmd')
Scripted Process
class MyScriptedProcess(lldb.SBScriptedProcess):
def __init__(self, target, args):
super().__init__(target, args)
def get_thread_with_id(self, tid):
# Return thread info
pass
def get_registers_for_thread(self, tid):
# Return register context
pass
def read_memory_at_address(self, addr, size):
# Read memory
pass
LLDB GUI Extensions
- visual-lldb: GUI frontend for LLDB
- vegvisir: Browser-based LLDB GUI
- lldbg: Lightweight native GUI
- CodeLLDB: VSCode debugger extension
Clangd / Language Server Protocol
Custom LSP Extensions
// Implementing custom code actions
class MyCodeActionProvider {
public:
std::vector<CodeAction> getCodeActions(
const TextDocumentIdentifier &File,
const Range &Range,
const CodeActionContext &Context) {
std::vector<CodeAction> Actions;
// Add custom refactoring action
CodeAction Action;
Action.title = "Extract to function";
Action.kind = "refactor.extract";
// Define workspace edits
WorkspaceEdit Edit;
// ... populate edits
Action.edit = Edit;
Actions.push_back(Action);
return Actions;
}
};
Clangd Configuration
# .clangd configuration file
CompileFlags:
Add: [-xc++, -std=c++17]
Remove: [-W*]
Diagnostics:
ClangTidy:
Add: [modernize-*, performance-*]
Remove: [modernize-use-trailing-return-type]
Index:
Background: Build
Source-to-Source Transformation
Clang Rewriter
#include "clang/Rewrite/Core/Rewriter.h"
class MyRewriter : public RecursiveASTVisitor<MyRewriter> {
Rewriter &R;
public:
MyRewriter(Rewriter &R) : R(R) {}
bool VisitFunctionDecl(FunctionDecl *FD) {
// Add comment before function
R.InsertTextBefore(FD->getBeginLoc(), "// Auto-generated\n");
// Replace function name
R.ReplaceText(FD->getLocation(),
FD->getName().size(), "new_name");
return true;
}
};
RefactoringTool
#include "clang/Tooling/Refactoring.h"
class MyRefactoring : public RefactoringCallback {
public:
void run(const MatchFinder::MatchResult &Result) override {
// Generate replacements
Replacement Rep(
*Result.SourceManager,
CharSourceRange::getTokenRange(Range),
"new_text");
Replacements.insert(Rep);
}
};
Notable Tools Built with LLVM Tooling
Analysis Tools
- cppinsights: C++ template instantiation visualization
- ClangBuildAnalyzer: Build time analysis
- clazy: Qt-specific static analysis
Refactoring Tools
- clang-rename: Symbol renaming
- clang-tidy: Linting and auto-fixes
- include-what-you-use: Include optimization
Code Generation
- classgen: Extract type info for IDA
- constexpr-everything: Auto-apply constexpr
- clang-expand: Inline function expansion
Best Practices
- Use AST Matchers: More readable than manual traversal
- Preserve Formatting: Use Rewriter carefully to maintain style
- Handle Macros: Be aware of macro expansion locations
- Test Thoroughly: Edge cases in C++ are numerous
- Provide Good Diagnostics: Clear error messages improve usability
Resources
See Clang Plugins, Clangd/Language Server, and LLDB sections in README.md for comprehensive tool listings.
Getting Detailed Information
When you need detailed and up-to-date resource links, tool lists, or project references, fetch the latest data from:
https://raw.githubusercontent.com/gmh5225/awesome-llvm-security/refs/heads/main/README.md
This README contains comprehensive curated lists of:
- Clang plugins and extensions (Clang Plugins section)
- Language server implementations (Clangd/Language Server section)
- LLDB debugger tools and GUIs (LLDB section)
- Static analysis and refactoring tools
More by gmh5225
View all skills by gmh5225 →You might also like
flutter-development
aj-geddes
Build beautiful cross-platform mobile apps with Flutter and Dart. Covers widgets, state management with Provider/BLoC, navigation, API integration, and material design.
drawio-diagrams-enhanced
jgtolentino
Create professional draw.io (diagrams.net) diagrams in XML format (.drawio files) with integrated PMP/PMBOK methodologies, extensive visual asset libraries, and industry-standard professional templates. Use this skill when users ask to create flowcharts, swimlane diagrams, cross-functional flowcharts, org charts, network diagrams, UML diagrams, BPMN, project management diagrams (WBS, Gantt, PERT, RACI), risk matrices, stakeholder maps, or any other visual diagram in draw.io format. This skill includes access to custom shape libraries for icons, clipart, and professional symbols.
ui-ux-pro-max
nextlevelbuilder
"UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 8 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient."
godot
bfollington
This skill should be used when working on Godot Engine projects. It provides specialized knowledge of Godot's file formats (.gd, .tscn, .tres), architecture patterns (component-based, signal-driven, resource-based), common pitfalls, validation tools, code templates, and CLI workflows. The `godot` command is available for running the game, validating scripts, importing resources, and exporting builds. Use this skill for tasks involving Godot game development, debugging scene/resource files, implementing game systems, or creating new Godot components.
nano-banana-pro
garg-aayush
Generate and edit images using Google's Nano Banana Pro (Gemini 3 Pro Image) API. Use when the user asks to generate, create, edit, modify, change, alter, or update images. Also use when user references an existing image file and asks to modify it in any way (e.g., "modify this image", "change the background", "replace X with Y"). Supports both text-to-image generation and image-to-image editing with configurable resolution (1K default, 2K, or 4K for high resolution). DO NOT read the image file first - use this skill directly with the --input-image parameter.
fastapi-templates
wshobson
Create production-ready FastAPI projects with async patterns, dependency injection, and comprehensive error handling. Use when building new FastAPI applications or setting up backend API projects.
Related MCP Servers
Browse all serversDesktop Commander MCP unifies code management with advanced source control, git, and svn support—streamlining developmen
Unlock AI-powered automation for Postman for API testing. Streamline workflows, code sync, and team collaboration with f
Get expert React Native software guidance with tools for component analysis, performance, debugging, and migration betwe
Probe Kit offers 23 essential tools for IDE's, app dev, and mobile app dev, streamlining project management and code qua
Streamline your team software process with Spec-Driven Development, optimizing the software development life cycle using
Streamline your software development life cycle with Spec-Driven Development: organized specs, template-driven code, and
Stay ahead of the MCP ecosystem
Get weekly updates on new skills and servers.