llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Shoaib Meenai (smeenai) <details> <summary>Changes</summary> The previous logic could fail in some edge cases. --- Full diff: https://github.com/llvm/llvm-project/pull/102571.diff 1 Files Affected: - (modified) clang/utils/hmaptool/hmaptool (+5-2) ``````````diff diff --git a/clang/utils/hmaptool/hmaptool b/clang/utils/hmaptool/hmaptool index d7754632b162b..aa400e3dd64e9 100755 --- a/clang/utils/hmaptool/hmaptool +++ b/clang/utils/hmaptool/hmaptool @@ -192,8 +192,11 @@ def action_write(name, args): key_idx = len(strtable) strtable += key + '\0' - prefix = os.path.dirname(value) + '/' - suffix = os.path.basename(value) + prefix, suffix = os.path.split(value) + # This guarantees that prefix + suffix == value in all cases, including when + # prefix is empty or contains a trailing slash or suffix is empty (hence the use + # of `len(value) - len(suffix)` instead of just `-len(suffix)`. + prefix += value[len(prefix) : len(value) - len(suffix)] prefix_idx = len(strtable) strtable += prefix + '\0' suffix_idx = len(strtable) `````````` </details> https://github.com/llvm/llvm-project/pull/102571 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits