| 29 | }; |
| 30 | |
| 31 | TEST_F(TestLLVMUtil, GetCalledFunction_GeneralP) { |
| 32 | const std::string Code = "extern \"C\" {\n" |
| 33 | " void API();\n" |
| 34 | " void test() { API(); }\n" |
| 35 | "}"; |
| 36 | SourceFileManager SFM; |
| 37 | SFM.createFile("test.cpp", Code); |
| 38 | ASSERT_TRUE(load(SFM.getSrcDirPath(), SFM.getFilePath("test.cpp"))); |
| 39 | const auto *CB = llvm::dyn_cast_or_null<llvm::CallBase>( |
| 40 | IRAccess->getInstruction("test", 0, 0)); |
| 41 | ASSERT_TRUE(CB); |
| 42 | const auto *CF = util::getCalledFunction(*CB); |
| 43 | ASSERT_TRUE(CF); |
| 44 | ASSERT_EQ(CF->getName(), "API"); |
| 45 | } |
| 46 | |
| 47 | TEST_F(TestLLVMUtil, GetCalledFunction_IndirectN) { |
| 48 | const std::string Code = "extern \"C\" {\n" |
nothing calls this directly
no test coverage detected