[Lldb-commits] [PATCH] D65942: Disallow implicit conversion from pointers to bool in llvm::toStringRef
Raphael Isemann via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Thu Aug 8 06:48:26 PDT 2019
teemperor updated this revision to Diff 214141.
teemperor retitled this revision from "Disallow implicit conversion from const char* to bool in llvm::toStringRef" to "Disallow implicit conversion from pointers to bool in llvm::toStringRef".
teemperor edited the summary of this revision.
teemperor added a comment.
- Now disallowing all implicit conversions.
- Fixed typo in comment.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D65942/new/
https://reviews.llvm.org/D65942
Files:
lldb/source/Symbol/TypeSystem.cpp
llvm/include/llvm/ADT/StringExtras.h
Index: llvm/include/llvm/ADT/StringExtras.h
===================================================================
--- llvm/include/llvm/ADT/StringExtras.h
+++ llvm/include/llvm/ADT/StringExtras.h
@@ -50,6 +50,8 @@
/// Construct a string ref from a boolean.
inline StringRef toStringRef(bool B) { return StringRef(B ? "true" : "false"); }
+/// Prevent implicit conversion from pointers (e.g. const char*) to bool.
+StringRef toStringRef(const void *) = delete;
/// Construct a string ref from an array ref of unsigned chars.
inline StringRef toStringRef(ArrayRef<uint8_t> Input) {
Index: lldb/source/Symbol/TypeSystem.cpp
===================================================================
--- lldb/source/Symbol/TypeSystem.cpp
+++ lldb/source/Symbol/TypeSystem.cpp
@@ -219,7 +219,7 @@
}
error = llvm::make_error<llvm::StringError>(
"TypeSystem for language " +
- llvm::toStringRef(Language::GetNameForLanguageType(language)) +
+ llvm::StringRef(Language::GetNameForLanguageType(language)) +
" doesn't exist",
llvm::inconvertibleErrorCode());
return std::move(error);
@@ -236,7 +236,7 @@
}
error = llvm::make_error<llvm::StringError>(
"TypeSystem for language " +
- llvm::toStringRef(Language::GetNameForLanguageType(language)) +
+ llvm::StringRef(Language::GetNameForLanguageType(language)) +
" doesn't exist",
llvm::inconvertibleErrorCode());
return std::move(error);
@@ -246,7 +246,7 @@
if (!can_create) {
error = llvm::make_error<llvm::StringError>(
"Unable to find type system for language " +
- llvm::toStringRef(Language::GetNameForLanguageType(language)),
+ llvm::StringRef(Language::GetNameForLanguageType(language)),
llvm::inconvertibleErrorCode());
} else {
// Cache even if we get a shared pointer that contains a null type system
@@ -259,7 +259,7 @@
}
error = llvm::make_error<llvm::StringError>(
"TypeSystem for language " +
- llvm::toStringRef(Language::GetNameForLanguageType(language)) +
+ llvm::StringRef(Language::GetNameForLanguageType(language)) +
" doesn't exist",
llvm::inconvertibleErrorCode());
}
@@ -288,7 +288,7 @@
}
error = llvm::make_error<llvm::StringError>(
"TypeSystem for language " +
- llvm::toStringRef(Language::GetNameForLanguageType(language)) +
+ llvm::StringRef(Language::GetNameForLanguageType(language)) +
" doesn't exist",
llvm::inconvertibleErrorCode());
return std::move(error);
@@ -305,7 +305,7 @@
}
error = llvm::make_error<llvm::StringError>(
"TypeSystem for language " +
- llvm::toStringRef(Language::GetNameForLanguageType(language)) +
+ llvm::StringRef(Language::GetNameForLanguageType(language)) +
" doesn't exist",
llvm::inconvertibleErrorCode());
return std::move(error);
@@ -315,7 +315,7 @@
if (!can_create) {
error = llvm::make_error<llvm::StringError>(
"Unable to find type system for language " +
- llvm::toStringRef(Language::GetNameForLanguageType(language)),
+ llvm::StringRef(Language::GetNameForLanguageType(language)),
llvm::inconvertibleErrorCode());
} else {
// Cache even if we get a shared pointer that contains a null type system
@@ -328,7 +328,7 @@
}
error = llvm::make_error<llvm::StringError>(
"TypeSystem for language " +
- llvm::toStringRef(Language::GetNameForLanguageType(language)) +
+ llvm::StringRef(Language::GetNameForLanguageType(language)) +
" doesn't exist",
llvm::inconvertibleErrorCode());
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65942.214141.patch
Type: text/x-patch
Size: 3959 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20190808/9ccc7773/attachment-0001.bin>
More information about the lldb-commits
mailing list