Unreal Engine Clangd Utils
An extension for Visual Studio Code designed to configure Unreal Engine C++ projects (including UE 5.7 and 5.8) to work seamlessly with clangd IntelliSense.
Provides fast, accurate, and responsive code completion, navigation, and diagnostics for Unreal Engine C++ code, eliminating the common false-positive "red squiggles" and high CPU usage issues associated with the default Microsoft C++ IntelliSense engine.
Prerequisites
Before using this extension, please ensure your system meets the following requirements:
- Install clangd Toolchain:
- You need the
clangd language server binary on your machine.
- You can download the LLVM/clangd toolchain from LLVM Releases or let VS Code install it automatically.
- Install VS Code Extensions:
- Compile the Project At Least Once:
- Unreal Engine relies heavily on reflection and code generation (creating
*.generated.h files).
- You must compile your project at least once via Unreal Editor or VS Code build tasks before generating the clang database. If you don't compile,
clangd will report errors about missing generated headers.
Key Features
- Automated Clangd Setup: Automatically creates a custom project-specific
.clangd file with optimized compiler arguments, disabled template parsing warnings, and specific diagnostic suppressions for Unreal Engine's macro systems (UCLASS, GENERATED_BODY, etc.).
- Automatic Compile Commands Generation: Locates the
UnrealBuildTool executable and runs it with -mode=GenerateClangDatabase to build compile_commands.json.
- Installed Engine Detection: Finds every installed Unreal Engine version, wherever it is installed, from the Windows registry (Launcher installs and registered source builds) and the Epic Games Launcher install list. It uses the engine matching your project's
EngineAssociation, or the newest installed engine (with a warning) if that version isn't installed.
- Database in the Project Root:
compile_commands.json ends up in your project root, where the clangd language server finds it. Newer engines write it there directly; with older engines it is copied from the Engine root folder.
- Toolchain Fallback: UE 5.x generates the database with Clang by default. If Clang isn't installed, the extension automatically uses the Visual Studio toolchain instead (configurable with
unreal-utils.compiler).
- Full Build Output: UnrealBuildTool's output appears in the Unreal Clangd Utils output panel, and error messages show the reason for a failure.
- Unreal Coding Standard Linting: The generated
.clangd enables clang-tidy checks and compiler warnings that follow the Epic C++ Coding Standard (see Linting).
- Conflict Prevention: Disables Microsoft C/C++ extension's IntelliSense workspace engine (
C_Cpp.intelliSenseEngine = disabled) to prevent duplicate diagnostics, lag, and resource conflicts.
- One-Click UI Controls:
- Status Bar Button: Displays a
Generate Clang Database shortcut button at the bottom of the window.
- Editor Title Button: Shows a database sync icon in the top-right toolbar when editing C++ or
.uproject files for quick regeneration.
- Auto-Run on Startup: Prompts you to run the initial setup automatically if your project is missing a
.clangd file or compile_commands.json upon opening.
How to Use
- First-time Setup:
- Open your Unreal Engine C++ project directory in VS Code.
- If it's a fresh setup, you will see a notification prompting you to configure the project. Click Setup Now.
- Alternatively, open the Command Palette (
Ctrl+Shift+P) and select Unreal Utils: Setup Project for Clangd.
- Updating the Database:
- Whenever you add new C++ files, rename modules, or add new plugin dependencies, the compiler paths change.
- Simply click the Generate Clang Database button on the bottom status bar, or click the Sync Database icon in the editor toolbar (top-right of C++ files) to regenerate and copy
compile_commands.json.
Linting
The generated .clangd turns on these checks, based on the Epic C++ Coding Standard. They appear as warnings in the editor, most with a quick fix.
| Coding standard rule |
Check |
PascalCase names, E prefix for enums, b prefix for booleans, UPPER_CASE macros |
readability-identifier-naming |
| Braces even around single-statement blocks |
readability-braces-around-statements |
nullptr, never NULL |
modernize-use-nullptr |
| Const locals; const methods; pass unmodified arguments by const reference; iterate by const reference |
misc-const-correctness, readability-make-member-function-const, performance-unnecessary-value-param, performance-for-range-copy |
Never const on a by-value return type |
readability-const-return-type |
auto* / const auto& when auto is used |
readability-qualified-auto |
| One variable per declaration |
readability-isolate-declaration |
Every switch has a default |
bugprone-switch-missing-default-case |
enum class instead of plain enums |
cppcoreguidelines-use-enum-class |
int16/int64/... instead of short/long |
google-runtime-int |
No using declarations at global scope in headers |
google-global-names-in-headers |
| C++ casts instead of C-style casts |
google-readability-casting |
Overrides marked override (alongside virtual) |
-Wsuggest-override |
| No shadowed variables |
-Wshadow |
Unreal's own patterns are allowed: K2_, OnRep_ and _Implementation/_Validate function names, the code GENERATED_BODY(), UE_LOG and DOREPLIFETIME expand to. Some rules can't be checked automatically (for example "bool variables must start with b" is allowed but not enforced, and auto restrictions). To change the checks, edit the Diagnostics: ClangTidy: section of .clangd.
Troubleshooting
Issue: Missing *.generated.h files
- Cause: The project hasn't been built yet, or UBT generated the database without building files.
- Solution: Build your project inside Unreal Editor (e.g. click "Live Coding" or Compile) or run a standard build task in VS Code. Once built, restart the
clangd server via the Command Palette (clangd: Restart language server).
- Cause: No installed engine was found in
.vscode/tasks.json, the Windows registry, or the Epic Games Launcher install list (for example, a source build that was never registered with UnrealVersionSelector).
- Solution:
- Open Unreal Editor and select Tools -> Generate Visual Studio Code Project.
- For source builds, register the engine: right-click your
.uproject -> Switch Unreal Engine version... and browse to the engine folder.
- Open VS Code Settings (
Ctrl+,), search for Unreal Build Tool Path, and manually paste the absolute path to your UnrealBuildTool.exe.
Issue: Warning "Project targets Unreal Engine X, which isn't installed"
- Cause: The engine version in your
.uproject (EngineAssociation) isn't installed, so the newest installed engine was used instead.
- Solution: Install the matching engine version, switch the project's engine version (right-click the
.uproject -> Switch Unreal Engine version...), or set Unreal Build Tool Path in settings to pick a specific engine.
Issue: "Clang x64 must be installed in order to build this target"
- Cause: UE 5.x generates the clang database with the Clang toolchain by default, and no supported Clang version is installed (UE 5.8 needs 18.1.8 or newer).
- Solution: With the default
unreal-utils.compiler setting (auto), the extension retries with the Visual Studio toolchain automatically, and clangd works with either. To use Clang, install C++ Clang Compiler for Windows from the Visual Studio Installer, or a supported LLVM release, and set unreal-utils.compiler to Clang.
Issue: Generation failed and the reason isn't clear
- Solution: Click Show Output in the error message, or open the Unreal Clangd Utils output panel (
View -> Output), to see UnrealBuildTool's full output.
Issue: clangd errors like "definition of builtin function '_m_prefetch'" but the project compiles
- Cause: When the project is built with Clang, Unreal's compile commands point clangd at the compiler's own builtin headers (
-resource-dir, e.g. Visual Studio's Clang 19). A newer clangd doesn't match those headers.
- Solution: Run Unreal Utils: Write .clangd Config File (this overwrites
.clangd), or add -resource-dir=* to the CompileFlags: Remove: list in your .clangd. Then run clangd: Restart language server.
Issue: Many false errors after a clean build, or warning "compile_commands.json is out of date"
- Cause: Each entry in
compile_commands.json keeps its flags in a response file under Intermediate/ (cl.exe @File.cpp.obj.rsp). If Intermediate is cleaned, those files are gone and clangd has no include paths or defines.
- Solution: Click Regenerate in the warning, or click Generate Clang Database in the status bar.
- Cause: Microsoft's C/C++ extension IntelliSense is still running.
- Solution: Ensure your workspace settings file (
.vscode/settings.json) contains "C_Cpp.intelliSenseEngine": "disabled". This extension attempts to set this automatically during initial setup.
Extension Settings
This extension contributes the following settings:
unreal-utils.unrealBuildToolPath: Custom path to the UnrealBuildTool executable. If empty, the extension will auto-resolve it from .vscode/tasks.json, the Windows registry, or the Epic Games Launcher install list.
unreal-utils.targetName: Custom project target name (e.g. MyGameEditor). If left empty, it auto-detects based on the .Target.cs files in your Source/ folder.
unreal-utils.buildConfiguration: The build configuration to use when generating compile commands (defaults to Development).
unreal-utils.buildPlatform: The target platform (defaults to Win64).
unreal-utils.autoRunOnStartup: Toggles whether the extension prompts you to run setup if configurations are missing on startup (default: true).
unreal-utils.useNoExecCodeGenActions: Appends the -NoExecCodeGenActions flag to the UBT command to significantly speed up database generation (default: true).
unreal-utils.compiler: Toolchain for generating the database: auto (default; UBT's default, falling back to Visual Studio if Clang isn't installed), Clang, or VisualStudio.
Release Notes
See CHANGELOG.md for the release history.
License
MIT License. Copyright (c) 2026 Siddartha Gonnabattula.
| |