[ItaniumDemangle] Add Named flag to "pm" operator#136862
Conversation
|
@llvm/pr-subscribers-libcxxabi Author: Michael Buch (Michael137) ChangesCompilers can generate mangled names such as Full diff: https://github.com/llvm/llvm-project/pull/136862.diff 3 Files Affected:
diff --git a/libcxxabi/src/demangle/ItaniumDemangle.h b/libcxxabi/src/demangle/ItaniumDemangle.h
index 69932e63669bf..67cc4560f061d 100644
--- a/libcxxabi/src/demangle/ItaniumDemangle.h
+++ b/libcxxabi/src/demangle/ItaniumDemangle.h
@@ -3389,9 +3389,9 @@ const typename AbstractManglingParser<
{"de", OperatorInfo::Prefix, false, Node::Prec::Unary, "operator*"},
{"dl", OperatorInfo::Del, /*Ary*/ false, Node::Prec::Unary,
"operator delete"},
- {"ds", OperatorInfo::Member, /*Named*/ false, Node::Prec::PtrMem,
+ {"ds", OperatorInfo::Member, false, Node::Prec::PtrMem,
"operator.*"},
- {"dt", OperatorInfo::Member, /*Named*/ false, Node::Prec::Postfix,
+ {"dt", OperatorInfo::Member, false, Node::Prec::Postfix,
"operator."},
{"dv", OperatorInfo::Binary, false, Node::Prec::Assign, "operator/"},
{"eO", OperatorInfo::Binary, false, Node::Prec::Assign, "operator^="},
@@ -3421,11 +3421,11 @@ const typename AbstractManglingParser<
{"or", OperatorInfo::Binary, false, Node::Prec::Ior, "operator|"},
{"pL", OperatorInfo::Binary, false, Node::Prec::Assign, "operator+="},
{"pl", OperatorInfo::Binary, false, Node::Prec::Additive, "operator+"},
- {"pm", OperatorInfo::Member, /*Named*/ false, Node::Prec::PtrMem,
+ {"pm", OperatorInfo::Member, false, Node::Prec::PtrMem,
"operator->*"},
{"pp", OperatorInfo::Postfix, false, Node::Prec::Postfix, "operator++"},
{"ps", OperatorInfo::Prefix, false, Node::Prec::Unary, "operator+"},
- {"pt", OperatorInfo::Member, /*Named*/ true, Node::Prec::Postfix,
+ {"pt", OperatorInfo::Member, false, Node::Prec::Postfix,
"operator->"},
{"qu", OperatorInfo::Conditional, false, Node::Prec::Conditional,
"operator?"},
@@ -3499,9 +3499,6 @@ AbstractManglingParser<Derived, Alloc>::parseOperatorName(NameState *State) {
if (Op->getKind() >= OperatorInfo::Unnameable)
/* Not a nameable operator. */
return nullptr;
- if (Op->getKind() == OperatorInfo::Member && !Op->getFlag())
- /* Not a nameable MemberExpr */
- return nullptr;
return make<NameType>(Op->getName());
}
diff --git a/libcxxabi/test/test_demangle.pass.cpp b/libcxxabi/test/test_demangle.pass.cpp
index 53da1bf6765e7..22b39fb06458d 100644
--- a/libcxxabi/test/test_demangle.pass.cpp
+++ b/libcxxabi/test/test_demangle.pass.cpp
@@ -30246,6 +30246,10 @@ const char* cases[][2] = {
{"_Z3fooPU9__ptrauthILj3ELb1ELj234EEPi", "foo(int* __ptrauth<3u, true, 234u>*)"},
{"_Z3fooIPU9__ptrauthILj1ELb0ELj64EEPiEvT_", "void foo<int* __ptrauth<1u, false, 64u>*>(int* __ptrauth<1u, false, 64u>*)"},
+
+ {"_ZN1CpmEi", "C::operator->*(int)"},
+ {"_ZN1CdtEi", "C::operator.(int)"},
+ {"_ZN1CdsEi", "C::operator.*(int)"},
// clang-format on
};
diff --git a/llvm/include/llvm/Demangle/ItaniumDemangle.h b/llvm/include/llvm/Demangle/ItaniumDemangle.h
index b4a4c72021fd1..f75e309b06e0a 100644
--- a/llvm/include/llvm/Demangle/ItaniumDemangle.h
+++ b/llvm/include/llvm/Demangle/ItaniumDemangle.h
@@ -3389,9 +3389,9 @@ const typename AbstractManglingParser<
{"de", OperatorInfo::Prefix, false, Node::Prec::Unary, "operator*"},
{"dl", OperatorInfo::Del, /*Ary*/ false, Node::Prec::Unary,
"operator delete"},
- {"ds", OperatorInfo::Member, /*Named*/ false, Node::Prec::PtrMem,
+ {"ds", OperatorInfo::Member, false, Node::Prec::PtrMem,
"operator.*"},
- {"dt", OperatorInfo::Member, /*Named*/ false, Node::Prec::Postfix,
+ {"dt", OperatorInfo::Member, false, Node::Prec::Postfix,
"operator."},
{"dv", OperatorInfo::Binary, false, Node::Prec::Assign, "operator/"},
{"eO", OperatorInfo::Binary, false, Node::Prec::Assign, "operator^="},
@@ -3421,11 +3421,11 @@ const typename AbstractManglingParser<
{"or", OperatorInfo::Binary, false, Node::Prec::Ior, "operator|"},
{"pL", OperatorInfo::Binary, false, Node::Prec::Assign, "operator+="},
{"pl", OperatorInfo::Binary, false, Node::Prec::Additive, "operator+"},
- {"pm", OperatorInfo::Member, /*Named*/ false, Node::Prec::PtrMem,
+ {"pm", OperatorInfo::Member, false, Node::Prec::PtrMem,
"operator->*"},
{"pp", OperatorInfo::Postfix, false, Node::Prec::Postfix, "operator++"},
{"ps", OperatorInfo::Prefix, false, Node::Prec::Unary, "operator+"},
- {"pt", OperatorInfo::Member, /*Named*/ true, Node::Prec::Postfix,
+ {"pt", OperatorInfo::Member, false, Node::Prec::Postfix,
"operator->"},
{"qu", OperatorInfo::Conditional, false, Node::Prec::Conditional,
"operator?"},
@@ -3499,9 +3499,6 @@ AbstractManglingParser<Derived, Alloc>::parseOperatorName(NameState *State) {
if (Op->getKind() >= OperatorInfo::Unnameable)
/* Not a nameable operator. */
return nullptr;
- if (Op->getKind() == OperatorInfo::Member && !Op->getFlag())
- /* Not a nameable MemberExpr */
- return nullptr;
return make<NameType>(Op->getName());
}
|
|
@urnathan I couldn't really find an explanation for what "Not a nameable MemberExpr" are. Any idea if this is still needed? Test-suite runs cleanly without this |
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
urnathan
left a comment
There was a problem hiding this comment.
On vacation. But iirc this logic predates my rewrite. Ill try and remember to look more later
Thanks! Seems to have been introduced by: But couldn't quite tell from the diff why this condition was necessary. |
|
Ah what was probably meant by this is that the operators are non-overloadable, and thus "not nameable". If we want to keep that check we should at least mark |
|
Decided to put condition back and just make |
Compilers can generate mangled names such as
_ZN1CpmEiwhich we currently fail to demangle. The OperatorInfo table only marked theptoperator as being "named", which prevented the others from demangling properly. Removing this logic for the other kinds of member operators isn't causing any tests to fail.