Bug 1316120: Fix nsLocalFileWin.cpp build on clang-cl. r=froydnj
authorDavid Major <dmajor@mozilla.com>
Thu, 10 Nov 2016 11:48:59 -0600
changeset 321999 8d647917ebe1138258d89d98b88aae9989ce7cf8
parent 321998 1f8f122dfef1792340e1ce1b199b3a5b4d373417
child 322000 debae3394553dde5b5edcdf1e2afbed5d282db1d
push id83733
push userdmajor@mozilla.com
push dateThu, 10 Nov 2016 17:48:03 +0000
treeherdermozilla-inbound@8d647917ebe1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1316120, 30578
milestone52.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1316120: Fix nsLocalFileWin.cpp build on clang-cl. r=froydnj This keeps the ITEMIDLIST pointers in the "LP" flavour to avoid casting away __unaligned qualifiers. __unaligned is meaningless on non-Itanium platforms but clang-cl nonetheless has trouble with it. (https://llvm.org/bugs/show_bug.cgi?id=30578)
xpcom/io/nsLocalFileWin.cpp
--- a/xpcom/io/nsLocalFileWin.cpp
+++ b/xpcom/io/nsLocalFileWin.cpp
@@ -175,23 +175,22 @@ private:
     DWORD attributes = GetFileAttributesW(mResolvedPath.get());
     if (INVALID_FILE_ATTRIBUTES == attributes) {
       return NS_ERROR_FILE_INVALID_PATH;
     }
 
     HRESULT hr;
     if (attributes & FILE_ATTRIBUTE_DIRECTORY) {
       // We have a directory so we should open the directory itself.
-      ITEMIDLIST* dir =
-        static_cast<ITEMIDLIST*>(ILCreateFromPathW(mResolvedPath.get()));
+      LPITEMIDLIST dir = ILCreateFromPathW(mResolvedPath.get());
       if (!dir) {
         return NS_ERROR_FAILURE;
       }
 
-      const ITEMIDLIST* selection[] = { dir };
+      LPCITEMIDLIST selection[] = { dir };
       UINT count = ArrayLength(selection);
 
       //Perform the open of the directory.
       hr = SHOpenFolderAndSelectItems(dir, count, selection, 0);
       CoTaskMemFree(dir);
     } else {
       int32_t len = mResolvedPath.Length();
       // We don't currently handle UNC long paths of the form \\?\ anywhere so
@@ -199,31 +198,29 @@ private:
       if (len > MAX_PATH) {
         return NS_ERROR_FILE_INVALID_PATH;
       }
       WCHAR parentDirectoryPath[MAX_PATH + 1] = { 0 };
       wcsncpy(parentDirectoryPath, mResolvedPath.get(), MAX_PATH);
       PathRemoveFileSpecW(parentDirectoryPath);
 
       // We have a file so we should open the parent directory.
-      ITEMIDLIST* dir =
-        static_cast<ITEMIDLIST*>(ILCreateFromPathW(parentDirectoryPath));
+      LPITEMIDLIST dir = ILCreateFromPathW(parentDirectoryPath);
       if (!dir) {
         return NS_ERROR_FAILURE;
       }
 
       // Set the item in the directory to select to the file we want to reveal.
-      ITEMIDLIST* item =
-        static_cast<ITEMIDLIST*>(ILCreateFromPathW(mResolvedPath.get()));
+      LPITEMIDLIST item = ILCreateFromPathW(mResolvedPath.get());
       if (!item) {
         CoTaskMemFree(dir);
         return NS_ERROR_FAILURE;
       }
 
-      const ITEMIDLIST* selection[] = { item };
+      LPCITEMIDLIST selection[] = { item };
       UINT count = ArrayLength(selection);
 
       //Perform the selection of the file.
       hr = SHOpenFolderAndSelectItems(dir, count, selection, 0);
 
       CoTaskMemFree(dir);
       CoTaskMemFree(item);
     }