aboutsummaryrefslogtreecommitdiff
path: root/absl/debugging/internal/demangle.cc
diff options
context:
space:
mode:
authorChris Mihelich <cmihelic@google.com>2024-05-28 11:04:04 -0700
committerCopybara-Service <copybara-worker@google.com>2024-05-28 11:04:54 -0700
commit4a861bb14ba1baf203912f11360d4d8a6379faf7 (patch)
tree9b13bb36b4b9b4a5c087b1aa6a2d663c6b7c02df /absl/debugging/internal/demangle.cc
parent90d49cbad8c503418a10056e2d50c93caa0d142b (diff)
downloadabseil-4a861bb14ba1baf203912f11360d4d8a6379faf7.tar.gz
abseil-4a861bb14ba1baf203912f11360d4d8a6379faf7.tar.bz2
abseil-4a861bb14ba1baf203912f11360d4d8a6379faf7.zip
Demangle valueless literals LDnE (nullptr) and LA<number>_<type>E ("foo").
PiperOrigin-RevId: 637958502 Change-Id: If81eba9729c16b5d5ac7187cf74738d8aaace367
Diffstat (limited to 'absl/debugging/internal/demangle.cc')
-rw-r--r--absl/debugging/internal/demangle.cc33
1 files changed, 29 insertions, 4 deletions
diff --git a/absl/debugging/internal/demangle.cc b/absl/debugging/internal/demangle.cc
index c27cc01a..38b5458e 100644
--- a/absl/debugging/internal/demangle.cc
+++ b/absl/debugging/internal/demangle.cc
@@ -2040,10 +2040,35 @@ static bool ParseExprPrimary(State *state) {
return false;
}
- // The merged cast production.
- if (ParseOneCharToken(state, 'L') && ParseType(state) &&
- ParseExprCastValueAndTrailingE(state)) {
- return true;
+ if (ParseOneCharToken(state, 'L')) {
+ // There are two special cases in which a literal may or must contain a type
+ // without a value. The first is that both LDnE and LDn0E are valid
+ // encodings of nullptr, used in different situations. Recognize LDnE here,
+ // leaving LDn0E to be recognized by the general logic afterward.
+ if (ParseThreeCharToken(state, "DnE")) return true;
+
+ // The second special case is a string literal, currently mangled in C++98
+ // style as LA<length + 1>_KcE. This is inadequate to support C++11 and
+ // later versions, and the discussion of this problem has not converged.
+ //
+ // https://github.com/itanium-cxx-abi/cxx-abi/issues/64
+ //
+ // For now the bare-type mangling is what's used in practice, so we
+ // recognize this form and only this form if an array type appears here.
+ // Someday we'll probably have to accept a new form of value mangling in
+ // LA...E constructs. (Note also that C++20 allows a wide range of
+ // class-type objects as template arguments, so someday their values will be
+ // mangled and we'll have to recognize them here too.)
+ if (RemainingInput(state)[0] == 'A' /* an array type follows */) {
+ if (ParseType(state) && ParseOneCharToken(state, 'E')) return true;
+ state->parse_state = copy;
+ return false;
+ }
+
+ // The merged cast production.
+ if (ParseType(state) && ParseExprCastValueAndTrailingE(state)) {
+ return true;
+ }
}
state->parse_state = copy;