# The compile\_commands.json is not usable with run-clang-tidy

**URL:** https://discourse.cmake.org/t/the-compile-commands-json-is-not-usable-with-run-clang-tidy/13565
**Category:** Development
**Tags:** os:windows
**Created:** [February 12, 2025, 10:05am UTC](https://discourse.cmake.org/t/the-compile-commands-json-is-not-usable-with-run-clang-tidy/13565 "2025-02-12T10:05:05Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![ClausKlein](https://discourse.cmake.org/user_avatar/discourse.cmake.org/clausklein/32/352_2.png) [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)
#### Post date: [February 12, 2025, 10:05am UTC](https://discourse.cmake.org/t/the-compile-commands-json-is-not-usable-with-run-clang-tidy/13565/1 "2025-02-12T10:05:05Z")

</div>

With `cmake v3.30.4` generated `compile_commands.json` file:

```json
[
{
  "directory": "C:/Users/KLEIN_CL/Workspace/cmake/ModernCmakeStarter/build/user",
  "command": "C:\\PROGRA~1\\MIB055~1\\2022\\PROFES~1\\VC\\Tools\\Llvm\\bin\\CLANG_~1.EXE -DFMT_HEADER_ONLY=1 -IC:/Users/KLEIN_CL/Workspace/cmake/ModernCmakeStarter/build/user/PackageProjectInclude -isystem C:/Users/KLEIN_CL/Workspace/cmake/ModernCmakeStarter/include -isystem C:/Users/KLEIN_CL/Workspace/cmake/ModernCmakeStarter/build/user/_deps/fmt-src/include -O3 -DNDEBUG -std=c++20 -D_DLL -D_MT -Xclang --dependent-lib=msvcrt -fcolor-diagnostics @CMakeFiles\\greeter.dir\\source\\greeter.cpp.obj.modmap -o CMakeFiles\\greeter.dir\\source\\greeter.cpp.obj -c C:\\Users\\KLEIN_CL\\Workspace\\cmake\\ModernCmakeStarter\\source\\greeter.cpp",
  "file": "C:\\Users\\KLEIN_CL\\Workspace\\cmake\\ModernCmakeStarter\\source\\greeter.cpp",
  "output": "CMakeFiles\\greeter.dir\\source\\greeter.cpp.obj"
}
]

```

I get the following error on windows:

````auto
C:\Users\KLEIN_CL\Workspace\cmake\ModernCmakeStarter>python.exe "C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/Llvm/bin/run-clang-tidy" -p build/user source\greeter.cpp

.```

Traceback (most recent call last):
  File "C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\Llvm\bin\run-clang-tidy", line 537, in <module>
    main()
  File "C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\Llvm\bin\run-clang-tidy", line 470, in main
    file_name_re = re.compile("|".join(args.files))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\RsPython\3.12\Lib\re\ __init__.py", line 228, in compile
    return _compile(pattern, flags)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\RsPython\3.12\Lib\re\ __init__.py", line 307, in _compile
    p = _compiler.compile(pattern, flags)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\RsPython\3.12\Lib\re\_compiler.py", line 743, in compile
    p = _parser.parse(p, flags)
        ^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\RsPython\3.12\Lib\re\_parser.py", line 972, in parse
    p = _parse_sub(source, state, flags & SRE_FLAG_VERBOSE, 0)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\RsPython\3.12\Lib\re\_parser.py", line 453, in _parse_sub
    itemsappend(_parse(source, state, verbose, nested + 1,
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\RsPython\3.12\Lib\re\_parser.py", line 537, in _parse
    code = _escape(source, this, state)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\RsPython\3.12\Lib\re\_parser.py", line 436, in _escape
    raise source.error("bad escape %s" % escape, len(escape))
re.error: bad escape \g at position 6

````

---

<div class="post-metadata">

### Author: ![ClausKlein](https://discourse.cmake.org/user_avatar/discourse.cmake.org/clausklein/32/352_2.png) [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)
#### Post date: [February 12, 2025, 10:10am UTC](https://discourse.cmake.org/t/the-compile-commands-json-is-not-usable-with-run-clang-tidy/13565/2 "2025-02-12T10:10:24Z")

</div>

with possix pathes it works fine:

> “file”: “C:/Users/KLEIN\_CL/Workspace/cmake/ModernCmakeStarter/source/greeter.cpp”,

@ben.boeckel what is the reason to generate mixed path separation for **directory** and **file** items?

see too [https://gitlab.kitware.com/cmake/cmake/-/merge\_requests/10357](https://gitlab.kitware.com/cmake/cmake/-/merge_requests/10357)

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [July 20, 2025, 2:26am UTC](https://discourse.cmake.org/t/the-compile-commands-json-is-not-usable-with-run-clang-tidy/13565/3 "2025-07-20T02:26:30Z")

</div>

I suspect this has been fixed by the mentioned MR. As for reason: oversight.
