Heres my compile_commands.json :
{ "directory": "/data/data/com.termux/files/home/cpulator", "file": "allocator.cc", "output": "allocator.o", "arguments": ["/data/data/com.termux/files/usr/bin/clang-16", "-xc++", "--sysroot=/data/data/com.termux/files", "events.cc", "-o", "events.o", "--target=arm-altera-eabi", "-nostdlib", "-Wall", "-Wextra", "-Wpedantic", "-c", "-O0", "-gdwarf-4", "-fno-exceptions", "-fno-rtti", "-fno-inline", "--target=armv4t-altera-unknown-eabi"]}
When I run clang-tidy allocator.cc
, it acts as if it cant detect the compile_commands.json file.
Error message:
Error while trying to load a compilation database:
Could not auto-detect compilation database from directory "/data/data/com.termux/files/home/cpulator"
No compilation database found in /data/data/com.termux/files/home/cpulator or any parent directory
fixed-compilation-database: Error while opening fixed database: No such file or directory
json-compilation-database: Expected array.
How do I fix this?
The error message:
comes from
JSONCompilationDatabase.cpp
:It means the
compilation_database.json
file was found, but did not begin with the required square bracket character[
.The documentation of the
compile_commands.json
format explains (emphasis mine):To fix your
compile_commands.json
file, simply insert[
at the start and]
at the end.