thanks for your email. I have searched online on how to build clang plugins and I found [1]. I wanted to use the example that prints all the function names but, despite the fact that I followed the instructions, I could not compile it :)
I searched again and I found [2] and hopefully In this case I could build and run the basic hello-world example. I then tried to just replace the HelloWorld.cpp with the example that print the functions names but no luck. I compile but I have an error message. The following paragraph shows the entire test:
➜ build git:(main) ✗ make
Scanning dependencies of target HelloWorld
[ 50%] Building CXX object CMakeFiles/HelloWorld.dir/HelloWorld.cpp.o
[100%] Linking CXX shared library libHelloWorld.so
[100%] Built target HelloWorld
➜ build git:(main) ✗ clang-13 -cc1 -load ./libHelloWorld.so -plugin hello-world $CLANG_TUTOR_DIR/test/HelloWorld-basic.cpp
➜ build git:(main) ✗ $Clang_DIR/bin/clang -cc1 -load ./libHelloWorld.so -plugin hello-world $CLANG_TUTOR_DIR/test/HelloWorld-basic.cpp
(clang-tutor) file: /home/alberto/Desktop/projects/llvm/clang-tutor//test/HelloWorld-basic.cpp
(clang-tutor) count: 3
➜ build git:(main) ✗ cd ..
➜ HelloWorld git:(main) ✗ wget
https://raw.githubusercontent.com/llvm/llvm-project/main/clang/examples/PrintFunctionNames/PrintFunctionNames.cpp--2021-12-17 06:45:54--
https://raw.githubusercontent.com/llvm/llvm-project/main/clang/examples/PrintFunctionNames/PrintFunctionNames.cppResolving
raw.githubusercontent.com (
raw.githubusercontent.com)... 185.199.110.133, 185.199.109.133, 185.199.108.133, ...
Connecting to
raw.githubusercontent.com (
raw.githubusercontent.com)|185.199.110.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 4504 (4.4K) [text/plain]
Saving to: ‘PrintFunctionNames.cpp’
PrintFunctionNames.cp 100%[========================>] 4.40K --.-KB/s in 0s
2021-12-17 06:45:54 (11.3 MB/s) - ‘PrintFunctionNames.cpp’ saved [4504/4504]
➜ HelloWorld git:(main) ✗ mv HelloWorld.cpp HelloWorld.cpp.backup
➜ HelloWorld git:(main) ✗ mv PrintFunctionNames.cpp HelloWorld.cpp
➜ HelloWorld git:(main) ✗ rm -rf build
➜ HelloWorld git:(main) ✗ take build
➜ build git:(main) ✗ cmake ../
-- The C compiler identification is GNU 10.2.1
-- The CXX compiler identification is GNU 10.2.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test Terminfo_LINKABLE
-- Performing Test Terminfo_LINKABLE - Success
-- Found Terminfo: /usr/lib/x86_64-linux-gnu/libtinfo.so
-- Found ZLIB: /usr/local/lib/libz.so (found version "1.2.11")
-- Configuring done
-- Generating done
-- Build files have been written to: /home/alberto/Desktop/progetti/llvm/clang-tutor/HelloWorld/build
➜ build git:(main) ✗ make
Scanning dependencies of target HelloWorld
[ 50%] Building CXX object CMakeFiles/HelloWorld.dir/HelloWorld.cpp.o
[100%] Linking CXX shared library libHelloWorld.so
[100%] Built target HelloWorld
➜ build git:(main) ✗ $Clang_DIR/bin/clang -cc1 -load ./libHelloWorld.so -plugin hello-world $CLANG_TUTOR_DIR/test/HelloWorld-basic.cpp
error: unable to find plugin 'hello-world'
➜ build git:(main) ✗
Any idea on how to solve it? I think a little github repo with an example on how to do it as standalone project would be beneficial to others as well.