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

Class BuildEventsParser

src/BuildEvents.cpp:163–466  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

161
162
163struct BuildEventsParser
164{
165 BuildEventsParser()
166 {
167 // make sure zero index is empty
168 NameToIndex("", resultNameToIndex);
169 resultNames.push_back(std::string_view(resultNameToIndex.begin()->first.str, 0));
170
171 resultEvents.reserve(2048);
172 resultNames.reserve(2048);
173 }
174
175 BuildEvents resultEvents;
176 BuildNames resultNames;
177 NameToIndexMap resultNameToIndex;
178 std::mutex resultMutex;
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)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected