[Lldb-commits] [lldb] 93503aa - Fix MSVC build issues (#84362)
via lldb-commits
lldb-commits at lists.llvm.org
Tue Mar 12 10:26:48 PDT 2024
Author: Hiroshi Yamauchi
Date: 2024-03-12T10:26:44-07:00
New Revision: 93503aafcdc66837ecf220243aaa530c05c35895
URL: https://github.com/llvm/llvm-project/commit/93503aafcdc66837ecf220243aaa530c05c35895
DIFF: https://github.com/llvm/llvm-project/commit/93503aafcdc66837ecf220243aaa530c05c35895.diff
LOG: Fix MSVC build issues (#84362)
MSVC fails when there is ambiguity (multiple options) around implicit
type conversion operators.
Make ConstString's conversion operator to string_view explicit to avoid
ambiguity with one to StringRef and remove an unused local variable that
MSVC also fails on.
Added:
Modified:
lldb/include/lldb/Utility/ConstString.h
lldb/source/Core/Mangled.cpp
lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
Removed:
################################################################################
diff --git a/lldb/include/lldb/Utility/ConstString.h b/lldb/include/lldb/Utility/ConstString.h
index 470a554ca04869..f7f7ec7605eba4 100644
--- a/lldb/include/lldb/Utility/ConstString.h
+++ b/lldb/include/lldb/Utility/ConstString.h
@@ -168,8 +168,8 @@ class ConstString {
// Implicitly convert \class ConstString instances to \class StringRef.
operator llvm::StringRef() const { return GetStringRef(); }
- // Implicitly convert \class ConstString instances to \class std::string_view.
- operator std::string_view() const {
+ // Explicitly convert \class ConstString instances to \class std::string_view.
+ explicit operator std::string_view() const {
return std::string_view(m_string, GetLength());
}
diff --git a/lldb/source/Core/Mangled.cpp b/lldb/source/Core/Mangled.cpp
index 23ae3913093faf..b167c51fdce247 100644
--- a/lldb/source/Core/Mangled.cpp
+++ b/lldb/source/Core/Mangled.cpp
@@ -125,7 +125,7 @@ void Mangled::SetValue(ConstString name) {
}
// Local helpers for
diff erent demangling implementations.
-static char *GetMSVCDemangledStr(std::string_view M) {
+static char *GetMSVCDemangledStr(llvm::StringRef M) {
char *demangled_cstr = llvm::microsoftDemangle(
M, nullptr, nullptr,
llvm::MSDemangleFlags(
@@ -169,27 +169,29 @@ static char *GetItaniumDemangledStr(const char *M) {
return demangled_cstr;
}
-static char *GetRustV0DemangledStr(std::string_view M) {
+static char *GetRustV0DemangledStr(llvm::StringRef M) {
char *demangled_cstr = llvm::rustDemangle(M);
if (Log *log = GetLog(LLDBLog::Demangle)) {
if (demangled_cstr && demangled_cstr[0])
LLDB_LOG(log, "demangled rustv0: {0} -> \"{1}\"", M, demangled_cstr);
else
- LLDB_LOG(log, "demangled rustv0: {0} -> error: failed to demangle", M);
+ LLDB_LOG(log, "demangled rustv0: {0} -> error: failed to demangle",
+ static_cast<std::string_view>(M));
}
return demangled_cstr;
}
-static char *GetDLangDemangledStr(std::string_view M) {
+static char *GetDLangDemangledStr(llvm::StringRef M) {
char *demangled_cstr = llvm::dlangDemangle(M);
if (Log *log = GetLog(LLDBLog::Demangle)) {
if (demangled_cstr && demangled_cstr[0])
LLDB_LOG(log, "demangled dlang: {0} -> \"{1}\"", M, demangled_cstr);
else
- LLDB_LOG(log, "demangled dlang: {0} -> error: failed to demangle", M);
+ LLDB_LOG(log, "demangled dlang: {0} -> error: failed to demangle",
+ static_cast<std::string_view>(M));
}
return demangled_cstr;
diff --git a/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp b/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
index 6a2ea8c4a41b1c..f237dd63ab1cce 100644
--- a/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
+++ b/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
@@ -527,7 +527,6 @@ TEST_F(SymbolFilePDBTests, TestTypedefs) {
SymbolFilePDB *symfile =
static_cast<SymbolFilePDB *>(module->GetSymbolFile());
llvm::pdb::IPDBSession &session = symfile->GetPDBSession();
- TypeMap results;
const char *TypedefsToCheck[] = {"ClassTypedef", "NSClassTypedef",
"FuncPointerTypedef",
More information about the lldb-commits
mailing list