Ste*_*ini 5 c++ plugins llvm clang
clang支持插件,这个概念通常用于构建静态分析等工具。为了开始使用它,我举了这个例子,它打印目标 cpp 文件中存在的所有函数名称。
我编译了运行以下命令的插件:
clang++ -v -std=c++11 PrintFunctionNames.cpp \
$(llvm-config --cxxflags --ldflags) \
-o plugin.so -shared -Wl,-undefined,dynamic_lookup
Run Code Online (Sandbox Code Playgroud)
然后“按书本”运行:
clang++ \
-c main.cpp \
-Xclang -load \
-Xclang $PWD/plugin.so \
-Xclang -plugin \
-Xclang print-fns
Run Code Online (Sandbox Code Playgroud)
它工作得很好:它打印 main.cpp 中的函数名称
并退出(由于 -c 标志而无需编译 main.cpp)。
What I'd like to do is to print all the function names AND compile main.cpp into an executable.
I tried removing the -c flag but I got:
/usr/bin/ld: cannot find /tmp/main-284664.o: No such file or directory
Run Code Online (Sandbox Code Playgroud)
What am I doing wrong?
| 归档时间: |
|
| 查看次数: |
1886 次 |
| 最近记录: |