RFC Libclang based analyzer
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v2 RFC Latest posting 3/31 of 2 patches 0 repliesNew
- v2 RFC posting 2/30 of 2 patches 0 repliesSuperseded
- v2 RFC posting 1/31 of 2 patches 0 repliesSuperseded
Earlier versions · 1
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v1 RFC | 1 of 2 patches | 0 replies | Superseded |
1 of 2 patches is in this archive. The cover letter announces 2.
Patches in v2 posting 3/3 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | Add 'make check' and clang-check to build system | +0 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.
Cover letter [LTP] [RFC PATCH v2 0/2] Libclang based analyzer
Hello Joerg,
Quoted 33 lines · Joerg Vehlow
Hi Richard,
Quoted 9 lines · Richard Palethorpe
Hello Joerg,
On ubuntu 20.04, this file is part of libclang-dev, but installing it did not help either, because it is installed to an include path not know to gcc (
/usr/lib/llvm-10/include/clang-c).
Is part of this path the same that 'clang -print-resource-dir' prints?Either way I guess we can search for this during configuration. LLVM has a CMake module (or w/e) which probably finds all this automatically.
resource dir is
/usr/lib/llvm-12/lib/clang/12.0.1.The llvm-config tool can be used to find the locations of the include and lib directory.
On my ubuntu, I installed clang-12 from apt.llvm.org and clang-10 from ubuntu repos.
In the path there is the llvm-config tool from ubuntu pointing to/usr/lib/llvm-10/bin/llvm-configand llvm-config-10 and llvm-config-12 pointing to the respective llvm-config tool.I guess using llvm-config from the path to detect the correct include and library path would be the best way to go.
If someone wants to use a different version, he can still set prepend it to the path during configuration:$ llvm-config --includedir /usr/lib/llvm-10/include$ llvm-config --libdir /usr/lib/llvm-10/lib
Quoted 7 lines
$ PATH="/usr/lib/llvm-12/bin:$PATH" llvm-config --includedir /usr/lib/llvm-12/includeBoth includedir and libdir are required, to correctly link libclang. In the default library search paths, there are only versioned versiones of libclang (eg. libclang-12.so).
OK.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
I added it to the include path and it was found, but the next problem is, that some used functions (like
clang_Cursor_getVarDeclInitializer) are only available starting with libclang 12.
Quoted 7 lines
Quoted 5 lines
I guess that we could replace that function by recursing further into the AST to find the initializer ourselves.
Probably we can restrict ourselves to only use functions from before libclang 11.
Sounds good, but how to force this? I don't think there is a "allow only libclang 10 symbols"...
Make a list of the symbols exported by libclang 10. Then check that anything which starts with clang_ or CX is in that list.
Or just compile it against libclang 10 in CI.
Quoted 11 lines
Quoted 9 lines
Quoted 5 lines
So in conclusion, I do not think we can assume libclang to be available for all developers and installing it is probably more work, at least when newer functions from libclang are used, than installing coccinelle.
IIRC Cyril said the Coccinelle package on Gentoo is not maintained anymore. AFAICT it exists, but it is on an old version. I don't think many people are interested in or want to maintain Ocaml stuff. LLVM/Clang OTOH looks to be very active.
Right, it actually is removed now from gentoo portage tree ([1]). But is it used by the kernel developers?
Some kernel developers use it. There are a number of checkers and some maintainers care about them while others do not.
Quoted 5 lines
J?rg
[1]
https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=58395d3a0c06e060a0a40182fff4bf39f1910529
Signature · 2 lines
Thank you, Richard.