[llvm] [llvm][Support][Windows] Refactored remove_directories() w/o CComPtr and atlbase.h (PR #119843)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 13 01:22:43 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-platform-windows
Author: Dmitry Vasilyev (slydiman)
<details>
<summary>Changes</summary>
This is the update of #<!-- -->118677.
---
Full diff: https://github.com/llvm/llvm-project/pull/119843.diff
1 Files Affected:
- (modified) llvm/lib/Support/Windows/Path.inc (+6-4)
``````````diff
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;
``````````
</details>
https://github.com/llvm/llvm-project/pull/119843
More information about the llvm-commits
mailing list