9
9
//
10
10
// This file implements the operating system DynamicLibrary concept.
11
11
//
12
- // FIXME: This file leaks ExplicitSymbols and OpenedHandles!
13
- //
14
12
// ===----------------------------------------------------------------------===//
15
13
16
14
#include " llvm/Support/DynamicLibrary.h"
@@ -51,7 +49,7 @@ using namespace llvm::sys;
51
49
// === independent code.
52
50
// ===----------------------------------------------------------------------===//
53
51
54
- static DenseSet<void *> *OpenedHandles = nullptr ;
52
+ static llvm::ManagedStatic< DenseSet<void *> > OpenedHandles ;
55
53
56
54
DynamicLibrary DynamicLibrary::getPermanentLibrary (const char *filename,
57
55
std::string *errMsg) {
@@ -70,9 +68,6 @@ DynamicLibrary DynamicLibrary::getPermanentLibrary(const char *filename,
70
68
handle = RTLD_DEFAULT;
71
69
#endif
72
70
73
- if (!OpenedHandles)
74
- OpenedHandles = new DenseSet<void *>();
75
-
76
71
// If we've already loaded this library, dlclose() the handle in order to
77
72
// keep the internal refcount at +1.
78
73
if (!OpenedHandles->insert (handle).second )
@@ -121,7 +116,7 @@ void* DynamicLibrary::SearchForAddressOfSymbol(const char *symbolName) {
121
116
122
117
#if defined(HAVE_DLFCN_H) && defined(HAVE_DLOPEN)
123
118
// Now search the libraries.
124
- if (OpenedHandles) {
119
+ if (OpenedHandles. isConstructed () ) {
125
120
for (DenseSet<void *>::iterator I = OpenedHandles->begin (),
126
121
E = OpenedHandles->end (); I != E; ++I) {
127
122
// lt_ptr ptr = lt_dlsym(*I, symbolName);
0 commit comments