[llvm] 6983968 - [Demangle] Pass Ret parameter from decodeNumber by reference
Luís Ferreira via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 12 14:01:54 PST 2022
Author: Luís Ferreira
Date: 2022-01-12T21:57:31Z
New Revision: 6983968e833b03e8a25eba4d2a02e4d1b5d446a2
URL: https://github.com/llvm/llvm-project/commit/6983968e833b03e8a25eba4d2a02e4d1b5d446a2
DIFF: https://github.com/llvm/llvm-project/commit/6983968e833b03e8a25eba4d2a02e4d1b5d446a2.diff
LOG: [Demangle] Pass Ret parameter from decodeNumber by reference
Since Ret parameter is never meant to be nullptr, let's pass it by reference instead of a raw pointer.
Reviewed By: dblaikie
Differential Revision: https://reviews.llvm.org/D117046
Added:
Modified:
llvm/lib/Demangle/DLangDemangle.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Demangle/DLangDemangle.cpp b/llvm/lib/Demangle/DLangDemangle.cpp
index 9c0ea7a51bf4c..7cecd80070878 100644
--- a/llvm/lib/Demangle/DLangDemangle.cpp
+++ b/llvm/lib/Demangle/DLangDemangle.cpp
@@ -68,7 +68,7 @@ struct Demangler {
/// \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 @@ struct Demangler {
} // 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 @@ const char *Demangler::decodeNumber(const char *Mangled, unsigned long *Ret) {
if (*Mangled == '\0')
return nullptr;
- *Ret = Val;
+ Ret = Val;
return Mangled;
}
@@ -278,7 +278,7 @@ const char *Demangler::parseSymbolBackref(OutputBuffer *Demangled,
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;
@@ -419,7 +419,7 @@ const char *Demangler::parseIdentifier(OutputBuffer *Demangled,
// TODO: Parse lengthless template instances.
- const char *Endptr = decodeNumber(Mangled, &Len);
+ const char *Endptr = decodeNumber(Mangled, Len);
if (Endptr == nullptr || Len == 0)
return nullptr;
More information about the llvm-commits
mailing list