Currently dsymutil when generating accelerator tables will attempt to strip the template parameters from names for subroutines. For some overload operators which contain < in their names e.g. operator< the current method ends up stripping the operator name as well, so we just end up with the name operator in the table for each case.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
| llvm/lib/DWARFLinker/DWARFLinker.cpp | ||
|---|---|---|
| 174–176 | s/auto/StringRef/ | |
| 178 | This comment adds more confusion than it clarifies. The angle brackets being balanced doesn't really matter as this point. I'd say something like: To strip the template we need to find at least one left angle bracket | |
| 180 | Please follow the LLVM coding style. This applies to all variables. Also I'd rename this to LeftAngleBracketsToSkip. | |
| 184 | Can this operator occur more than once? | |
| 191 | The comment says not balanced, but you use > instead of !=. Does that matter? | |
| 199 | Given that we always strip the end, can we simplify the algorithm to something like size_t RightAngleCount = name.count('>');
size_t LeftAngleCount = name.count('<');
if (RightAngleCount != LeftAngleCount) {
size_t AngleDifference = std::abs(RightAngleCount - LeftAngleCount);
while (AngleDifference) {
name = name.take_front(name.rfind('<'));
}
}That way we don't have to hardcode the <=> stuff. | |
| 199 | Forgot to decrement AngleDifference: while (AngleDifference--) { | |
| 200 | We should extract this logic in a static function, something like StringRef stripTemplateFromName(StringRef Str);. | |
| llvm/test/tools/dsymutil/X86/template_operators.test | ||
| 24 | Please test operator<=> as well. | |
- Addressing comments
- Fixing bug, I was setting NameWithoutTemplate incorrectly in some cases.
| llvm/lib/DWARFLinker/DWARFLinker.cpp | ||
|---|---|---|
| 200 | Just realized I missed this comment, I will extract this out in the next update. | |
| llvm/lib/DWARFLinker/DWARFLinker.cpp | ||
|---|---|---|
| 122 | For consistency with the other free functions in the cpp file, can you just make it static? This seems to be the default in llvm. | |
| 134 | I still think that Skip would be more meaningful than Count | |
| 151 | Please clang format your patch before landing. | |
| 175 | You can move this into the if: if (Optional<StringRef> StrippedName = StripTemplateParameters(Name)) | |
Addressing comment
- Converting function to static Vs anon namespace
- Updating naming
- moving assignment into if
- clang-format
For consistency with the other free functions in the cpp file, can you just make it static? This seems to be the default in llvm.