运行clang libtooling时出现分段错误(核心转储)

时间:2017-04-05 23:04:17

标签: clang libtooling

我实现了一个简单的重构工具,可以将函数名替换为用户特定的名称。

当我在测试代码上运行该工具(没有任何头文件)时,它运行良好。

但是,如果我在测试代码中包含头文件, e.g。

#include <stdio.h>

... 然后,我再次运行它。存在分段错误(核心转储):

$ ./transform -class=Test -method=test -newname=run ./testcode.cpp

./transform(_ZN4llvm3sys15PrintStackTraceERNS_11raw_ostreamE+0x33)[0xc76123]
./transform[0xc761b6]
./transform(_ZN4llvm3sys17RunSignalHandlersEv+0x99)[0xc74471]
./transform[0xc75998]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7f5a0eec1390]
./transform[0xbd9537]
./transform[0xbd2d7b]
./transform[0x10a7215]
./transform(_ZN5clang12ast_matchers8internal21BoundNodesTreeBuilder12visitMatchesEPNS2_7VisitorE+0x10c)[0x11527fc]
./transform[0x10a665b]
./transform[0x10a67f9]
./transform[0x10aba99]
./transform[0x10a77c3]
./transform[0x1103b1e]
./transform[0x10c3d55]
./transform[0x10ac8b6]
./transform[0x10a77d6]
./transform[0x1103b1e]
./transform[0x10c94d7]
./transform[0x10ad4dd]
./transform[0x10a77d6]
./transform(_ZN5clang12ast_matchers11MatchFinder8matchASTERNS_10ASTContextE+0x9b)[0x10a8377]
./transform[0x10a7a99]
./transform(_ZN5clang8ParseASTERNS_4SemaEbb+0x30d)[0x13b484d]
./transform(_ZN5clang17ASTFrontendAction13ExecuteActionEv+0x143)[0x11e4ac1]
./transform(_ZN5clang14FrontendAction7ExecuteEv+0x96)[0x11e450e]
./transform(_ZN5clang16CompilerInstance13ExecuteActionERNS_14FrontendActionE+0x522)[0x123e956]
./transform(_ZN5clang7tooling21FrontendActionFactory13runInvocationESt10shared_ptrINS_18CompilerInvocationEEPNS_11FileManagerES2_INS_22PCHContainerOperationsEEPNS_18DiagnosticConsumerE+0x19e)[0x13abb66]
./transform(_ZN5clang7tooling14ToolInvocation13runInvocationEPKcPNS_6driver11CompilationESt10shared_ptrINS_18CompilerInvocationEES7_INS_22PCHContainerOperationsEE+0x12c)[0x13ab98c]
./transform(_ZN5clang7tooling14ToolInvocation3runEv+0x5d7)[0x13ab795]
./transform(_ZN5clang7tooling9ClangTool3runEPNS0_10ToolActionE+0xa32)[0x13accb6]
./transform(_ZN5clang7tooling15RefactoringTool10runAndSaveEPNS0_21FrontendActionFactoryE+0x44)[0x13a7ae8]
./transform(main+0x71b)[0xbd3ca0]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7f5a0e04c830]
./transform(_start+0x29)[0xbd1c59]
Segmentation fault (core dumped)

我对此感到困惑,因为我只添加了#34; #include&lt; ...&gt;&#34; 你能帮忙检查一下故障信息吗? 提前致谢!

0 个答案:

没有答案