MCPcopy Create free account
hub / github.com/Samsung/UTopia / IRData

Method IRData

tests/testutil/CompileHelper.cpp:224–260  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

222}
223
224CompileHelper::IRData::IRData(const std::vector<SourceFileData> &SourceFiles)
225 : Path(getUniqueFilePath(getTmpDirPath(), "link", "bc")) {
226
227 std::vector<std::string> IRPaths;
228 for (auto &SourceFile : SourceFiles) {
229 auto IRPath = compile(SourceFile);
230 if (IRPath.empty()) {
231 IRPaths.clear();
232 return;
233 }
234
235 IRPaths.emplace_back(IRPath);
236 }
237 if (IRPaths.empty())
238 return;
239
240 auto CMD = "llvm-link -o " + Path;
241 for (auto &IRPath : IRPaths)
242 CMD += " " + IRPath;
243 if (system(CMD.c_str()) || !fs::exists(Path))
244 return;
245
246 for (auto &IRPath : IRPaths) {
247 if (!fs::exists(IRPath))
248 continue;
249 fs::remove(IRPath);
250 }
251
252 Ctx = std::make_unique<llvm::LLVMContext>();
253 if (!Ctx)
254 return;
255
256 llvm::SMDiagnostic SMDiag;
257 Ptr = llvm::parseIRFile(Path, SMDiag, *Ctx);
258 if (!Ptr && fs::exists(Path))
259 fs::remove(Path);
260}
261
262CompileHelper::IRData::~IRData() {
263

Callers

nothing calls this directly

Calls 4

getUniqueFilePathFunction · 0.85
getTmpDirPathFunction · 0.85
emptyMethod · 0.80
clearMethod · 0.45

Tested by

no test coverage detected