[PATCH] D117046: [Demangle] Pass Ret parameter from decodeNumber by reference
Luís Ferreira via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 11 12:18:18 PST 2022
ljmf00 created this revision.
Herald added a subscriber: hiraditya.
ljmf00 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Since Ret parameter is never meant to be nullptr, let's pass it by reference instead of a raw pointer.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D117046
Files:
llvm/lib/Demangle/DLangDemangle.cpp
Index: llvm/lib/Demangle/DLangDemangle.cpp
===================================================================
--- llvm/lib/Demangle/DLangDemangle.cpp
+++ llvm/lib/Demangle/DLangDemangle.cpp
@@ -68,7 +68,7 @@
/// \note A result larger than UINT_MAX is considered a failure.
///
/// \see https://dlang.org/spec/abi.html#Number .
- const char *decodeNumber(const char *Mangled, unsigned long *Ret);
+ const char *decodeNumber(const char *Mangled, unsigned long &Ret);
/// Extract the back reference position from a given string.
///
@@ -179,7 +179,7 @@
} // namespace
-const char *Demangler::decodeNumber(const char *Mangled, unsigned long *Ret) {
+const char *Demangler::decodeNumber(const char *Mangled, unsigned long &Ret) {
// Return nullptr if trying to extract something that isn't a digit.
if (Mangled == nullptr || !std::isdigit(*Mangled))
return nullptr;
@@ -200,7 +200,7 @@
if (*Mangled == '\0')
return nullptr;
- *Ret = Val;
+ Ret = Val;
return Mangled;
}
@@ -278,7 +278,7 @@
Mangled = decodeBackref(Mangled, Backref);
// Must point to a simple identifier
- Backref = decodeNumber(Backref, &Len);
+ Backref = decodeNumber(Backref, Len);
if (Backref == nullptr || strlen(Backref) < Len)
return nullptr;
@@ -415,7 +415,7 @@
// TODO: Parse lengthless template instances.
- const char *Endptr = decodeNumber(Mangled, &Len);
+ const char *Endptr = decodeNumber(Mangled, Len);
if (Endptr == nullptr || Len == 0)
return nullptr;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D117046.399039.patch
Type: text/x-patch
Size: 1523 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220111/68d2a3ae/attachment.bin>
More information about the llvm-commits
mailing list