A tiny Clang LibTooling utility that parses C++ source files into an AST, finds every function/method/constructor call, and reports whether the callee is noexcept.
The tool prints a CSV to stdout, which you can redirect to a file.
Columns:
file,line,col,kind,qualified-name,noexcept,signature,callee-source
- Walks calls to free functions, member methods, constructors, and overloaded operators
- Evaluates
noexceptviaFunctionProtoType::isNothrow() - Optional filters:
--only-std— keep only calls whose qualified name starts withstd::--name-prefix <prefix>— keep only calls with a given qualified-name prefix (e.g.,std::filesystem::)--csv-header— print a header row
- (By default) system headers are excluded; you can tweak the matcher in the source if you need them
- CMake ≥ 3.20
- A working LLVM/Clang development environment (headers + libs)
- Rocky/Red Hat example:
sudo dnf install clang clang-devel llvm llvm-devel libedit-devel libffi-devel libxml2-devel zlib-devel libzstd-devel
- Ubuntu example:
sudo apt install clang libclang-dev llvm-dev libedit-dev libffi-dev libxml2-dev zlib1g-dev libzstd-dev
- Rocky/Red Hat example:
# from the project root
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -jThis will produce an executable (e.g., build/std_call_scan).
-
(1) Download LLVM and Clang from the following site:
-
Files (install the latest version.
amd64: 64-bit,msvc17: VS2022)- llvm-x.x.x-windows-
amd64-msvc17-XXX.7z - clang-x.x.x-windows-
amd64-msvc17-XXX.7z
- llvm-x.x.x-windows-
-
(2) Extract them to the same path.
- Assume extraction to
C:\llvm-package.
- Assume extraction to
-
(3) Set environment variables as follows:
PATH:C:\llvm-package\binLLVM_DIR:C:\llvm-package\lib\cmake\llvmClang_DIR:C:\llvm-package\lib\cmake\clang
-
(4) Run
cmakein the Visual Studio command prompt (make sureninjais pre-installed):mkdir build && cd build cmake -G Ninja ^ -DCMAKE_BUILD_TYPE=Release ^ -DCMAKE_C_COMPILER=clang-cl ^ -DCMAKE_CXX_COMPILER=clang-cl ^ -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDLL ^ -DLLVM_DIR="C:/llvm-package/lib/cmake/llvm" ^ -DClang_DIR="C:/llvm-package/lib/cmake/clang" ^ ..
-
One-line command:
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDLL -DLLVM_DIR="C:/llvm-package/lib/cmake/llvm" -DClang_DIR="C:/llvm-package/lib/cmake/clang" ..
-
-
(5) Execute build:
ninja -v
# Edit variable in build_scan_env.sh, before execute script
./sh/build_scan_env.sh- file: source file path containing the call site
- line, col: 1‑based position of the call site
- kind:
call(free function),method(member),construct(constructor),opcall(operator call), etc. - qualified-name: fully qualified callee name (e.g.,
std::filesystem::create_directory) - noexcept:
1if the callee is nothrow (per Clang's type system),0otherwise - signature: a pretty function signature
- callee-source: a short source snippet of the call expression
⚠️ Notes & Limitations
- Results can vary by standard library implementation (libstdc++/libc++/MSVC STL) and template instantiation.
- System headers are excluded by default; edit the matcher in
scanner.cppif you want to include them.- The
noexceptresult reflects the callee type as seen by Clang; it does not run your code.
# Current project file as a smoke test
./build/std_call_scan --csv-header scanner.cppSee LICENSE.