[llvm] d098ce0 - [llvm][Support][Windows] Refactored remove_directories() w/o CComPtr and atlbase.h (#119843)

via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 13 04:59:35 PST 2024


Author: Dmitry Vasilyev
Date: 2024-12-13T16:59:31+04:00
New Revision: d098ce0ec9e4dddb494f1f61ff36921dd4ce5f8e

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

LOG: [llvm][Support][Windows] Refactored remove_directories() w/o CComPtr and atlbase.h (#119843)

This is the update of #118677. This patch fixes building with mingw.

Added: 
    

Modified: 
    llvm/lib/Support/Windows/Path.inc

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Support/Windows/Path.inc b/llvm/lib/Support/Windows/Path.inc
index d4e8261ae4feba..17db114caeb1ec 100644
--- a/llvm/lib/Support/Windows/Path.inc
+++ b/llvm/lib/Support/Windows/Path.inc
@@ -25,7 +25,6 @@
 // These two headers must be included last, and make sure shlobj is required
 // after Windows.h to make sure it picks up our definition of _WIN32_WINNT
 #include "llvm/Support/Windows/WindowsSupport.h"
-#include <atlbase.h>
 #include <shellapi.h>
 #include <shlobj.h>
 
@@ -1395,19 +1394,22 @@ std::error_code remove_directories(const Twine &path, bool IgnoreErrors) {
     if (FAILED(HR))
       break;
     auto Uninitialize = make_scope_exit([] { CoUninitialize(); });
-    CComPtr<IFileOperation> FileOp;
-    HR = FileOp.CoCreateInstance(CLSID_FileOperation);
+    IFileOperation *FileOp = NULL;
+    HR = CoCreateInstance(CLSID_FileOperation, NULL, CLSCTX_ALL,
+                          IID_PPV_ARGS(&FileOp));
     if (FAILED(HR))
       break;
+    auto FileOpRelease = make_scope_exit([&FileOp] { FileOp->Release(); });
     HR = FileOp->SetOperationFlags(FOF_NO_UI | FOFX_NOCOPYHOOKS);
     if (FAILED(HR))
       break;
     PIDLIST_ABSOLUTE PIDL = ILCreateFromPathW(Path16.data());
     auto FreePIDL = make_scope_exit([&PIDL] { ILFree(PIDL); });
-    CComPtr<IShellItem> ShItem;
+    IShellItem *ShItem = NULL;
     HR = SHCreateItemFromIDList(PIDL, IID_PPV_ARGS(&ShItem));
     if (FAILED(HR))
       break;
+    auto ShItemRelease = make_scope_exit([&ShItem] { ShItem->Release(); });
     HR = FileOp->DeleteItem(ShItem, NULL);
     if (FAILED(HR))
       break;


        


More information about the llvm-commits mailing list