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

Method AddEvents

src/BuildEvents.cpp:181–231  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

179 std::mutex arenaMutex;
180
181 void AddEvents(BuildEvents& add, const NameToIndexMap& nameToIndex)
182 {
183 // we got job-local build events and name-to-index mapping;
184 // add them to the global result with any necessary remapping.
185 // gotta take a mutex since we're modifying shared state here.
186 std::scoped_lock lock(resultMutex);
187
188 // move events to end of result events list
189 int offset = (int)resultEvents.size();
190 std::move(add.begin(), add.end(), std::back_inserter(resultEvents));
191 add.clear();
192
193 // create remapping from name indices, adding them to global remapping
194 // list if necessary.
195 ska::bytell_hash_map<DetailIndex, DetailIndex> detailRemap;
196 for (const auto& kvp : nameToIndex)
197 {
198 const auto& existing = resultNameToIndex.find(kvp.first);
199 if (existing == resultNameToIndex.end())
200 {
201 DetailIndex index((int)resultNameToIndex.size());
202 resultNameToIndex.insert(std::make_pair(kvp.first, index));
203 resultNames.push_back(std::string_view(kvp.first.str, kvp.first.len));
204 detailRemap[kvp.second] = index;
205 }
206 else
207 {
208 detailRemap[kvp.second] = existing->second;
209 }
210 }
211
212 // adjust the added event indices
213 for (size_t i = offset, n = resultEvents.size(); i != n; ++i)
214 {
215 BuildEvent& ev = resultEvents[EventIndex(int(i))];
216 if (ev.parent.idx >= 0)
217 ev.parent.idx += offset;
218 for (auto& ch : ev.children)
219 ch.idx += offset;
220 if (ev.detailIndex.idx != 0)
221 {
222 assert(ev.detailIndex.idx >= 0);
223 assert(ev.detailIndex.idx < static_cast<int>(nameToIndex.size()));
224 ev.detailIndex = detailRemap[ev.detailIndex];
225 assert(ev.detailIndex.idx >= 0);
226 assert(ev.detailIndex.idx < static_cast<int>(resultNameToIndex.size()));
227 }
228 }
229
230 assert(resultNameToIndex.size() == resultNames.size());
231 }
232
233
234 DetailIndex NameToIndex(const char* str, NameToIndexMap& nameToIndex)

Callers

nothing calls this directly

Calls 8

EventIndexClass · 0.85
push_backMethod · 0.80
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
clearMethod · 0.45
findMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected