From 2be87e00b5cce35ab3bcf446ab59b985003cd8c8 Mon Sep 17 00:00:00 2001
From: Ding Fei <danix800@gmail.com>
Date: Wed, 8 Jul 2020 00:11:09 +0800
Subject: [PATCH] [Support] Fix utf16 path's index upper bound

---
 llvm/lib/Support/Windows/Path.inc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/Support/Windows/Path.inc b/llvm/lib/Support/Windows/Path.inc
index 399a0cc7a25c5..b85209488190a 100644
--- a/llvm/lib/Support/Windows/Path.inc
+++ b/llvm/lib/Support/Windows/Path.inc
@@ -958,8 +958,8 @@ std::error_code detail::directory_iterator_construct(detail::DirIterState &IT,
 
   // Convert path to the format that Windows is happy with.
   if (PathUTF16.size() > 0 &&
-      !is_separator(PathUTF16[Path.size() - 1]) &&
-      PathUTF16[Path.size() - 1] != L':') {
+      !is_separator(PathUTF16[PathUTF16.size() - 1]) &&
+      PathUTF16[PathUTF16.size() - 1] != L':') {
     PathUTF16.push_back(L'\\');
     PathUTF16.push_back(L'*');
   } else {