C++ 如何使用LLVM函数/模块传递检测那些只存在于源文件中的函数/构造函数?
我正在从LLVM编写一个模块传递。在这里,我需要处理所有在位码中存在的函数,但同时我需要确保我没有改变对我不感兴趣的函数,也就是说,我不想考虑那些不是源文件的函数。怎么做 考虑以下测试文件C++ 如何使用LLVM函数/模块传递检测那些只存在于源文件中的函数/构造函数?,c++,llvm,llvm-clang,llvm-ir,C++,Llvm,Llvm Clang,Llvm Ir,我正在从LLVM编写一个模块传递。在这里,我需要处理所有在位码中存在的函数,但同时我需要确保我没有改变对我不感兴趣的函数,也就是说,我不想考虑那些不是源文件的函数。怎么做 考虑以下测试文件 #include <iostream> using namespace std; int testCall() { return 1; } class test { int a; public: test() {
#include <iostream>
using namespace std;
int testCall()
{
return 1;
}
class test
{
int a;
public:
test()
{
a = 0;
}
test(int b)
{
a = b;
}
void foo1()
{
a =2;
}
void fun()
{
a = 3;
}
};
int main()
{
testCall();
test *a = new test(2);
test *b = new test(4);
a->foo1();
a->fun();
b->fun();
cout << "Hi" << "\n";
return 0;
}
#包括
使用名称空间std;
int testCall()
{
返回1;
}
课堂测试
{
INTA;
公众:
测试()
{
a=0;
}
测试(int b)
{
a=b;
}
void foo1()
{
a=2;
}
虚无乐趣()
{
a=3;
}
};
int main()
{
testCall();
试验*a=新试验(2);
试验*b=新试验(4);
a->foo1();
a->fun();
b->fun();
不能,但这些都存在于源代码中。您将它们包含在其中。在clang中,您可能会得到“源文件源代码”我不知道这些信息是否仍然存在于LLVM字节码中。@Basilevs:是的。我接受。但我只想关注开发人员编写的代码,而不是库函数。按命名空间筛选?@Jarod42您是指LLVM的sourcemanager类吗?