[PATCH] D30991: [Driver] Fix cross compiling with Visual Studio 2017

Hamza Sood via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 15 18:17:17 PDT 2017


hamzasood added inline comments.


================
Comment at: lib/Driver/ToolChains/MSVC.cpp:487-488
+      if (!llvm::convertUTF16ToUTF8String(
+             llvm::ArrayRef<char>(reinterpret_cast<char *>(EnvBlockWide.get()),
+                                  EnvBlockLen * sizeof(EnvBlockWide[0])),
+             EnvBlock))
----------------
hamzasood wrote:
> zturner wrote:
> > There's an overload of `convertUTF16ToUTF8String` that takes an `ArrayRef<UTF16>`.  So I think you can just write this:
> > 
> > ```
> > if (!llvm::convertUTF16ToUTF8String(makeArrayRef(EnvBlockWide.get(), EnvBlockLen)))
> > ```
> Using that overload would involve casting wchar_t* to UTF16* (i.e. unsigned char*), which I think breaks aliasing rules.
Sorry, I meant unsigned short.


https://reviews.llvm.org/D30991





More information about the cfe-commits mailing list