Skip to content

Commit 7c658e7

Browse files
committed
fixup! Initialize Process to &Invalid instead of nullptr, so an additional bool is not needed
also fix platform .inc files
1 parent 67456ef commit 7c658e7

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

llvm/lib/Support/Unix/DynamicLibrary.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ DynamicLibrary::HandleSet::~HandleSet() {
1717
// Close the libraries in reverse order.
1818
for (void *Handle : llvm::reverse(Handles))
1919
::dlclose(Handle);
20-
if (Process)
20+
if (Process != &Invalid)
2121
::dlclose(Process);
2222

2323
// llvm_shutdown called, Return to default

llvm/lib/Support/Windows/DynamicLibrary.inc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ DynamicLibrary::HandleSet::~HandleSet() {
2626
FreeLibrary(HMODULE(Handle));
2727

2828
// 'Process' should not be released on Windows.
29-
assert((!Process || Process == this) && "Bad Handle");
29+
assert((Process == &Invalid || Process == this) && "Bad Handle");
3030
// llvm_shutdown called, Return to default
3131
DynamicLibrary::SearchOrder = DynamicLibrary::SO_Linker;
3232
}
@@ -60,7 +60,7 @@ static DynamicLibrary::HandleSet *IsOpenedHandlesInstance(void *Handle) {
6060

6161
void DynamicLibrary::HandleSet::DLClose(void *Handle) {
6262
if (HandleSet *HS = IsOpenedHandlesInstance(Handle))
63-
HS->Process = nullptr; // Just drop the *Process* handle.
63+
HS->Process = &Invalid; // Just drop the *Process* handle.
6464
else
6565
FreeLibrary((HMODULE)Handle);
6666
}
@@ -89,7 +89,7 @@ void *DynamicLibrary::HandleSet::DLSym(void *Handle, const char *Symbol) {
8989
return (void *)uintptr_t(GetProcAddress((HMODULE)Handle, Symbol));
9090

9191
// Could have done a dlclose on the *Process* handle
92-
if (!HS->Process)
92+
if (HS->Process == &Invalid)
9393
return nullptr;
9494

9595
// Trials indicate EnumProcessModulesEx is consistantly faster than using

0 commit comments

Comments
 (0)