[llvm] [llvm][Support][Windows] Refactored remove_directories() w/o CComPtr and atlbase.h (PR #119843)
Dmitry Vasilyev via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 13 01:22:21 PST 2024
https://github.com/slydiman created https://github.com/llvm/llvm-project/pull/119843
This is the update of #118677.
>From 4724a069e4ed3036213191fccde677fbbea8d486 Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev <dvassiliev at accesssoftek.com>
Date: Fri, 13 Dec 2024 13:14:38 +0400
Subject: [PATCH] [llvm][Support][Windows] Refactored remove_directories() w/o
CComPtr and atlbase.h
This is the update of #118677.
---
llvm/lib/Support/Windows/Path.inc | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
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