[llvm] 430fc53 - [llvm-ar] Simplify Windows comparePaths NFCI

Andrew Ng via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 14 03:22:08 PST 2020


Author: Andrew Ng
Date: 2020-02-14T11:20:17Z
New Revision: 430fc538e6dc2f3b1b6093755080efdcf206cd3f

URL: https://github.com/llvm/llvm-project/commit/430fc538e6dc2f3b1b6093755080efdcf206cd3f
DIFF: https://github.com/llvm/llvm-project/commit/430fc538e6dc2f3b1b6093755080efdcf206cd3f.diff

LOG: [llvm-ar] Simplify Windows comparePaths NFCI

Replace use of widenPath in comparePaths with UTF8ToUTF16. widenPath
does a lot more than just conversion from UTF-8 to UTF-16. This is not
necessary for CompareStringOrdinal and could possibly even cause
problems.

Differential Revision: https://reviews.llvm.org/D74477

Added: 
    

Modified: 
    llvm/tools/llvm-ar/llvm-ar.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/tools/llvm-ar/llvm-ar.cpp b/llvm/tools/llvm-ar/llvm-ar.cpp
index 61ab8051eded..d95226c5d8e3 100644
--- a/llvm/tools/llvm-ar/llvm-ar.cpp
+++ b/llvm/tools/llvm-ar/llvm-ar.cpp
@@ -21,6 +21,7 @@
 #include "llvm/Object/ObjectFile.h"
 #include "llvm/Support/Chrono.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/ConvertUTF.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Format.h"
@@ -518,8 +519,8 @@ static bool comparePaths(StringRef Path1, StringRef Path2) {
 // binary equivalence and allows for case insensitivity.
 #ifdef _WIN32
   SmallVector<wchar_t, 128> WPath1, WPath2;
-  failIfError(sys::path::widenPath(normalizePath(Path1), WPath1));
-  failIfError(sys::path::widenPath(normalizePath(Path2), WPath2));
+  failIfError(sys::windows::UTF8ToUTF16(normalizePath(Path1), WPath1));
+  failIfError(sys::windows::UTF8ToUTF16(normalizePath(Path2), WPath2));
 
   return CompareStringOrdinal(WPath1.data(), WPath1.size(), WPath2.data(),
                               WPath2.size(), true) == CSTR_EQUAL;


        


More information about the llvm-commits mailing list