diff options
author | Senran Zhang <zsrkmyn@gmail.com> | 2022-03-26 19:04:23 +0300 |
---|---|---|
committer | Senran Zhang <zsrkmyn@gmail.com> | 2022-04-08 07:20:45 +0300 |
commit | a23652f6f9d8bcdeb7eee81c45eaf3ae65cfb3c5 (patch) | |
tree | 7a6ece9bdeb3ebc4b0b07dfbd00eb859e6abba6d /libcxxabi/src/demangle | |
parent | 497f87bb7b4f72da52d58ce8016ebe1537b8b2c0 (diff) |
[demangler] Support C23 _BitInt type
Reviewed By: #libc_abi, aaron.ballman, urnathan
Differential Revision: https://reviews.llvm.org/D122530
Diffstat (limited to 'libcxxabi/src/demangle')
-rw-r--r-- | libcxxabi/src/demangle/ItaniumDemangle.h | 36 | ||||
-rw-r--r-- | libcxxabi/src/demangle/ItaniumNodes.def | 1 |
2 files changed, 37 insertions, 0 deletions
diff --git a/libcxxabi/src/demangle/ItaniumDemangle.h b/libcxxabi/src/demangle/ItaniumDemangle.h index 36fe26b44620..90f62bab0bd9 100644 --- a/libcxxabi/src/demangle/ItaniumDemangle.h +++ b/libcxxabi/src/demangle/ItaniumDemangle.h @@ -482,6 +482,26 @@ public: void printLeft(OutputBuffer &OB) const override { OB += Name; } }; +class BitIntType final : public Node { + const Node *Size; + bool Signed; + +public: + BitIntType(const Node *Size_, bool Signed_) + : Node(KBitIntType), Size(Size_), Signed(Signed_) {} + + template <typename Fn> void match(Fn F) const { F(Size, Signed); } + + void printLeft(OutputBuffer &OB) const override { + if (!Signed) + OB += "unsigned "; + OB += "_BitInt"; + OB.printOpen(); + Size->printAsOperand(OB); + OB.printClose(); + } +}; + class ElaboratedTypeSpefType : public Node { StringView Kind; Node *Child; @@ -3924,6 +3944,22 @@ Node *AbstractManglingParser<Derived, Alloc>::parseType() { return nullptr; return make<BinaryFPType>(DimensionNumber); } + // ::= DB <number> _ # C23 signed _BitInt(N) + // ::= DB <instantiation-dependent expression> _ # C23 signed _BitInt(N) + // ::= DU <number> _ # C23 unsigned _BitInt(N) + // ::= DU <instantiation-dependent expression> _ # C23 unsigned _BitInt(N) + case 'B': + case 'U': { + bool Signed = look(1) == 'B'; + First += 2; + Node *Size = std::isdigit(look()) ? make<NameType>(parseNumber()) + : getDerived().parseExpr(); + if (!Size) + return nullptr; + if (!consumeIf('_')) + return nullptr; + return make<BitIntType>(Size, Signed); + } // ::= Di # char32_t case 'i': First += 2; diff --git a/libcxxabi/src/demangle/ItaniumNodes.def b/libcxxabi/src/demangle/ItaniumNodes.def index 1d71c5de8e9d..f615cb9fadb0 100644 --- a/libcxxabi/src/demangle/ItaniumNodes.def +++ b/libcxxabi/src/demangle/ItaniumNodes.def @@ -42,6 +42,7 @@ NODE(ModuleEntity) NODE(VectorType) NODE(PixelVectorType) NODE(BinaryFPType) +NODE(BitIntType) NODE(SyntheticTemplateParamName) NODE(TypeTemplateParamDecl) NODE(NonTypeTemplateParamDecl) |