Skip to content

Commit fda812c

Browse files
author
Alex B
committed
Address Feedback Nr 5
1 parent d5bd6d5 commit fda812c

File tree

2 files changed

+13
-19
lines changed

2 files changed

+13
-19
lines changed

llvm/lib/DebugInfo/GSYM/CallSiteInfo.cpp

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ Expected<CallSiteInfo> CallSiteInfo::decode(DataExtractor &Data,
7171

7272
Error CallSiteInfoCollection::encode(FileWriter &O) const {
7373
O.writeU32(CallSites.size());
74-
for (const CallSiteInfo &CSI : CallSites) {
74+
for (const CallSiteInfo &CSI : CallSites)
7575
if (Error Err = CSI.encode(O))
7676
return Err;
77-
}
77+
7878
return Error::success();
7979
}
8080

@@ -175,23 +175,17 @@ Error CallSiteInfoLoader::loadYAML(std::vector<FunctionInfo> &Funcs,
175175

176176
StringMap<FunctionInfo *>
177177
CallSiteInfoLoader::buildFunctionMap(std::vector<FunctionInfo> &Funcs) {
178+
// If the function name is already in the map, don't update it. This way we
179+
// preferentially use the first encountered function. Since symbols are
180+
// loaded from dSYM first, we end up preferring keeping track of symbols
181+
// from dSYM rather than from the symbol table - which is what we want to
182+
// do.
178183
StringMap<FunctionInfo *> FuncMap;
179-
auto insertFunc = [&](auto &Function) {
180-
StringRef FuncName = GCreator.getString(Function.Name);
181-
// If the function name is already in the map, don't update it. This way we
182-
// preferentially use the first encountered function. Since symbols are
183-
// loaded from dSYM first, we end up preferring keeping track of symbols
184-
// from dSYM rather than from the symbol table - which is what we want to
185-
// do.
186-
if (FuncMap.count(FuncName))
187-
return;
188-
FuncMap[FuncName] = &Function;
189-
};
190184
for (auto &Func : Funcs) {
191-
insertFunc(Func);
192-
if (Func.MergedFunctions.has_value())
193-
for (auto &MFunc : Func.MergedFunctions->MergedFunctions)
194-
insertFunc(MFunc);
185+
FuncMap.try_emplace(GCreator.getString(Func.Name), &Func);
186+
if (auto MFuncs = Func.MergedFunctions)
187+
for (auto &MFunc : MFuncs->MergedFunctions)
188+
FuncMap.try_emplace(GCreator.getString(MFunc.Name), &MFunc);
195189
}
196190
return FuncMap;
197191
}

llvm/lib/DebugInfo/GSYM/GsymCreator.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,8 +385,8 @@ uint32_t GsymCreator::insertString(StringRef S, bool Copy) {
385385
return StrOff;
386386
}
387387

388-
StringRef GsymCreator::getString(uint32_t offset) {
389-
auto I = StringOffsetMap.find(offset);
388+
StringRef GsymCreator::getString(uint32_t Offset) {
389+
auto I = StringOffsetMap.find(Offset);
390390
assert(I != StringOffsetMap.end() &&
391391
"GsymCreator::getString expects a valid offset as parameter.");
392392
return I->second.val();

0 commit comments

Comments
 (0)