MCPcopy Create free account
hub / github.com/aras-p/ClangBuildAnalyzer / ParseEvent

Method ParseEvent

src/BuildEvents.cpp:311–465  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

309 const char* kDetail = "detail";
310
311 void ParseEvent(simdjson::dom::element& it, const std::string& curFileName, BuildEvents& fileEvents, NameToIndexMap& nameToIndexLocal)
312 {
313 simdjson::dom::object node;
314 if (it.get(node))
315 {
316 printf("%sERROR: 'traceEvents' elements in JSON should be objects.%s\n", col::kRed, col::kReset);
317 resultEvents.clear();
318 return;
319 }
320
321 BuildEvent event;
322 bool valid = true;
323 std::string_view detailPtr;
324 for (const simdjson::dom::key_value_pair& kv : node)
325 {
326 std::string_view nodeKey = kv.key;
327 if (StrEqual(nodeKey, kPid))
328 {
329 if (!kv.value.is_int64()) // starting with Clang/LLVM 11 process IDs are not necessarily 1
330 valid = false;
331 }
332 else if (StrEqual(nodeKey, kTid))
333 {
334 if (!kv.value.is_int64()) // starting with Clang/LLVM 11 thread IDs are not necessarily 0
335 valid = false;
336 }
337 else if (StrEqual(nodeKey, kPh))
338 {
339 if (!kv.value.is_string())
340 valid = false;
341 else
342 {
343 std::string_view val = kv.value.get_string();
344 if (!StrEqual(val, "X") && !StrEqual(val, "b") && !StrEqual(val, "e"))
345 valid = false;
346 else
347 event.phase = val[0];
348 }
349 }
350 else if (StrEqual(nodeKey, kName) && kv.value.is_string() && valid)
351 {
352 std::string_view name = kv.value.get_string();
353 if (StrEqual(name, "ExecuteCompiler"))
354 event.type = BuildEventType::kCompiler;
355 else if (StrEqual(name, "Frontend"))
356 event.type = BuildEventType::kFrontend;
357 else if (StrEqual(name, "Backend"))
358 event.type = BuildEventType::kBackend;
359 else if (StrEqual(name, "Source"))
360 event.type = BuildEventType::kParseFile;
361 else if (StrEqual(name, "ParseTemplate"))
362 event.type = BuildEventType::kParseTemplate;
363 else if (StrEqual(name, "ParseClass"))
364 event.type = BuildEventType::kParseClass;
365 else if (StrEqual(name, "InstantiateClass"))
366 event.type = BuildEventType::kInstantiateClass;
367 else if (StrEqual(name, "InstantiateFunction"))
368 event.type = BuildEventType::kInstantiateFunction;

Callers

nothing calls this directly

Calls 5

cf_file_existsFunction · 0.85
pop_backMethod · 0.80
clearMethod · 0.45
beginMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected