Open kanihal opened 2 years ago
@PiotrZSL @gavinchou - Any idea on how to resolve this issue?
How did you generate that compilation database? It looks like clang's compilation database parser don't support extra key.
Also your version of LLVM is quite old, perhaps output is a recent addition. (I have no idea about that, just a guess. Upgrading clang might or might not help)
@ogoffart
How did you generate that compilation database?
Since postgres is not a cmake project, I generated compile_commands.json
using bear(https://github.com/rizsotto/Bear).
$ cd postgres
$ bear -- ./configure
$ bear -- make
Also your version of LLVM is quite old, ...
I had installed codebrowser_generator using .deb
file linked in the woboq website: https://woboq.com/codebrowser-download.html. This is a very old build as you mentioned.
I also tried building codebrowser with LLVM-13(latest version). I get the following error while compiling,
$ cd codebrowser
$ cmake . -DCMAKE_BUILD_TYPE=Release
$ make
[ 8%] Building CXX object generator/CMakeFiles/codebrowser_generator.dir/main.cpp.o
In file included from /home/jagadeesha/Downloads/codebrowser/generator/main.cpp:39:
/home/jagadeesha/Downloads/codebrowser/generator/browserastvisitor.h: In member function ‘bool BrowserASTVisitor::VisitEnumConstantDecl(clang::EnumConstantDecl*)’:
/home/jagadeesha/Downloads/codebrowser/generator/browserastvisitor.h:132:130: error: no matching function for call to ‘llvm::APSInt::toString(int) const’
132 | otator.registerReference(d, d->getLocation(), Annotator::EnumDecl, Annotator::Declaration, d->getInitVal().toString(10));
| ^
In file included from /usr/lib/llvm-13/include/clang/AST/Type.h:34,
from /usr/lib/llvm-13/include/clang/AST/CanonicalType.h:17,
from /usr/lib/llvm-13/include/clang/AST/ASTContext.h:19,
from /usr/lib/llvm-13/include/clang/Frontend/ASTUnit.h:17,
from /usr/lib/llvm-13/include/clang/Frontend/FrontendAction.h:23,
from /usr/lib/llvm-13/include/clang/Frontend/FrontendActions.h:12,
from /home/jagadeesha/Downloads/codebrowser/generator/main.cpp:24:
/usr/lib/llvm-13/include/llvm/ADT/APSInt.h:82:8: note: candidate: ‘void llvm::APSInt::toString(llvm::SmallVectorImpl<char>&, unsigned int) const’
82 | void toString(SmallVectorImpl<char> &Str, unsigned Radix = 10) const {
| ^~~~~~~~
/usr/lib/llvm-13/include/llvm/ADT/APSInt.h:82:40: note: no known conversion for argument 1 from ‘int’ to ‘llvm::SmallVectorImpl<char>&’
82 | void toString(SmallVectorImpl<char> &Str, unsigned Radix = 10) const {
| ~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/lib/llvm-13/include/clang/AST/Type.h:33,
from /usr/lib/llvm-13/include/clang/AST/CanonicalType.h:17,
from /usr/lib/llvm-13/include/clang/AST/ASTContext.h:19,
from /usr/lib/llvm-13/include/clang/Frontend/ASTUnit.h:17,
from /usr/lib/llvm-13/include/clang/Frontend/FrontendAction.h:23,
from /usr/lib/llvm-13/include/clang/Frontend/FrontendActions.h:12,
from /home/jagadeesha/Downloads/codebrowser/generator/main.cpp:24:
/usr/lib/llvm-13/include/llvm/ADT/APInt.h:1741:8: note: candidate: ‘void llvm::APInt::toString(llvm::SmallVectorImpl<char>&, unsigned int, bool, bool) const’
1741 | void toString(SmallVectorImpl<char> &Str, unsigned Radix, bool Signed,
| ^~~~~~~~
/usr/lib/llvm-13/include/llvm/ADT/APInt.h:1741:8: note: candidate expects 4 arguments, 1 provided
/home/jagadeesha/Downloads/codebrowser/generator/main.cpp: In function ‘bool proceedCommand(std::vector<std::__cxx11::basic_string<char> >, llvm::StringRef, llvm::StringRef, clang::FileManager*, DatabaseType)’:
/home/jagadeesha/Downloads/codebrowser/generator/main.cpp:303:15: error: ‘class clang::tooling::ToolInvocation’ has no member named ‘mapVirtualFile’
303 | Inv.mapVirtualFile(f->filename, {f->content , f->size } );
| ^~~~~~~~~~~~~~
make[2]: *** [generator/CMakeFiles/codebrowser_generator.dir/build.make:82: generator/CMakeFiles/codebrowser_generator.dir/main.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:138: generator/CMakeFiles/codebrowser_generator.dir/all] Error 2
make: *** [Makefile:149: all] Error 2
The 2 errors are:
codebrowser/generator/browserastvisitor.h:132:130: error: no matching function for call to ‘llvm::APSInt::toString(int) const’
codebrowser/generator/main.cpp:303:15: error: ‘class clang::tooling::ToolInvocation’ has no member named ‘mapVirtualFile’ 303 | Inv.mapVirtualFile(f->filename, {f->content , f->size } );
Workaround Fix:
I followed the instructions given in https://github.com/rizsotto/Bear/issues/196#issuecomment-691748584 to generate compile_commands.json
in the older format (i.e. without output
field). codebrowser_generator worked fine with the older format.
Adding config.json
that I used for reference here.
{
"compilation": {},
"output": {
"content": {
"include_only_existing_source": true
},
"format": {
"command_as_array": false,
"drop_output_field": true
}
}
}
As for the codebrowser
build failure with LLVM-13, I have logged a new issue (https://github.com/KDAB/codebrowser/issues/95).
@kanihal Since you've solved the db problem, I would like to share some tips on generating compilation.json. Hope it may help in the future.
For any project I'd like to compile with codebrowser, I would like to write another new CMakeList.txt for it to get full control of the source code and dependencies needed by codebrowser, even though it already has one. Of course, I need some script to help, here is the example https://github.com/gavinchou/codebrowser/tree/master/examples/build-project-with-template
I am trying to use woboq on postgres (https://github.com/postgres/postgres). I have generated
compile_commands.json
using bearNow when I run codebrowser_generator, I get the below-mentioned error
Here is a sample entry from compile_commands.json,
and codebrowser version details:
is the generated entries in compile_commands.json not supposed to contain
output
field? How do I resolve this issue?