Skip to content

Commit 7de79bd

Browse files
committed
Fix a crash on Windows, remove redundant swift::, don't bother using std::move() on POD types
1 parent bc3dcb3 commit 7de79bd

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

stdlib/public/runtime/SymbolInfo.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,11 @@
2121
#include <dlfcn.h>
2222
#endif
2323

24-
#include <utility>
25-
2624
#include "ImageInspection.h"
2725

2826
using namespace swift;
2927

30-
const char *swift::SymbolInfo::getFilename() const {
28+
const char *SymbolInfo::getFilename() const {
3129
#if defined(_WIN32) && !defined(__CYGWIN__)
3230
return nullptr;
3331
#elif SWIFT_STDLIB_HAS_DLADDR
@@ -37,7 +35,7 @@ const char *swift::SymbolInfo::getFilename() const {
3735
#endif
3836
}
3937

40-
const void *swift::SymbolInfo::getBaseAddress() const {
38+
const void *SymbolInfo::getBaseAddress() const {
4139
#if defined(_WIN32) && !defined(__CYGWIN__)
4240
return reinterpret_cast<const void *>(_package.si.ModBase);
4341
#elif SWIFT_STDLIB_HAS_DLADDR
@@ -47,7 +45,7 @@ const void *swift::SymbolInfo::getBaseAddress() const {
4745
#endif
4846
}
4947

50-
const char *swift::SymbolInfo::getSymbolName() const {
48+
const char *SymbolInfo::getSymbolName() const {
5149
#if defined(_WIN32) && !defined(__CYGWIN__)
5250
return _package.si.Name;
5351
#elif SWIFT_STDLIB_HAS_DLADDR
@@ -57,7 +55,7 @@ const char *swift::SymbolInfo::getSymbolName() const {
5755
#endif
5856
}
5957

60-
const void *swift::SymbolInfo::getSymbolAddress() const {
58+
const void *SymbolInfo::getSymbolAddress() const {
6159
#if defined(_WIN32) && !defined(__CYGWIN__)
6260
return reinterpret_cast<const void *>(_package.si.Address);
6361
#elif SWIFT_STDLIB_HAS_DLADDR
@@ -67,7 +65,7 @@ const void *swift::SymbolInfo::getSymbolAddress() const {
6765
#endif
6866
}
6967

70-
llvm::Optional<SymbolInfo> swift::SymbolInfo::lookup(const void *address) {
68+
llvm::Optional<SymbolInfo> SymbolInfo::lookup(const void *address) {
7169
llvm::Optional<SymbolInfo> result;
7270

7371
#if defined(__wasm__)
@@ -78,21 +76,21 @@ llvm::Optional<SymbolInfo> swift::SymbolInfo::lookup(const void *address) {
7876
#elif defined(_WIN32) && !defined(__CYGWIN__)
7977
_swift_win32_withDbgHelpLibrary([&] (HANDLE hProcess) {
8078
if (!hProcess) {
81-
return 0;
79+
return;
8280
}
8381

8482
SymbolInfo info;
8583
info._package.si.SizeOfStruct = sizeof(SYMBOL_INFO);
8684
info._package.si.MaxNameLen = MAX_SYM_NAME;
8785
if (SymFromAddr(hProcess, reinterpret_cast<const DWORD64>(address),
8886
nullptr, &info._package.si)) {
89-
result = std::move(info);
87+
result = info;
9088
}
9189
});
9290
#elif SWIFT_STDLIB_HAS_DLADDR
9391
SymbolInfo info;
9492
if (dladdr(address, &info._info)) {
95-
result = std::move(info);
93+
result = info;
9694
}
9795
#endif
9896

0 commit comments

Comments
 (0)