Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,25 @@ bool TemplateInstantiationsExporter::ExportTo(const std::string& path) const
// aggregate data
typedef std::unordered_map<std::string, DataPerTemplate> TAggregatedData;
TAggregatedData aggregatedData;
std::string templateName = "Unknown";

for (auto&& pair : m_templateInstantiations)
{
const std::chrono::nanoseconds& timeElapsed = pair.second.Duration;

auto itSpecializationTemplateName = m_symbolNames.find(pair.second.Specialization);
assert(itSpecializationTemplateName != m_symbolNames.end());

if (itSpecializationTemplateName != m_symbolNames.end())
{
templateName = itSpecializationTemplateName->second;
}
else
{
templateName = "Unknown";
}
Comment on lines 48 to +57
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about not registering the Unknown template name at all and switching to this?

auto itSpecializationTemplateName = m_symbolNames.find(pair.second.Specialization);
if (itSpecializationTemplateName == m_symbolNames.end())
{
    // a TemplateInstantiation activity has been recorded but its related SymbolName hasn't been emitted
    // we can't know which template it refers to, so we can only skip it
    continue;
}

After all, it won't be correctly registered in the BuildTimeline.json report either.
And this way users won't have an entry listed Unknown with the accumulated time of (probably) unrelated templates.


// from the docs: "Comparing types between different compiler front-end passes requires using symbol names"
auto result = aggregatedData.try_emplace(itSpecializationTemplateName->second, DataPerTemplate());
auto result = aggregatedData.try_emplace(templateName, DataPerTemplate());
auto& data = result.first->second;

// first occurrence?
Expand Down