[PATCH] D88502: [llvm][Support] Delete unused is_absolute_gnu helper

Christopher Ertl via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 30 03:16:19 PDT 2020


certl added a comment.

The other path manipulation functions have similar quirks for Windows paths (Unicode drives / NTFS alternate streams). I'm not particularly concerned, but for correctness sake I would also recommend for those to be removed / refactored / replaced with something standard such as those from C++17.

`find_first_component` - assumes all drives are single byte alpha characters (see here <https://github.com/git/git/blob/7034cd094bda4edbcdff7fad1a28fcaaf9b9a040/compat/win32/path-utils.c#L3> for how the git project handles this):

  if (real_style(style) == Style::windows) {
    // C:
    if (path.size() >= 2 &&
        std::isalpha(static_cast<unsigned char>(path[0])) && path[1] == ':')
      return path.substr(0, 2);
  }

`root_dir_start` - also assumes single byte drive:

  // case "c:/"
  if (real_style(style) == Style::windows) {
    if (str.size() > 2 && str[1] == ':' && is_separator(str[2], style))
      return 2;
  }

`filename_pos` - doesn't anticipate NTFS alternate streams (eg: I believe `C:\xxx\yyy::$INDEX_ALLOCATION\` would return the filename as `$INDEX_ALLOCATION`), as well as assuming single byte drives:

  if (real_style(style) == Style::windows) {
    if (pos == StringRef::npos)
      pos = str.find_last_of(':', str.size() - 2);
  }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88502



More information about the llvm-commits mailing list