[libcxx-commits] [libcxxabi] e48cd70 - [demangler] Buffer peeking needs buffer
Nathan Sidwell via libcxx-commits
libcxx-commits at lists.llvm.org
Mon May 9 04:55:31 PDT 2022
Author: Nathan Sidwell
Date: 2022-05-09T04:17:22-07:00
New Revision: e48cd7088b736dae5cd572ebb58963c70a4a72b8
URL: https://github.com/llvm/llvm-project/commit/e48cd7088b736dae5cd572ebb58963c70a4a72b8
DIFF: https://github.com/llvm/llvm-project/commit/e48cd7088b736dae5cd572ebb58963c70a4a72b8.diff
LOG: [demangler] Buffer peeking needs buffer
The output buffer has a 'back' member, which returns NUL when you try
it with an empty buffer. But there are no use cases that need that
additional functionality. This makes the 'back' member behave more
like STL containers' back members. (It still returns a value, not a
reference.)
Reviewed By: dblaikie
Differential Revision: https://reviews.llvm.org/D123201
Added:
Modified:
libcxxabi/src/demangle/Utility.h
llvm/include/llvm/Demangle/Utility.h
Removed:
################################################################################
diff --git a/libcxxabi/src/demangle/Utility.h b/libcxxabi/src/demangle/Utility.h
index 6e0fa38632c89..db19dcac0147d 100644
--- a/libcxxabi/src/demangle/Utility.h
+++ b/libcxxabi/src/demangle/Utility.h
@@ -171,7 +171,8 @@ class OutputBuffer {
void setCurrentPosition(size_t NewPos) { CurrentPosition = NewPos; }
char back() const {
- return CurrentPosition ? Buffer[CurrentPosition - 1] : '\0';
+ assert(CurrentPosition);
+ return Buffer[CurrentPosition - 1];
}
bool empty() const { return CurrentPosition == 0; }
diff --git a/llvm/include/llvm/Demangle/Utility.h b/llvm/include/llvm/Demangle/Utility.h
index b17eadcfa3bee..ca7e44b948c71 100644
--- a/llvm/include/llvm/Demangle/Utility.h
+++ b/llvm/include/llvm/Demangle/Utility.h
@@ -171,7 +171,8 @@ class OutputBuffer {
void setCurrentPosition(size_t NewPos) { CurrentPosition = NewPos; }
char back() const {
- return CurrentPosition ? Buffer[CurrentPosition - 1] : '\0';
+ assert(CurrentPosition);
+ return Buffer[CurrentPosition - 1];
}
bool empty() const { return CurrentPosition == 0; }
More information about the libcxx-commits
mailing list