[PATCH] D65942: Disallow implicit conversion from pointers to bool in llvm::toStringRef
David Blaikie via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 9 10:41:17 PDT 2019
dblaikie added inline comments.
================
Comment at: lldb/source/Symbol/TypeSystem.cpp:331
"TypeSystem for language " +
- llvm::toStringRef(Language::GetNameForLanguageType(language)) +
+ llvm::StringRef(Language::GetNameForLanguageType(language)) +
" doesn't exist",
----------------
Perhaps Language::GetNameForLanguageType should return StringRef to start with?
(& guessing there should be an lldb test case demonstrating this fix?)
================
Comment at: llvm/include/llvm/ADT/StringExtras.h:52-53
/// Construct a string ref from a boolean.
-inline StringRef toStringRef(bool B) { return StringRef(B ? "true" : "false"); }
+template <typename T>
+typename std::enable_if<std::is_same<T, bool>::value, StringRef>::type
+toStringRef(T B) {
----------------
labath wrote:
> This enable_if trick might be worth a short comment...
Sure, something like "ensure only bools are accepted here to avoid surprising implicit conversion to bool (for ints, pointers, etc)" if you like.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D65942/new/
https://reviews.llvm.org/D65942
More information about the llvm-commits
mailing list