[PATCH] D75545: [dsymutil] Fix template stripping in getDIENames(...) to account for overloaded operators

Jonas Devlieghere via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 3 13:47:14 PST 2020


JDevlieghere added inline comments.


================
Comment at: llvm/lib/DWARFLinker/DWARFLinker.cpp:169
+      Info.NameWithoutTemplate =
+          StringPool.getEntry(name.substr(0, start_of_template - 1));
+    }
----------------
JDevlieghere wrote:
> 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. 
Forgot to decrement AngleDifference: `while (AngleDifference--) {`


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75545/new/

https://reviews.llvm.org/D75545





More information about the llvm-commits mailing list