Skip to content

JayTwoLab/hello_llvm_clang

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LLVM/Clang Demo Project

  • Korean README

  • This project is a minimal/complete template that includes an LLVM/Clang-based C++ compilation environment, VSCode development setup, and example code utilizing the latest C++20~26 features.

  • It is designed to work with the same structure on both Windows and Linux.



1. Project Structure Overview

  • This project includes:
    • CMake-based build system
    • Enforced clang / clang++ usage configuration
    • C++26 compilation enabled
    • LLD linker usage (-fuse-ld=lld)
    • VSCode development environment setup (IntelliSense, clangd, LLDB DAP)
    • Example code (main.cpp) using C++20/23/26 features


2. Key File Descriptions

2.1 CMakeLists.txt

  • Prioritizes the LLVM_HOME environment variable
    • Automatically uses C:/llvm-package on Windows
  • Forces clang, clang++ as CMAKE_C_COMPILER / CMAKE_CXX_COMPILER
  • Uses LLD linker (-fuse-ld=lld)
  • Enables C++26 compilation (target_compile_features(... cxx_std_26))
  • Automatically generates compile_commands.json

This is an ideal basic structure for VSCode + clangd users.



2.2 Example (main.cpp)

  • C++20 ranges / views / std::format
  • C++23 std::expected
  • C++26 deducing this syntax applied (Point::move)
  • Includes advanced examples (filtering, transformation, join view, structured message generation, etc.)

  • This single file allows you to verify actual execution examples of C++20~26 features.


2.3 VSCode Configuration Files

2.3.1 c_cpp_properties.json

  • Sets IntelliSense engine to clang-based
  • Automatically references compile_commands.json
  • Basic includePath configuration

2.3.2 extensions.json

  • Automatically recommends the following extensions:
    • ms-vscode.cmake-tools
    • ms-vscode.cpptools
    • llvm-vs-code-extensions.vscode-clangd

2.3.3 launch.json

  • LLDB-DAP-based debugging configuration
  • Automatic executable branching by OS (Windows uses hello.exe)

2.3.4 settings.json

  • CMake generator = Ninja
  • Sets clang++ as the default IntelliSense compiler
  • editor.formatOnSave option

2.3.5 tasks.json

  • CMake Configure
  • CMake Build
  • VSCode build automation configuration


3. Build and Execution Instructions

3.1 Common for Windows / Linux

cmake -S . -B build -G Ninja
cmake --build build --config Debug

3.2 Execution

Linux

./build/hello

Windows

.\build\hello.exe


4. Debugging (VSCode)

  • (1) Install Extensions

    • ms-vscode.cmake-tools
    • llvm-vs-code-extensions.vscode-clangd
    • llvm-vs-code-extensions.lldb-dap
  • (2) VSCode left sidebar Run/Debug menu → Run Debug (lldb-dap)



5. C++ Example Code Features

  • Actual executable examples of C++20 / C++23 / C++26 key new features
  • Includes all of ranges, views, format, expected
  • Uses operator chaining style with "deducing this" syntax
  • Assembles example messages into strings for output in main


6. Project Structure

project_root/
│  CMakeLists.txt
│  main.cpp
│
├─ .vscode/
│   ├─ c_cpp_properties.json
│   ├─ extensions.json
│   ├─ launch.json
│   ├─ settings.json
│   └─ tasks.json
│
└─ build/ (generated by cmake)


7. Use Cases for This Template

  • LLVM/Clang development environment testing
  • Experimenting with latest C++ standards (C++20~C++26)
  • Basic structure for C++ projects based on VSCode + clangd + LLDB
  • CMake-based multi-platform template


8. License

  • MIT

About

LLVM, Clang, VSCode Demo Project

Resources

License

Stars

Watchers

Forks

Packages

No packages published