aboutsummaryrefslogtreecommitdiff
path: root/absl/debugging
diff options
context:
space:
mode:
Diffstat (limited to 'absl/debugging')
-rw-r--r--absl/debugging/internal/demangle.cc14
-rw-r--r--absl/debugging/internal/demangle_test.cc30
2 files changed, 44 insertions, 0 deletions
diff --git a/absl/debugging/internal/demangle.cc b/absl/debugging/internal/demangle.cc
index 99cc324b..79246e9b 100644
--- a/absl/debugging/internal/demangle.cc
+++ b/absl/debugging/internal/demangle.cc
@@ -1996,6 +1996,8 @@ static bool ParseBracedExpression(State *state) {
// ::= cc <type> <expression>
// ::= rc <type> <expression>
// ::= st <type>
+// ::= at <type>
+// ::= az <expression>
// ::= <template-param>
// ::= <function-param>
// ::= sZ <template-param>
@@ -2122,6 +2124,18 @@ static bool ParseExpression(State *state) {
}
state->parse_state = copy;
+ // alignof(type)
+ if (ParseTwoCharToken(state, "at") && ParseType(state)) {
+ return true;
+ }
+ state->parse_state = copy;
+
+ // alignof(expression), a GNU extension
+ if (ParseTwoCharToken(state, "az") && ParseExpression(state)) {
+ return true;
+ }
+ state->parse_state = copy;
+
// sizeof...(pack)
//
// <expression> ::= sZ <template-param>
diff --git a/absl/debugging/internal/demangle_test.cc b/absl/debugging/internal/demangle_test.cc
index 2f2a48a6..a91935f4 100644
--- a/absl/debugging/internal/demangle_test.cc
+++ b/absl/debugging/internal/demangle_test.cc
@@ -1098,6 +1098,36 @@ TEST(Demangle, ReinterpretCast) {
EXPECT_STREQ("f<>()", tmp);
}
+TEST(Demangle, AlignofType) {
+ char tmp[80];
+
+ // Source:
+ //
+ // template <class T> T f(T (&a)[alignof(T)]) { return a[0]; }
+ // template int f<int>(int (&)[alignof(int)]);
+ //
+ // Full LLVM demangling of the instantiation of f:
+ //
+ // int f<int>(int (&) [alignof (int)])
+ EXPECT_TRUE(Demangle("_Z1fIiET_RAatS0__S0_", tmp, sizeof(tmp)));
+ EXPECT_STREQ("f<>()", tmp);
+}
+
+TEST(Demangle, AlignofExpression) {
+ char tmp[80];
+
+ // Source (note that this uses a GNU extension; it is not standard C++):
+ //
+ // template <class T> T f(T (&a)[alignof(T{})]) { return a[0]; }
+ // template int f<int>(int (&)[alignof(int{})]);
+ //
+ // Full LLVM demangling of the instantiation of f:
+ //
+ // int f<int>(int (&) [alignof (int{})])
+ EXPECT_TRUE(Demangle("_Z1fIiET_RAaztlS0_E_S0_", tmp, sizeof(tmp)));
+ EXPECT_STREQ("f<>()", tmp);
+}
+
TEST(Demangle, ThreadLocalWrappers) {
char tmp[80];