LLVM

Clang Plugins & Refactoring Tools

Advanced code transformation techniques using LLVM's Clang plugin infrastructure

Start Refactoring Tutorial

Key Concepts

AST Navigation

Use Clang's AST to traverse and modify code structure with precise transformations.

Learn AST Techniques →

Transformation Passes

Implement refactoring operations through Clang's rewrite engine for source code changes.

View Passes →

Interactive Tools

Build IDE-integrated refactoring tools using clang-tidy and clang-format APIs.

Tooling Guide →

Extract Method Example

// clang-refactor.cpp
#include "clang/Tooling/Tooling.h"
#include "clang/Refactoring/RefactoringActions.h"

using namespace clang::tooling;
using namespace clang::refactor;

class ExtractMethod : public RefactoringAction {
protected:
  int runAction() override {
    // Implementation
    return 0;
  }
};

int main(int argc, const char** argv) {
  CommonOptionsParser options(argc, argv);
  return runToolOnCode(<Extractor>, options.getCompilations(), options.getSourcePathList());
}

Refactoring Tutorials

Code Extraction

Learn to create plugins that refactor large code bodies into smaller functions.

View Tutorial

Safe Rename

Build rename tools that handle cross-file name propagation and semantic validation.

View Tutorial

Contribute a Refactoring Tool

Help expand Clang's refactoring capabilities with your code transformation ideas.

Submit Your Plugin