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
Event Timeline
llvm/lib/DWARFLinker/DWARFLinker.cpp | ||
---|---|---|
175–177 | s/auto/StringRef/ | |
179 | 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 | |
181 | Please follow the LLVM coding style. This applies to all variables. Also I'd rename this to LeftAngleBracketsToSkip. | |
185 | Can this operator occur more than once? | |
192 | The comment says not balanced, but you use > instead of !=. Does that matter? | |
200 | 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. | |
200 | Forgot to decrement AngleDifference: while (AngleDifference--) { | |
201 | 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 | ||
---|---|---|
201 | Just realized I missed this comment, I will extract this out in the next update. |
llvm/lib/DWARFLinker/DWARFLinker.cpp | ||
---|---|---|
123 | 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. | |
135 | I still think that Skip would be more meaningful than Count | |
152 | Please clang format your patch before landing. | |
176 | 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.