| ... | @@ -17,8 +17,9 @@ | ... | @@ -17,8 +17,9 @@ |
| 17 | #define DEMANGLE_ITANIUMDEMANGLE_H | 17 | #define DEMANGLE_ITANIUMDEMANGLE_H |
| 18 | | 18 | |
| 19 | #include "DemangleConfig.h" | 19 | #include "DemangleConfig.h" |
| 20 | #include "StringView.h" | 20 | #include "StringViewExtras.h" |
| 21 | #include "Utility.h" | 21 | #include "Utility.h" |
| | 22 | #include <__cxxabi_config.h> |
| 22 | #include <algorithm> | 23 | #include <algorithm> |
| 23 | #include <cassert> | 24 | #include <cassert> |
| 24 | #include <cctype> | 25 | #include <cctype> |
| ... | @@ -27,8 +28,15 @@ | ... | @@ -27,8 +28,15 @@ |
| 27 | #include <cstring> | 28 | #include <cstring> |
| 28 | #include <limits> | 29 | #include <limits> |
| 29 | #include <new> | 30 | #include <new> |
| | 31 | #include <string_view> |
| | 32 | #include <type_traits> |
| 30 | #include <utility> | 33 | #include <utility> |
| 31 | | 34 | |
| | 35 | #ifdef _LIBCXXABI_COMPILER_CLANG |
| | 36 | #pragma clang diagnostic push |
| | 37 | #pragma clang diagnostic ignored "-Wunused-template" |
| | 38 | #endif |
| | 39 | |
| 32 | DEMANGLE_NAMESPACE_BEGIN | 40 | DEMANGLE_NAMESPACE_BEGIN |
| 33 | | 41 | |
| 34 | template <class T, size_t N> class PODSmallVector { | 42 | template <class T, size_t N> class PODSmallVector { |
| ... | @@ -286,7 +294,7 @@ public: | ... | @@ -286,7 +294,7 @@ public: |
| 286 | // implementation. | 294 | // implementation. |
| 287 | virtual void printRight(OutputBuffer &) const {} | 295 | virtual void printRight(OutputBuffer &) const {} |
| 288 | | 296 | |
| 289 | virtual StringView getBaseName() const { return StringView(); } | 297 | virtual std::string_view getBaseName() const { return {}; } |
| 290 | | 298 | |
| 291 | // Silence compiler warnings, this dtor will never be called. | 299 | // Silence compiler warnings, this dtor will never be called. |
| 292 | virtual ~Node() = default; | 300 | virtual ~Node() = default; |
| ... | @@ -345,10 +353,10 @@ struct NodeArrayNode : Node { | ... | @@ -345,10 +353,10 @@ struct NodeArrayNode : Node { |
| 345 | | 353 | |
| 346 | class DotSuffix final : public Node { | 354 | class DotSuffix final : public Node { |
| 347 | const Node *Prefix; | 355 | const Node *Prefix; |
| 348 | const StringView Suffix; | 356 | const std::string_view Suffix; |
| 349 | | 357 | |
| 350 | public: | 358 | public: |
| 351 | DotSuffix(const Node *Prefix_, StringView Suffix_) | 359 | DotSuffix(const Node *Prefix_, std::string_view Suffix_) |
| 352 | : Node(KDotSuffix), Prefix(Prefix_), Suffix(Suffix_) {} | 360 | : Node(KDotSuffix), Prefix(Prefix_), Suffix(Suffix_) {} |
| 353 | | 361 | |
| 354 | template<typename Fn> void match(Fn F) const { F(Prefix, Suffix); } | 362 | template<typename Fn> void match(Fn F) const { F(Prefix, Suffix); } |
| ... | @@ -363,15 +371,15 @@ public: | ... | @@ -363,15 +371,15 @@ public: |
| 363 | | 371 | |
| 364 | class VendorExtQualType final : public Node { | 372 | class VendorExtQualType final : public Node { |
| 365 | const Node *Ty; | 373 | const Node *Ty; |
| 366 | StringView Ext; | 374 | std::string_view Ext; |
| 367 | const Node *TA; | 375 | const Node *TA; |
| 368 | | 376 | |
| 369 | public: | 377 | public: |
| 370 | VendorExtQualType(const Node *Ty_, StringView Ext_, const Node *TA_) | 378 | VendorExtQualType(const Node *Ty_, std::string_view Ext_, const Node *TA_) |
| 371 | : Node(KVendorExtQualType), Ty(Ty_), Ext(Ext_), TA(TA_) {} | 379 | : Node(KVendorExtQualType), Ty(Ty_), Ext(Ext_), TA(TA_) {} |
| 372 | | 380 | |
| 373 | const Node *getTy() const { return Ty; } | 381 | const Node *getTy() const { return Ty; } |
| 374 | StringView getExt() const { return Ext; } | 382 | std::string_view getExt() const { return Ext; } |
| 375 | const Node *getTA() const { return TA; } | 383 | const Node *getTA() const { return TA; } |
| 376 | | 384 | |
| 377 | template <typename Fn> void match(Fn F) const { F(Ty, Ext, TA); } | 385 | template <typename Fn> void match(Fn F) const { F(Ty, Ext, TA); } |
| ... | @@ -462,10 +470,10 @@ public: | ... | @@ -462,10 +470,10 @@ public: |
| 462 | | 470 | |
| 463 | class PostfixQualifiedType final : public Node { | 471 | class PostfixQualifiedType final : public Node { |
| 464 | const Node *Ty; | 472 | const Node *Ty; |
| 465 | const StringView Postfix; | 473 | const std::string_view Postfix; |
| 466 | | 474 | |
| 467 | public: | 475 | public: |
| 468 | PostfixQualifiedType(const Node *Ty_, StringView Postfix_) | 476 | PostfixQualifiedType(const Node *Ty_, std::string_view Postfix_) |
| 469 | : Node(KPostfixQualifiedType), Ty(Ty_), Postfix(Postfix_) {} | 477 | : Node(KPostfixQualifiedType), Ty(Ty_), Postfix(Postfix_) {} |
| 470 | | 478 | |
| 471 | template<typename Fn> void match(Fn F) const { F(Ty, Postfix); } | 479 | template<typename Fn> void match(Fn F) const { F(Ty, Postfix); } |
| ... | @@ -477,15 +485,15 @@ public: | ... | @@ -477,15 +485,15 @@ public: |
| 477 | }; | 485 | }; |
| 478 | | 486 | |
| 479 | class NameType final : public Node { | 487 | class NameType final : public Node { |
| 480 | const StringView Name; | 488 | const std::string_view Name; |
| 481 | | 489 | |
| 482 | public: | 490 | public: |
| 483 | NameType(StringView Name_) : Node(KNameType), Name(Name_) {} | 491 | NameType(std::string_view Name_) : Node(KNameType), Name(Name_) {} |
| 484 | | 492 | |
| 485 | template<typename Fn> void match(Fn F) const { F(Name); } | 493 | template<typename Fn> void match(Fn F) const { F(Name); } |
| 486 | | 494 | |
| 487 | StringView getName() const { return Name; } | 495 | std::string_view getName() const { return Name; } |
| 488 | StringView getBaseName() const override { return Name; } | 496 | std::string_view getBaseName() const override { return Name; } |
| 489 | | 497 | |
| 490 | void printLeft(OutputBuffer &OB) const override { OB += Name; } | 498 | void printLeft(OutputBuffer &OB) const override { OB += Name; } |
| 491 | }; | 499 | }; |
| ... | @@ -511,10 +519,10 @@ public: | ... | @@ -511,10 +519,10 @@ public: |
| 511 | }; | 519 | }; |
| 512 | | 520 | |
| 513 | class ElaboratedTypeSpefType : public Node { | 521 | class ElaboratedTypeSpefType : public Node { |
| 514 | StringView Kind; | 522 | std::string_view Kind; |
| 515 | Node *Child; | 523 | Node *Child; |
| 516 | public: | 524 | public: |
| 517 | ElaboratedTypeSpefType(StringView Kind_, Node *Child_) | 525 | ElaboratedTypeSpefType(std::string_view Kind_, Node *Child_) |
| 518 | : Node(KElaboratedTypeSpefType), Kind(Kind_), Child(Child_) {} | 526 | : Node(KElaboratedTypeSpefType), Kind(Kind_), Child(Child_) {} |
| 519 | | 527 | |
| 520 | template<typename Fn> void match(Fn F) const { F(Kind, Child); } | 528 | template<typename Fn> void match(Fn F) const { F(Kind, Child); } |
| ... | @@ -528,15 +536,17 @@ public: | ... | @@ -528,15 +536,17 @@ public: |
| 528 | | 536 | |
| 529 | struct AbiTagAttr : Node { | 537 | struct AbiTagAttr : Node { |
| 530 | Node *Base; | 538 | Node *Base; |
| 531 | StringView Tag; | 539 | std::string_view Tag; |
| 532 | | 540 | |
| 533 | AbiTagAttr(Node* Base_, StringView Tag_) | 541 | AbiTagAttr(Node *Base_, std::string_view Tag_) |
| 534 | : Node(KAbiTagAttr, Base_->RHSComponentCache, | 542 | : Node(KAbiTagAttr, Base_->RHSComponentCache, Base_->ArrayCache, |
| 535 | Base_->ArrayCache, Base_->FunctionCache), | 543 | Base_->FunctionCache), |
| 536 | Base(Base_), Tag(Tag_) {} | 544 | Base(Base_), Tag(Tag_) {} |
| 537 | | 545 | |
| 538 | template<typename Fn> void match(Fn F) const { F(Base, Tag); } | 546 | template<typename Fn> void match(Fn F) const { F(Base, Tag); } |
| 539 | | 547 | |
| | 548 | std::string_view getBaseName() const override { return Base->getBaseName(); } |
| | 549 | |
| 540 | void printLeft(OutputBuffer &OB) const override { | 550 | void printLeft(OutputBuffer &OB) const override { |
| 541 | Base->printLeft(OB); | 551 | Base->printLeft(OB); |
| 542 | OB += "[abi:"; | 552 | OB += "[abi:"; |
| ... | @@ -562,12 +572,12 @@ public: | ... | @@ -562,12 +572,12 @@ public: |
| 562 | | 572 | |
| 563 | class ObjCProtoName : public Node { | 573 | class ObjCProtoName : public Node { |
| 564 | const Node *Ty; | 574 | const Node *Ty; |
| 565 | StringView Protocol; | 575 | std::string_view Protocol; |
| 566 | | 576 | |
| 567 | friend class PointerType; | 577 | friend class PointerType; |
| 568 | | 578 | |
| 569 | public: | 579 | public: |
| 570 | ObjCProtoName(const Node *Ty_, StringView Protocol_) | 580 | ObjCProtoName(const Node *Ty_, std::string_view Protocol_) |
| 571 | : Node(KObjCProtoName), Ty(Ty_), Protocol(Protocol_) {} | 581 | : Node(KObjCProtoName), Ty(Ty_), Protocol(Protocol_) {} |
| 572 | | 582 | |
| 573 | template<typename Fn> void match(Fn F) const { F(Ty, Protocol); } | 583 | template<typename Fn> void match(Fn F) const { F(Ty, Protocol); } |
| ... | @@ -944,11 +954,11 @@ public: | ... | @@ -944,11 +954,11 @@ public: |
| 944 | }; | 954 | }; |
| 945 | | 955 | |
| 946 | class SpecialName final : public Node { | 956 | class SpecialName final : public Node { |
| 947 | const StringView Special; | 957 | const std::string_view Special; |
| 948 | const Node *Child; | 958 | const Node *Child; |
| 949 | | 959 | |
| 950 | public: | 960 | public: |
| 951 | SpecialName(StringView Special_, const Node *Child_) | 961 | SpecialName(std::string_view Special_, const Node *Child_) |
| 952 | : Node(KSpecialName), Special(Special_), Child(Child_) {} | 962 | : Node(KSpecialName), Special(Special_), Child(Child_) {} |
| 953 | | 963 | |
| 954 | template<typename Fn> void match(Fn F) const { F(Special, Child); } | 964 | template<typename Fn> void match(Fn F) const { F(Special, Child); } |
| ... | @@ -987,7 +997,7 @@ struct NestedName : Node { | ... | @@ -987,7 +997,7 @@ struct NestedName : Node { |
| 987 | | 997 | |
| 988 | template<typename Fn> void match(Fn F) const { F(Qual, Name); } | 998 | template<typename Fn> void match(Fn F) const { F(Qual, Name); } |
| 989 | | 999 | |
| 990 | StringView getBaseName() const override { return Name->getBaseName(); } | 1000 | std::string_view getBaseName() const override { return Name->getBaseName(); } |
| 991 | | 1001 | |
| 992 | void printLeft(OutputBuffer &OB) const override { | 1002 | void printLeft(OutputBuffer &OB) const override { |
| 993 | Qual->print(OB); | 1003 | Qual->print(OB); |
| ... | @@ -1027,7 +1037,7 @@ struct ModuleEntity : Node { | ... | @@ -1027,7 +1037,7 @@ struct ModuleEntity : Node { |
| 1027 | | 1037 | |
| 1028 | template <typename Fn> void match(Fn F) const { F(Module, Name); } | 1038 | template <typename Fn> void match(Fn F) const { F(Module, Name); } |
| 1029 | | 1039 | |
| 1030 | StringView getBaseName() const override { return Name->getBaseName(); } | 1040 | std::string_view getBaseName() const override { return Name->getBaseName(); } |
| 1031 | | 1041 | |
| 1032 | void printLeft(OutputBuffer &OB) const override { | 1042 | void printLeft(OutputBuffer &OB) const override { |
| 1033 | Name->print(OB); | 1043 | Name->print(OB); |
| ... | @@ -1063,7 +1073,7 @@ public: | ... | @@ -1063,7 +1073,7 @@ public: |
| 1063 | | 1073 | |
| 1064 | template<typename Fn> void match(Fn F) const { F(Qualifier, Name); } | 1074 | template<typename Fn> void match(Fn F) const { F(Qualifier, Name); } |
| 1065 | | 1075 | |
| 1066 | StringView getBaseName() const override { return Name->getBaseName(); } | 1076 | std::string_view getBaseName() const override { return Name->getBaseName(); } |
| 1067 | | 1077 | |
| 1068 | void printLeft(OutputBuffer &OB) const override { | 1078 | void printLeft(OutputBuffer &OB) const override { |
| 1069 | Qualifier->print(OB); | 1079 | Qualifier->print(OB); |
| ... | @@ -1485,7 +1495,7 @@ struct NameWithTemplateArgs : Node { | ... | @@ -1485,7 +1495,7 @@ struct NameWithTemplateArgs : Node { |
| 1485 | | 1495 | |
| 1486 | template<typename Fn> void match(Fn F) const { F(Name, TemplateArgs); } | 1496 | template<typename Fn> void match(Fn F) const { F(Name, TemplateArgs); } |
| 1487 | | 1497 | |
| 1488 | StringView getBaseName() const override { return Name->getBaseName(); } | 1498 | std::string_view getBaseName() const override { return Name->getBaseName(); } |
| 1489 | | 1499 | |
| 1490 | void printLeft(OutputBuffer &OB) const override { | 1500 | void printLeft(OutputBuffer &OB) const override { |
| 1491 | Name->print(OB); | 1501 | Name->print(OB); |
| ... | @@ -1502,7 +1512,7 @@ public: | ... | @@ -1502,7 +1512,7 @@ public: |
| 1502 | | 1512 | |
| 1503 | template<typename Fn> void match(Fn F) const { F(Child); } | 1513 | template<typename Fn> void match(Fn F) const { F(Child); } |
| 1504 | | 1514 | |
| 1505 | StringView getBaseName() const override { return Child->getBaseName(); } | 1515 | std::string_view getBaseName() const override { return Child->getBaseName(); } |
| 1506 | | 1516 | |
| 1507 | void printLeft(OutputBuffer &OB) const override { | 1517 | void printLeft(OutputBuffer &OB) const override { |
| 1508 | OB += "::"; | 1518 | OB += "::"; |
| ... | @@ -1538,20 +1548,20 @@ protected: | ... | @@ -1538,20 +1548,20 @@ protected: |
| 1538 | return unsigned(SSK) >= unsigned(SpecialSubKind::string); | 1548 | return unsigned(SSK) >= unsigned(SpecialSubKind::string); |
| 1539 | } | 1549 | } |
| 1540 | | 1550 | |
| 1541 | StringView getBaseName() const override { | 1551 | std::string_view getBaseName() const override { |
| 1542 | switch (SSK) { | 1552 | switch (SSK) { |
| 1543 | case SpecialSubKind::allocator: | 1553 | case SpecialSubKind::allocator: |
| 1544 | return StringView("allocator"); | 1554 | return {"allocator"}; |
| 1545 | case SpecialSubKind::basic_string: | 1555 | case SpecialSubKind::basic_string: |
| 1546 | return StringView("basic_string"); | 1556 | return {"basic_string"}; |
| 1547 | case SpecialSubKind::string: | 1557 | case SpecialSubKind::string: |
| 1548 | return StringView("basic_string"); | 1558 | return {"basic_string"}; |
| 1549 | case SpecialSubKind::istream: | 1559 | case SpecialSubKind::istream: |
| 1550 | return StringView("basic_istream"); | 1560 | return {"basic_istream"}; |
| 1551 | case SpecialSubKind::ostream: | 1561 | case SpecialSubKind::ostream: |
| 1552 | return StringView("basic_ostream"); | 1562 | return {"basic_ostream"}; |
| 1553 | case SpecialSubKind::iostream: | 1563 | case SpecialSubKind::iostream: |
| 1554 | return StringView("basic_iostream"); | 1564 | return {"basic_iostream"}; |
| 1555 | } | 1565 | } |
| 1556 | DEMANGLE_UNREACHABLE; | 1566 | DEMANGLE_UNREACHABLE; |
| 1557 | } | 1567 | } |
| ... | @@ -1575,12 +1585,12 @@ public: | ... | @@ -1575,12 +1585,12 @@ public: |
| 1575 | | 1585 | |
| 1576 | template<typename Fn> void match(Fn F) const { F(SSK); } | 1586 | template<typename Fn> void match(Fn F) const { F(SSK); } |
| 1577 | | 1587 | |
| 1578 | StringView getBaseName() const override { | 1588 | std::string_view getBaseName() const override { |
| 1579 | auto SV = ExpandedSpecialSubstitution::getBaseName (); | 1589 | std::string_view SV = ExpandedSpecialSubstitution::getBaseName(); |
| 1580 | if (isInstantiation()) { | 1590 | if (isInstantiation()) { |
| 1581 | // The instantiations are typedefs that drop the "basic_" prefix. | 1591 | // The instantiations are typedefs that drop the "basic_" prefix. |
| 1582 | assert(SV.startsWith("basic_")); | 1592 | assert(starts_with(SV, "basic_")); |
| 1583 | SV = SV.dropFront(sizeof("basic_") - 1); | 1593 | SV.remove_prefix(sizeof("basic_") - 1); |
| 1584 | } | 1594 | } |
| 1585 | return SV; | 1595 | return SV; |
| 1586 | } | 1596 | } |
| ... | @@ -1628,10 +1638,11 @@ public: | ... | @@ -1628,10 +1638,11 @@ public: |
| 1628 | }; | 1638 | }; |
| 1629 | | 1639 | |
| 1630 | class UnnamedTypeName : public Node { | 1640 | class UnnamedTypeName : public Node { |
| 1631 | const StringView Count; | 1641 | const std::string_view Count; |
| 1632 | | 1642 | |
| 1633 | public: | 1643 | public: |
| 1634 | UnnamedTypeName(StringView Count_) : Node(KUnnamedTypeName), Count(Count_) {} | 1644 | UnnamedTypeName(std::string_view Count_) |
| | 1645 | : Node(KUnnamedTypeName), Count(Count_) {} |
| 1635 | | 1646 | |
| 1636 | template<typename Fn> void match(Fn F) const { F(Count); } | 1647 | template<typename Fn> void match(Fn F) const { F(Count); } |
| 1637 | | 1648 | |
| ... | @@ -1645,11 +1656,11 @@ public: | ... | @@ -1645,11 +1656,11 @@ public: |
| 1645 | class ClosureTypeName : public Node { | 1656 | class ClosureTypeName : public Node { |
| 1646 | NodeArray TemplateParams; | 1657 | NodeArray TemplateParams; |
| 1647 | NodeArray Params; | 1658 | NodeArray Params; |
| 1648 | StringView Count; | 1659 | std::string_view Count; |
| 1649 | | 1660 | |
| 1650 | public: | 1661 | public: |
| 1651 | ClosureTypeName(NodeArray TemplateParams_, NodeArray Params_, | 1662 | ClosureTypeName(NodeArray TemplateParams_, NodeArray Params_, |
| 1652 | StringView Count_) | 1663 | std::string_view Count_) |
| 1653 | : Node(KClosureTypeName), TemplateParams(TemplateParams_), | 1664 | : Node(KClosureTypeName), TemplateParams(TemplateParams_), |
| 1654 | Params(Params_), Count(Count_) {} | 1665 | Params(Params_), Count(Count_) {} |
| 1655 | | 1666 | |
| ... | @@ -1696,12 +1707,12 @@ public: | ... | @@ -1696,12 +1707,12 @@ public: |
| 1696 | | 1707 | |
| 1697 | class BinaryExpr : public Node { | 1708 | class BinaryExpr : public Node { |
| 1698 | const Node *LHS; | 1709 | const Node *LHS; |
| 1699 | const StringView InfixOperator; | 1710 | const std::string_view InfixOperator; |
| 1700 | const Node *RHS; | 1711 | const Node *RHS; |
| 1701 | | 1712 | |
| 1702 | public: | 1713 | public: |
| 1703 | BinaryExpr(const Node *LHS_, StringView InfixOperator_, const Node *RHS_, | 1714 | BinaryExpr(const Node *LHS_, std::string_view InfixOperator_, |
| 1704 | Prec Prec_) | 1715 | const Node *RHS_, Prec Prec_) |
| 1705 | : Node(KBinaryExpr, Prec_), LHS(LHS_), InfixOperator(InfixOperator_), | 1716 | : Node(KBinaryExpr, Prec_), LHS(LHS_), InfixOperator(InfixOperator_), |
| 1706 | RHS(RHS_) {} | 1717 | RHS(RHS_) {} |
| 1707 | | 1718 | |
| ... | @@ -1750,10 +1761,10 @@ public: | ... | @@ -1750,10 +1761,10 @@ public: |
| 1750 | | 1761 | |
| 1751 | class PostfixExpr : public Node { | 1762 | class PostfixExpr : public Node { |
| 1752 | const Node *Child; | 1763 | const Node *Child; |
| 1753 | const StringView Operator; | 1764 | const std::string_view Operator; |
| 1754 | | 1765 | |
| 1755 | public: | 1766 | public: |
| 1756 | PostfixExpr(const Node *Child_, StringView Operator_, Prec Prec_) | 1767 | PostfixExpr(const Node *Child_, std::string_view Operator_, Prec Prec_) |
| 1757 | : Node(KPostfixExpr, Prec_), Child(Child_), Operator(Operator_) {} | 1768 | : Node(KPostfixExpr, Prec_), Child(Child_), Operator(Operator_) {} |
| 1758 | | 1769 | |
| 1759 | template <typename Fn> void match(Fn F) const { | 1770 | template <typename Fn> void match(Fn F) const { |
| ... | @@ -1791,11 +1802,12 @@ public: | ... | @@ -1791,11 +1802,12 @@ public: |
| 1791 | | 1802 | |
| 1792 | class MemberExpr : public Node { | 1803 | class MemberExpr : public Node { |
| 1793 | const Node *LHS; | 1804 | const Node *LHS; |
| 1794 | const StringView Kind; | 1805 | const std::string_view Kind; |
| 1795 | const Node *RHS; | 1806 | const Node *RHS; |
| 1796 | | 1807 | |
| 1797 | public: | 1808 | public: |
| 1798 | MemberExpr(const Node *LHS_, StringView Kind_, const Node *RHS_, Prec Prec_) | 1809 | MemberExpr(const Node *LHS_, std::string_view Kind_, const Node *RHS_, |
| | 1810 | Prec Prec_) |
| 1799 | : Node(KMemberExpr, Prec_), LHS(LHS_), Kind(Kind_), RHS(RHS_) {} | 1811 | : Node(KMemberExpr, Prec_), LHS(LHS_), Kind(Kind_), RHS(RHS_) {} |
| 1800 | | 1812 | |
| 1801 | template <typename Fn> void match(Fn F) const { | 1813 | template <typename Fn> void match(Fn F) const { |
| ... | @@ -1812,13 +1824,14 @@ public: | ... | @@ -1812,13 +1824,14 @@ public: |
| 1812 | class SubobjectExpr : public Node { | 1824 | class SubobjectExpr : public Node { |
| 1813 | const Node *Type; | 1825 | const Node *Type; |
| 1814 | const Node *SubExpr; | 1826 | const Node *SubExpr; |
| 1815 | StringView Offset; | 1827 | std::string_view Offset; |
| 1816 | NodeArray UnionSelectors; | 1828 | NodeArray UnionSelectors; |
| 1817 | bool OnePastTheEnd; | 1829 | bool OnePastTheEnd; |
| 1818 | | 1830 | |
| 1819 | public: | 1831 | public: |
| 1820 | SubobjectExpr(const Node *Type_, const Node *SubExpr_, StringView Offset_, | 1832 | SubobjectExpr(const Node *Type_, const Node *SubExpr_, |
| 1821 | NodeArray UnionSelectors_, bool OnePastTheEnd_) | 1833 | std::string_view Offset_, NodeArray UnionSelectors_, |
| | 1834 | bool OnePastTheEnd_) |
| 1822 | : Node(KSubobjectExpr), Type(Type_), SubExpr(SubExpr_), Offset(Offset_), | 1835 | : Node(KSubobjectExpr), Type(Type_), SubExpr(SubExpr_), Offset(Offset_), |
| 1823 | UnionSelectors(UnionSelectors_), OnePastTheEnd(OnePastTheEnd_) {} | 1836 | UnionSelectors(UnionSelectors_), OnePastTheEnd(OnePastTheEnd_) {} |
| 1824 | | 1837 | |
| ... | @@ -1835,7 +1848,7 @@ public: | ... | @@ -1835,7 +1848,7 @@ public: |
| 1835 | OB += "0"; | 1848 | OB += "0"; |
| 1836 | } else if (Offset[0] == 'n') { | 1849 | } else if (Offset[0] == 'n') { |
| 1837 | OB += "-"; | 1850 | OB += "-"; |
| 1838 | OB += Offset.dropFront(); | 1851 | OB += std::string_view(Offset.data() + 1, Offset.size() - 1); |
| 1839 | } else { | 1852 | } else { |
| 1840 | OB += Offset; | 1853 | OB += Offset; |
| 1841 | } | 1854 | } |
| ... | @@ -1844,12 +1857,12 @@ public: | ... | @@ -1844,12 +1857,12 @@ public: |
| 1844 | }; | 1857 | }; |
| 1845 | | 1858 | |
| 1846 | class EnclosingExpr : public Node { | 1859 | class EnclosingExpr : public Node { |
| 1847 | const StringView Prefix; | 1860 | const std::string_view Prefix; |
| 1848 | const Node *Infix; | 1861 | const Node *Infix; |
| 1849 | const StringView Postfix; | 1862 | const std::string_view Postfix; |
| 1850 | | 1863 | |
| 1851 | public: | 1864 | public: |
| 1852 | EnclosingExpr(StringView Prefix_, const Node *Infix_, | 1865 | EnclosingExpr(std::string_view Prefix_, const Node *Infix_, |
| 1853 | Prec Prec_ = Prec::Primary) | 1866 | Prec Prec_ = Prec::Primary) |
| 1854 | : Node(KEnclosingExpr, Prec_), Prefix(Prefix_), Infix(Infix_) {} | 1867 | : Node(KEnclosingExpr, Prec_), Prefix(Prefix_), Infix(Infix_) {} |
| 1855 | | 1868 | |
| ... | @@ -1868,12 +1881,13 @@ public: | ... | @@ -1868,12 +1881,13 @@ public: |
| 1868 | | 1881 | |
| 1869 | class CastExpr : public Node { | 1882 | class CastExpr : public Node { |
| 1870 | // cast_kind<to>(from) | 1883 | // cast_kind<to>(from) |
| 1871 | const StringView CastKind; | 1884 | const std::string_view CastKind; |
| 1872 | const Node *To; | 1885 | const Node *To; |
| 1873 | const Node *From; | 1886 | const Node *From; |
| 1874 | | 1887 | |
| 1875 | public: | 1888 | public: |
| 1876 | CastExpr(StringView CastKind_, const Node *To_, const Node *From_, Prec Prec_) | 1889 | CastExpr(std::string_view CastKind_, const Node *To_, const Node *From_, |
| | 1890 | Prec Prec_) |
| 1877 | : Node(KCastExpr, Prec_), CastKind(CastKind_), To(To_), From(From_) {} | 1891 | : Node(KCastExpr, Prec_), CastKind(CastKind_), To(To_), From(From_) {} |
| 1878 | | 1892 | |
| 1879 | template <typename Fn> void match(Fn F) const { | 1893 | template <typename Fn> void match(Fn F) const { |
| ... | @@ -1996,11 +2010,11 @@ public: | ... | @@ -1996,11 +2010,11 @@ public: |
| 1996 | }; | 2010 | }; |
| 1997 | | 2011 | |
| 1998 | class PrefixExpr : public Node { | 2012 | class PrefixExpr : public Node { |
| 1999 | StringView Prefix; | 2013 | std::string_view Prefix; |
| 2000 | Node *Child; | 2014 | Node *Child; |
| 2001 | | 2015 | |
| 2002 | public: | 2016 | public: |
| 2003 | PrefixExpr(StringView Prefix_, Node *Child_, Prec Prec_) | 2017 | PrefixExpr(std::string_view Prefix_, Node *Child_, Prec Prec_) |
| 2004 | : Node(KPrefixExpr, Prec_), Prefix(Prefix_), Child(Child_) {} | 2018 | : Node(KPrefixExpr, Prec_), Prefix(Prefix_), Child(Child_) {} |
| 2005 | | 2019 | |
| 2006 | template <typename Fn> void match(Fn F) const { | 2020 | template <typename Fn> void match(Fn F) const { |
| ... | @@ -2014,10 +2028,11 @@ public: | ... | @@ -2014,10 +2028,11 @@ public: |
| 2014 | }; | 2028 | }; |
| 2015 | | 2029 | |
| 2016 | class FunctionParam : public Node { | 2030 | class FunctionParam : public Node { |
| 2017 | StringView Number; | 2031 | std::string_view Number; |
| 2018 | | 2032 | |
| 2019 | public: | 2033 | public: |
| 2020 | FunctionParam(StringView Number_) : Node(KFunctionParam), Number(Number_) {} | 2034 | FunctionParam(std::string_view Number_) |
| | 2035 | : Node(KFunctionParam), Number(Number_) {} |
| 2021 | | 2036 | |
| 2022 | template<typename Fn> void match(Fn F) const { F(Number); } | 2037 | template<typename Fn> void match(Fn F) const { F(Number); } |
| 2023 | | 2038 | |
| ... | @@ -2052,11 +2067,11 @@ public: | ... | @@ -2052,11 +2067,11 @@ public: |
| 2052 | class PointerToMemberConversionExpr : public Node { | 2067 | class PointerToMemberConversionExpr : public Node { |
| 2053 | const Node *Type; | 2068 | const Node *Type; |
| 2054 | const Node *SubExpr; | 2069 | const Node *SubExpr; |
| 2055 | StringView Offset; | 2070 | std::string_view Offset; |
| 2056 | | 2071 | |
| 2057 | public: | 2072 | public: |
| 2058 | PointerToMemberConversionExpr(const Node *Type_, const Node *SubExpr_, | 2073 | PointerToMemberConversionExpr(const Node *Type_, const Node *SubExpr_, |
| 2059 | StringView Offset_, Prec Prec_) | 2074 | std::string_view Offset_, Prec Prec_) |
| 2060 | : Node(KPointerToMemberConversionExpr, Prec_), Type(Type_), | 2075 | : Node(KPointerToMemberConversionExpr, Prec_), Type(Type_), |
| 2061 | SubExpr(SubExpr_), Offset(Offset_) {} | 2076 | SubExpr(SubExpr_), Offset(Offset_) {} |
| 2062 | | 2077 | |
| ... | @@ -2141,11 +2156,11 @@ public: | ... | @@ -2141,11 +2156,11 @@ public: |
| 2141 | | 2156 | |
| 2142 | class FoldExpr : public Node { | 2157 | class FoldExpr : public Node { |
| 2143 | const Node *Pack, *Init; | 2158 | const Node *Pack, *Init; |
| 2144 | StringView OperatorName; | 2159 | std::string_view OperatorName; |
| 2145 | bool IsLeftFold; | 2160 | bool IsLeftFold; |
| 2146 | | 2161 | |
| 2147 | public: | 2162 | public: |
| 2148 | FoldExpr(bool IsLeftFold_, StringView OperatorName_, const Node *Pack_, | 2163 | FoldExpr(bool IsLeftFold_, std::string_view OperatorName_, const Node *Pack_, |
| 2149 | const Node *Init_) | 2164 | const Node *Init_) |
| 2150 | : Node(KFoldExpr), Pack(Pack_), Init(Init_), OperatorName(OperatorName_), | 2165 | : Node(KFoldExpr), Pack(Pack_), Init(Init_), OperatorName(OperatorName_), |
| 2151 | IsLeftFold(IsLeftFold_) {} | 2166 | IsLeftFold(IsLeftFold_) {} |
| ... | @@ -2209,7 +2224,7 @@ public: | ... | @@ -2209,7 +2224,7 @@ public: |
| 2209 | template<typename Fn> void match(Fn F) const { F(Value); } | 2224 | template<typename Fn> void match(Fn F) const { F(Value); } |
| 2210 | | 2225 | |
| 2211 | void printLeft(OutputBuffer &OB) const override { | 2226 | void printLeft(OutputBuffer &OB) const override { |
| 2212 | OB += Value ? StringView("true") : StringView("false"); | 2227 | OB += Value ? std::string_view("true") : std::string_view("false"); |
| 2213 | } | 2228 | } |
| 2214 | }; | 2229 | }; |
| 2215 | | 2230 | |
| ... | @@ -2247,10 +2262,10 @@ public: | ... | @@ -2247,10 +2262,10 @@ public: |
| 2247 | class EnumLiteral : public Node { | 2262 | class EnumLiteral : public Node { |
| 2248 | // ty(integer) | 2263 | // ty(integer) |
| 2249 | const Node *Ty; | 2264 | const Node *Ty; |
| 2250 | StringView Integer; | 2265 | std::string_view Integer; |
| 2251 | | 2266 | |
| 2252 | public: | 2267 | public: |
| 2253 | EnumLiteral(const Node *Ty_, StringView Integer_) | 2268 | EnumLiteral(const Node *Ty_, std::string_view Integer_) |
| 2254 | : Node(KEnumLiteral), Ty(Ty_), Integer(Integer_) {} | 2269 | : Node(KEnumLiteral), Ty(Ty_), Integer(Integer_) {} |
| 2255 | | 2270 | |
| 2256 | template<typename Fn> void match(Fn F) const { F(Ty, Integer); } | 2271 | template<typename Fn> void match(Fn F) const { F(Ty, Integer); } |
| ... | @@ -2261,18 +2276,18 @@ public: | ... | @@ -2261,18 +2276,18 @@ public: |
| 2261 | OB.printClose(); | 2276 | OB.printClose(); |
| 2262 | | 2277 | |
| 2263 | if (Integer[0] == 'n') | 2278 | if (Integer[0] == 'n') |
| 2264 | OB << "-" << Integer.dropFront(1); | 2279 | OB << '-' << std::string_view(Integer.data() + 1, Integer.size() - 1); |
| 2265 | else | 2280 | else |
| 2266 | OB << Integer; | 2281 | OB << Integer; |
| 2267 | } | 2282 | } |
| 2268 | }; | 2283 | }; |
| 2269 | | 2284 | |
| 2270 | class IntegerLiteral : public Node { | 2285 | class IntegerLiteral : public Node { |
| 2271 | StringView Type; | 2286 | std::string_view Type; |
| 2272 | StringView Value; | 2287 | std::string_view Value; |
| 2273 | | 2288 | |
| 2274 | public: | 2289 | public: |
| 2275 | IntegerLiteral(StringView Type_, StringView Value_) | 2290 | IntegerLiteral(std::string_view Type_, std::string_view Value_) |
| 2276 | : Node(KIntegerLiteral), Type(Type_), Value(Value_) {} | 2291 | : Node(KIntegerLiteral), Type(Type_), Value(Value_) {} |
| 2277 | | 2292 | |
| 2278 | template<typename Fn> void match(Fn F) const { F(Type, Value); } | 2293 | template<typename Fn> void match(Fn F) const { F(Type, Value); } |
| ... | @@ -2284,10 +2299,9 @@ public: | ... | @@ -2284,10 +2299,9 @@ public: |
| 2284 | OB.printClose(); | 2299 | OB.printClose(); |
| 2285 | } | 2300 | } |
| 2286 | | 2301 | |
| 2287 | if (Value[0] == 'n') { | 2302 | if (Value[0] == 'n') |
| 2288 | OB += '-'; | 2303 | OB << '-' << std::string_view(Value.data() + 1, Value.size() - 1); |
| 2289 | OB += Value.dropFront(1); | 2304 | else |
| 2290 | } else | | |
| 2291 | OB += Value; | 2305 | OB += Value; |
| 2292 | | 2306 | |
| 2293 | if (Type.size() <= 3) | 2307 | if (Type.size() <= 3) |
| ... | @@ -2310,29 +2324,26 @@ constexpr Node::Kind getFloatLiteralKind(long double *) { | ... | @@ -2310,29 +2324,26 @@ constexpr Node::Kind getFloatLiteralKind(long double *) { |
| 2310 | } | 2324 | } |
| 2311 | | 2325 | |
| 2312 | template <class Float> class FloatLiteralImpl : public Node { | 2326 | template <class Float> class FloatLiteralImpl : public Node { |
| 2313 | const StringView Contents; | 2327 | const std::string_view Contents; |
| 2314 | | 2328 | |
| 2315 | static constexpr Kind KindForClass = | 2329 | static constexpr Kind KindForClass = |
| 2316 | float_literal_impl::getFloatLiteralKind((Float *)nullptr); | 2330 | float_literal_impl::getFloatLiteralKind((Float *)nullptr); |
| 2317 | | 2331 | |
| 2318 | public: | 2332 | public: |
| 2319 | FloatLiteralImpl(StringView Contents_) | 2333 | FloatLiteralImpl(std::string_view Contents_) |
| 2320 | : Node(KindForClass), Contents(Contents_) {} | 2334 | : Node(KindForClass), Contents(Contents_) {} |
| 2321 | | 2335 | |
| 2322 | template<typename Fn> void match(Fn F) const { F(Contents); } | 2336 | template<typename Fn> void match(Fn F) const { F(Contents); } |
| 2323 | | 2337 | |
| 2324 | void printLeft(OutputBuffer &OB) const override { | 2338 | void printLeft(OutputBuffer &OB) const override { |
| 2325 | const char *first = Contents.begin(); | | |
| 2326 | const char *last = Contents.end() + 1; | | |
| 2327 | | | |
| 2328 | const size_t N = FloatData<Float>::mangled_size; | 2339 | const size_t N = FloatData<Float>::mangled_size; |
| 2329 | if (static_cast<std::size_t>(last - first) > N) { | 2340 | if (Contents.size() >= N) { |
| 2330 | last = first + N; | | |
| 2331 | union { | 2341 | union { |
| 2332 | Float value; | 2342 | Float value; |
| 2333 | char buf[sizeof(Float)]; | 2343 | char buf[sizeof(Float)]; |
| 2334 | }; | 2344 | }; |
| 2335 | const char *t = first; | 2345 | const char *t = Contents.data(); |
| | 2346 | const char *last = t + N; |
| 2336 | char *e = buf; | 2347 | char *e = buf; |
| 2337 | for (; t != last; ++t, ++e) { | 2348 | for (; t != last; ++t, ++e) { |
| 2338 | unsigned d1 = isdigit(*t) ? static_cast<unsigned>(*t - '0') | 2349 | unsigned d1 = isdigit(*t) ? static_cast<unsigned>(*t - '0') |
| ... | @@ -2347,7 +2358,7 @@ public: | ... | @@ -2347,7 +2358,7 @@ public: |
| 2347 | #endif | 2358 | #endif |
| 2348 | char num[FloatData<Float>::max_demangled_size] = {0}; | 2359 | char num[FloatData<Float>::max_demangled_size] = {0}; |
| 2349 | int n = snprintf(num, sizeof(num), FloatData<Float>::spec, value); | 2360 | int n = snprintf(num, sizeof(num), FloatData<Float>::spec, value); |
| 2350 | OB += StringView(num, num + n); | 2361 | OB += std::string_view(num, n); |
| 2351 | } | 2362 | } |
| 2352 | } | 2363 | } |
| 2353 | }; | 2364 | }; |
| ... | @@ -2474,8 +2485,8 @@ template <typename Derived, typename Alloc> struct AbstractManglingParser { | ... | @@ -2474,8 +2485,8 @@ template <typename Derived, typename Alloc> struct AbstractManglingParser { |
| 2474 | return res; | 2485 | return res; |
| 2475 | } | 2486 | } |
| 2476 | | 2487 | |
| 2477 | bool consumeIf(StringView S) { | 2488 | bool consumeIf(std::string_view S) { |
| 2478 | if (StringView(First, Last).startsWith(S)) { | 2489 | if (starts_with(std::string_view(First, Last - First), S)) { |
| 2479 | First += S.size(); | 2490 | First += S.size(); |
| 2480 | return true; | 2491 | return true; |
| 2481 | } | 2492 | } |
| ... | @@ -2500,10 +2511,10 @@ template <typename Derived, typename Alloc> struct AbstractManglingParser { | ... | @@ -2500,10 +2511,10 @@ template <typename Derived, typename Alloc> struct AbstractManglingParser { |
| 2500 | | 2511 | |
| 2501 | size_t numLeft() const { return static_cast<size_t>(Last - First); } | 2512 | size_t numLeft() const { return static_cast<size_t>(Last - First); } |
| 2502 | | 2513 | |
| 2503 | StringView parseNumber(bool AllowNegative = false); | 2514 | std::string_view parseNumber(bool AllowNegative = false); |
| 2504 | Qualifiers parseCVQualifiers(); | 2515 | Qualifiers parseCVQualifiers(); |
| 2505 | bool parsePositiveInteger(size_t *Out); | 2516 | bool parsePositiveInteger(size_t *Out); |
| 2506 | StringView parseBareSourceName(); | 2517 | std::string_view parseBareSourceName(); |
| 2507 | | 2518 | |
| 2508 | bool parseSeqId(size_t *Out); | 2519 | bool parseSeqId(size_t *Out); |
| 2509 | Node *parseSubstitution(); | 2520 | Node *parseSubstitution(); |
| ... | @@ -2514,9 +2525,9 @@ template <typename Derived, typename Alloc> struct AbstractManglingParser { | ... | @@ -2514,9 +2525,9 @@ template <typename Derived, typename Alloc> struct AbstractManglingParser { |
| 2514 | | 2525 | |
| 2515 | /// Parse the <expr> production. | 2526 | /// Parse the <expr> production. |
| 2516 | Node *parseExpr(); | 2527 | Node *parseExpr(); |
| 2517 | Node *parsePrefixExpr(StringView Kind, Node::Prec Prec); | 2528 | Node *parsePrefixExpr(std::string_view Kind, Node::Prec Prec); |
| 2518 | Node *parseBinaryExpr(StringView Kind, Node::Prec Prec); | 2529 | Node *parseBinaryExpr(std::string_view Kind, Node::Prec Prec); |
| 2519 | Node *parseIntegerLiteral(StringView Lit); | 2530 | Node *parseIntegerLiteral(std::string_view Lit); |
| 2520 | Node *parseExprPrimary(); | 2531 | Node *parseExprPrimary(); |
| 2521 | template <class Float> Node *parseFloatingLiteral(); | 2532 | template <class Float> Node *parseFloatingLiteral(); |
| 2522 | Node *parseFunctionParam(); | 2533 | Node *parseFunctionParam(); |
| ... | @@ -2624,17 +2635,18 @@ template <typename Derived, typename Alloc> struct AbstractManglingParser { | ... | @@ -2624,17 +2635,18 @@ template <typename Derived, typename Alloc> struct AbstractManglingParser { |
| 2624 | bool operator!=(const char *Peek) const { return !this->operator==(Peek); } | 2635 | bool operator!=(const char *Peek) const { return !this->operator==(Peek); } |
| 2625 | | 2636 | |
| 2626 | public: | 2637 | public: |
| 2627 | StringView getSymbol() const { | 2638 | std::string_view getSymbol() const { |
| 2628 | StringView Res = Name; | 2639 | std::string_view Res = Name; |
| 2629 | if (Kind < Unnameable) { | 2640 | if (Kind < Unnameable) { |
| 2630 | assert(Res.startsWith("operator") && | 2641 | assert(starts_with(Res, "operator") && |
| 2631 | "operator name does not start with 'operator'"); | 2642 | "operator name does not start with 'operator'"); |
| 2632 | Res = Res.dropFront(sizeof("operator") - 1); | 2643 | Res.remove_prefix(sizeof("operator") - 1); |
| 2633 | Res.consumeFront(' '); | 2644 | if (starts_with(Res, ' ')) |
| | 2645 | Res.remove_prefix(1); |
| 2634 | } | 2646 | } |
| 2635 | return Res; | 2647 | return Res; |
| 2636 | } | 2648 | } |
| 2637 | StringView getName() const { return Name; } | 2649 | std::string_view getName() const { return Name; } |
| 2638 | OIKind getKind() const { return Kind; } | 2650 | OIKind getKind() const { return Kind; } |
| 2639 | bool getFlag() const { return Flag; } | 2651 | bool getFlag() const { return Flag; } |
| 2640 | Node::Prec getPrecedence() const { return Prec; } | 2652 | Node::Prec getPrecedence() const { return Prec; } |
| ... | @@ -2854,7 +2866,7 @@ AbstractManglingParser<Derived, Alloc>::parseUnnamedTypeName(NameState *State) { | ... | @@ -2854,7 +2866,7 @@ AbstractManglingParser<Derived, Alloc>::parseUnnamedTypeName(NameState *State) { |
| 2854 | TemplateParams.clear(); | 2866 | TemplateParams.clear(); |
| 2855 | | 2867 | |
| 2856 | if (consumeIf("Ut")) { | 2868 | if (consumeIf("Ut")) { |
| 2857 | StringView Count = parseNumber(); | 2869 | std::string_view Count = parseNumber(); |
| 2858 | if (!consumeIf('_')) | 2870 | if (!consumeIf('_')) |
| 2859 | return nullptr; | 2871 | return nullptr; |
| 2860 | return make<UnnamedTypeName>(Count); | 2872 | return make<UnnamedTypeName>(Count); |
| ... | @@ -2866,7 +2878,7 @@ AbstractManglingParser<Derived, Alloc>::parseUnnamedTypeName(NameState *State) { | ... | @@ -2866,7 +2878,7 @@ AbstractManglingParser<Derived, Alloc>::parseUnnamedTypeName(NameState *State) { |
| 2866 | | 2878 | |
| 2867 | size_t ParamsBegin = Names.size(); | 2879 | size_t ParamsBegin = Names.size(); |
| 2868 | while (look() == 'T' && | 2880 | while (look() == 'T' && |
| 2869 | StringView("yptn").find(look(1)) != StringView::npos) { | 2881 | std::string_view("yptn").find(look(1)) != std::string_view::npos) { |
| 2870 | Node *T = parseTemplateParamDecl(); | 2882 | Node *T = parseTemplateParamDecl(); |
| 2871 | if (!T) | 2883 | if (!T) |
| 2872 | return nullptr; | 2884 | return nullptr; |
| ... | @@ -2909,7 +2921,7 @@ AbstractManglingParser<Derived, Alloc>::parseUnnamedTypeName(NameState *State) { | ... | @@ -2909,7 +2921,7 @@ AbstractManglingParser<Derived, Alloc>::parseUnnamedTypeName(NameState *State) { |
| 2909 | } | 2921 | } |
| 2910 | NodeArray Params = popTrailingNodeArray(ParamsBegin); | 2922 | NodeArray Params = popTrailingNodeArray(ParamsBegin); |
| 2911 | | 2923 | |
| 2912 | StringView Count = parseNumber(); | 2924 | std::string_view Count = parseNumber(); |
| 2913 | if (!consumeIf('_')) | 2925 | if (!consumeIf('_')) |
| 2914 | return nullptr; | 2926 | return nullptr; |
| 2915 | return make<ClosureTypeName>(TempParams, Params, Count); | 2927 | return make<ClosureTypeName>(TempParams, Params, Count); |
| ... | @@ -2931,9 +2943,9 @@ Node *AbstractManglingParser<Derived, Alloc>::parseSourceName(NameState *) { | ... | @@ -2931,9 +2943,9 @@ Node *AbstractManglingParser<Derived, Alloc>::parseSourceName(NameState *) { |
| 2931 | return nullptr; | 2943 | return nullptr; |
| 2932 | if (numLeft() < Length || Length == 0) | 2944 | if (numLeft() < Length || Length == 0) |
| 2933 | return nullptr; | 2945 | return nullptr; |
| 2934 | StringView Name(First, First + Length); | 2946 | std::string_view Name(First, Length); |
| 2935 | First += Length; | 2947 | First += Length; |
| 2936 | if (Name.startsWith("_GLOBAL__N")) | 2948 | if (starts_with(Name, "_GLOBAL__N")) |
| 2937 | return make<NameType>("(anonymous namespace)"); | 2949 | return make<NameType>("(anonymous namespace)"); |
| 2938 | return make<NameType>(Name); | 2950 | return make<NameType>(Name); |
| 2939 | } | 2951 | } |
| ... | @@ -3447,7 +3459,7 @@ Node *AbstractManglingParser<Derived, Alloc>::parseUnresolvedName(bool Global) { | ... | @@ -3447,7 +3459,7 @@ Node *AbstractManglingParser<Derived, Alloc>::parseUnresolvedName(bool Global) { |
| 3447 | template <typename Derived, typename Alloc> | 3459 | template <typename Derived, typename Alloc> |
| 3448 | Node *AbstractManglingParser<Derived, Alloc>::parseAbiTags(Node *N) { | 3460 | Node *AbstractManglingParser<Derived, Alloc>::parseAbiTags(Node *N) { |
| 3449 | while (consumeIf('B')) { | 3461 | while (consumeIf('B')) { |
| 3450 | StringView SN = parseBareSourceName(); | 3462 | std::string_view SN = parseBareSourceName(); |
| 3451 | if (SN.empty()) | 3463 | if (SN.empty()) |
| 3452 | return nullptr; | 3464 | return nullptr; |
| 3453 | N = make<AbiTagAttr>(N, SN); | 3465 | N = make<AbiTagAttr>(N, SN); |
| ... | @@ -3459,16 +3471,16 @@ Node *AbstractManglingParser<Derived, Alloc>::parseAbiTags(Node *N) { | ... | @@ -3459,16 +3471,16 @@ Node *AbstractManglingParser<Derived, Alloc>::parseAbiTags(Node *N) { |
| 3459 | | 3471 | |
| 3460 | // <number> ::= [n] <non-negative decimal integer> | 3472 | // <number> ::= [n] <non-negative decimal integer> |
| 3461 | template <typename Alloc, typename Derived> | 3473 | template <typename Alloc, typename Derived> |
| 3462 | StringView | 3474 | std::string_view |
| 3463 | AbstractManglingParser<Alloc, Derived>::parseNumber(bool AllowNegative) { | 3475 | AbstractManglingParser<Alloc, Derived>::parseNumber(bool AllowNegative) { |
| 3464 | const char *Tmp = First; | 3476 | const char *Tmp = First; |
| 3465 | if (AllowNegative) | 3477 | if (AllowNegative) |
| 3466 | consumeIf('n'); | 3478 | consumeIf('n'); |
| 3467 | if (numLeft() == 0 || !std::isdigit(*First)) | 3479 | if (numLeft() == 0 || !std::isdigit(*First)) |
| 3468 | return StringView(); | 3480 | return std::string_view(); |
| 3469 | while (numLeft() != 0 && std::isdigit(*First)) | 3481 | while (numLeft() != 0 && std::isdigit(*First)) |
| 3470 | ++First; | 3482 | ++First; |
| 3471 | return StringView(Tmp, First); | 3483 | return std::string_view(Tmp, First - Tmp); |
| 3472 | } | 3484 | } |
| 3473 | | 3485 | |
| 3474 | // <positive length number> ::= [0-9]* | 3486 | // <positive length number> ::= [0-9]* |
| ... | @@ -3485,11 +3497,11 @@ bool AbstractManglingParser<Alloc, Derived>::parsePositiveInteger(size_t *Out) { | ... | @@ -3485,11 +3497,11 @@ bool AbstractManglingParser<Alloc, Derived>::parsePositiveInteger(size_t *Out) { |
| 3485 | } | 3497 | } |
| 3486 | | 3498 | |
| 3487 | template <typename Alloc, typename Derived> | 3499 | template <typename Alloc, typename Derived> |
| 3488 | StringView AbstractManglingParser<Alloc, Derived>::parseBareSourceName() { | 3500 | std::string_view AbstractManglingParser<Alloc, Derived>::parseBareSourceName() { |
| 3489 | size_t Int = 0; | 3501 | size_t Int = 0; |
| 3490 | if (parsePositiveInteger(&Int) || numLeft() < Int) | 3502 | if (parsePositiveInteger(&Int) || numLeft() < Int) |
| 3491 | return StringView(); | 3503 | return {}; |
| 3492 | StringView R(First, First + Int); | 3504 | std::string_view R(First, Int); |
| 3493 | First += Int; | 3505 | First += Int; |
| 3494 | return R; | 3506 | return R; |
| 3495 | } | 3507 | } |
| ... | @@ -3673,7 +3685,7 @@ Node *AbstractManglingParser<Derived, Alloc>::parsePointerToMemberType() { | ... | @@ -3673,7 +3685,7 @@ Node *AbstractManglingParser<Derived, Alloc>::parsePointerToMemberType() { |
| 3673 | // ::= Te <name> # dependent elaborated type specifier using 'enum' | 3685 | // ::= Te <name> # dependent elaborated type specifier using 'enum' |
| 3674 | template <typename Derived, typename Alloc> | 3686 | template <typename Derived, typename Alloc> |
| 3675 | Node *AbstractManglingParser<Derived, Alloc>::parseClassEnumType() { | 3687 | Node *AbstractManglingParser<Derived, Alloc>::parseClassEnumType() { |
| 3676 | StringView ElabSpef; | 3688 | std::string_view ElabSpef; |
| 3677 | if (consumeIf("Ts")) | 3689 | if (consumeIf("Ts")) |
| 3678 | ElabSpef = "struct"; | 3690 | ElabSpef = "struct"; |
| 3679 | else if (consumeIf("Tu")) | 3691 | else if (consumeIf("Tu")) |
| ... | @@ -3697,17 +3709,18 @@ Node *AbstractManglingParser<Derived, Alloc>::parseClassEnumType() { | ... | @@ -3697,17 +3709,18 @@ Node *AbstractManglingParser<Derived, Alloc>::parseClassEnumType() { |
| 3697 | template <typename Derived, typename Alloc> | 3709 | template <typename Derived, typename Alloc> |
| 3698 | Node *AbstractManglingParser<Derived, Alloc>::parseQualifiedType() { | 3710 | Node *AbstractManglingParser<Derived, Alloc>::parseQualifiedType() { |
| 3699 | if (consumeIf('U')) { | 3711 | if (consumeIf('U')) { |
| 3700 | StringView Qual = parseBareSourceName(); | 3712 | std::string_view Qual = parseBareSourceName(); |
| 3701 | if (Qual.empty()) | 3713 | if (Qual.empty()) |
| 3702 | return nullptr; | 3714 | return nullptr; |
| 3703 | | 3715 | |
| 3704 | // extension ::= U <objc-name> <objc-type> # objc-type<identifier> | 3716 | // extension ::= U <objc-name> <objc-type> # objc-type<identifier> |
| 3705 | if (Qual.startsWith("objcproto")) { | 3717 | if (starts_with(Qual, "objcproto")) { |
| 3706 | StringView ProtoSourceName = Qual.dropFront(std::strlen("objcproto")); | 3718 | constexpr size_t Len = sizeof("objcproto") - 1; |
| 3707 | StringView Proto; | 3719 | std::string_view ProtoSourceName(Qual.data() + Len, Qual.size() - Len); |
| | 3720 | std::string_view Proto; |
| 3708 | { | 3721 | { |
| 3709 | ScopedOverride<const char *> SaveFirst(First, ProtoSourceName.begin()), | 3722 | ScopedOverride<const char *> SaveFirst(First, ProtoSourceName.data()), |
| 3710 | SaveLast(Last, ProtoSourceName.end()); | 3723 | SaveLast(Last, &*ProtoSourceName.rbegin() + 1); |
| 3711 | Proto = parseBareSourceName(); | 3724 | Proto = parseBareSourceName(); |
| 3712 | } | 3725 | } |
| 3713 | if (Proto.empty()) | 3726 | if (Proto.empty()) |
| ... | @@ -3875,7 +3888,7 @@ Node *AbstractManglingParser<Derived, Alloc>::parseType() { | ... | @@ -3875,7 +3888,7 @@ Node *AbstractManglingParser<Derived, Alloc>::parseType() { |
| 3875 | // <builtin-type> ::= u <source-name> # vendor extended type | 3888 | // <builtin-type> ::= u <source-name> # vendor extended type |
| 3876 | case 'u': { | 3889 | case 'u': { |
| 3877 | ++First; | 3890 | ++First; |
| 3878 | StringView Res = parseBareSourceName(); | 3891 | std::string_view Res = parseBareSourceName(); |
| 3879 | if (Res.empty()) | 3892 | if (Res.empty()) |
| 3880 | return nullptr; | 3893 | return nullptr; |
| 3881 | // Typically, <builtin-type>s are not considered substitution candidates, | 3894 | // Typically, <builtin-type>s are not considered substitution candidates, |
| ... | @@ -4123,8 +4136,9 @@ Node *AbstractManglingParser<Derived, Alloc>::parseType() { | ... | @@ -4123,8 +4136,9 @@ Node *AbstractManglingParser<Derived, Alloc>::parseType() { |
| 4123 | } | 4136 | } |
| 4124 | | 4137 | |
| 4125 | template <typename Derived, typename Alloc> | 4138 | template <typename Derived, typename Alloc> |
| 4126 | Node *AbstractManglingParser<Derived, Alloc>::parsePrefixExpr(StringView Kind, | 4139 | Node * |
| 4127 | Node::Prec Prec) { | 4140 | AbstractManglingParser<Derived, Alloc>::parsePrefixExpr(std::string_view Kind, |
| | 4141 | Node::Prec Prec) { |
| 4128 | Node *E = getDerived().parseExpr(); | 4142 | Node *E = getDerived().parseExpr(); |
| 4129 | if (E == nullptr) | 4143 | if (E == nullptr) |
| 4130 | return nullptr; | 4144 | return nullptr; |
| ... | @@ -4132,8 +4146,9 @@ Node *AbstractManglingParser<Derived, Alloc>::parsePrefixExpr(StringView Kind, | ... | @@ -4132,8 +4146,9 @@ Node *AbstractManglingParser<Derived, Alloc>::parsePrefixExpr(StringView Kind, |
| 4132 | } | 4146 | } |
| 4133 | | 4147 | |
| 4134 | template <typename Derived, typename Alloc> | 4148 | template <typename Derived, typename Alloc> |
| 4135 | Node *AbstractManglingParser<Derived, Alloc>::parseBinaryExpr(StringView Kind, | 4149 | Node * |
| 4136 | Node::Prec Prec) { | 4150 | AbstractManglingParser<Derived, Alloc>::parseBinaryExpr(std::string_view Kind, |
| | 4151 | Node::Prec Prec) { |
| 4137 | Node *LHS = getDerived().parseExpr(); | 4152 | Node *LHS = getDerived().parseExpr(); |
| 4138 | if (LHS == nullptr) | 4153 | if (LHS == nullptr) |
| 4139 | return nullptr; | 4154 | return nullptr; |
| ... | @@ -4144,9 +4159,9 @@ Node *AbstractManglingParser<Derived, Alloc>::parseBinaryExpr(StringView Kind, | ... | @@ -4144,9 +4159,9 @@ Node *AbstractManglingParser<Derived, Alloc>::parseBinaryExpr(StringView Kind, |
| 4144 | } | 4159 | } |
| 4145 | | 4160 | |
| 4146 | template <typename Derived, typename Alloc> | 4161 | template <typename Derived, typename Alloc> |
| 4147 | Node * | 4162 | Node *AbstractManglingParser<Derived, Alloc>::parseIntegerLiteral( |
| 4148 | AbstractManglingParser<Derived, Alloc>::parseIntegerLiteral(StringView Lit) { | 4163 | std::string_view Lit) { |
| 4149 | StringView Tmp = parseNumber(true); | 4164 | std::string_view Tmp = parseNumber(true); |
| 4150 | if (!Tmp.empty() && consumeIf('E')) | 4165 | if (!Tmp.empty() && consumeIf('E')) |
| 4151 | return make<IntegerLiteral>(Lit, Tmp); | 4166 | return make<IntegerLiteral>(Lit, Tmp); |
| 4152 | return nullptr; | 4167 | return nullptr; |
| ... | @@ -4176,7 +4191,7 @@ Node *AbstractManglingParser<Derived, Alloc>::parseFunctionParam() { | ... | @@ -4176,7 +4191,7 @@ Node *AbstractManglingParser<Derived, Alloc>::parseFunctionParam() { |
| 4176 | return make<NameType>("this"); | 4191 | return make<NameType>("this"); |
| 4177 | if (consumeIf("fp")) { | 4192 | if (consumeIf("fp")) { |
| 4178 | parseCVQualifiers(); | 4193 | parseCVQualifiers(); |
| 4179 | StringView Num = parseNumber(); | 4194 | std::string_view Num = parseNumber(); |
| 4180 | if (!consumeIf('_')) | 4195 | if (!consumeIf('_')) |
| 4181 | return nullptr; | 4196 | return nullptr; |
| 4182 | return make<FunctionParam>(Num); | 4197 | return make<FunctionParam>(Num); |
| ... | @@ -4187,7 +4202,7 @@ Node *AbstractManglingParser<Derived, Alloc>::parseFunctionParam() { | ... | @@ -4187,7 +4202,7 @@ Node *AbstractManglingParser<Derived, Alloc>::parseFunctionParam() { |
| 4187 | if (!consumeIf('p')) | 4202 | if (!consumeIf('p')) |
| 4188 | return nullptr; | 4203 | return nullptr; |
| 4189 | parseCVQualifiers(); | 4204 | parseCVQualifiers(); |
| 4190 | StringView Num = parseNumber(); | 4205 | std::string_view Num = parseNumber(); |
| 4191 | if (!consumeIf('_')) | 4206 | if (!consumeIf('_')) |
| 4192 | return nullptr; | 4207 | return nullptr; |
| 4193 | return make<FunctionParam>(Num); | 4208 | return make<FunctionParam>(Num); |
| ... | @@ -4341,7 +4356,7 @@ Node *AbstractManglingParser<Derived, Alloc>::parseExprPrimary() { | ... | @@ -4341,7 +4356,7 @@ Node *AbstractManglingParser<Derived, Alloc>::parseExprPrimary() { |
| 4341 | Node *T = getDerived().parseType(); | 4356 | Node *T = getDerived().parseType(); |
| 4342 | if (T == nullptr) | 4357 | if (T == nullptr) |
| 4343 | return nullptr; | 4358 | return nullptr; |
| 4344 | StringView N = parseNumber(/*AllowNegative=*/true); | 4359 | std::string_view N = parseNumber(/*AllowNegative=*/true); |
| 4345 | if (N.empty()) | 4360 | if (N.empty()) |
| 4346 | return nullptr; | 4361 | return nullptr; |
| 4347 | if (!consumeIf('E')) | 4362 | if (!consumeIf('E')) |
| ... | @@ -4464,7 +4479,7 @@ AbstractManglingParser<Derived, Alloc>::parsePointerToMemberConversionExpr( | ... | @@ -4464,7 +4479,7 @@ AbstractManglingParser<Derived, Alloc>::parsePointerToMemberConversionExpr( |
| 4464 | Node *Expr = getDerived().parseExpr(); | 4479 | Node *Expr = getDerived().parseExpr(); |
| 4465 | if (!Expr) | 4480 | if (!Expr) |
| 4466 | return nullptr; | 4481 | return nullptr; |
| 4467 | StringView Offset = getDerived().parseNumber(true); | 4482 | std::string_view Offset = getDerived().parseNumber(true); |
| 4468 | if (!consumeIf('E')) | 4483 | if (!consumeIf('E')) |
| 4469 | return nullptr; | 4484 | return nullptr; |
| 4470 | return make<PointerToMemberConversionExpr>(Ty, Expr, Offset, Prec); | 4485 | return make<PointerToMemberConversionExpr>(Ty, Expr, Offset, Prec); |
| ... | @@ -4482,7 +4497,7 @@ Node *AbstractManglingParser<Derived, Alloc>::parseSubobjectExpr() { | ... | @@ -4482,7 +4497,7 @@ Node *AbstractManglingParser<Derived, Alloc>::parseSubobjectExpr() { |
| 4482 | Node *Expr = getDerived().parseExpr(); | 4497 | Node *Expr = getDerived().parseExpr(); |
| 4483 | if (!Expr) | 4498 | if (!Expr) |
| 4484 | return nullptr; | 4499 | return nullptr; |
| 4485 | StringView Offset = getDerived().parseNumber(true); | 4500 | std::string_view Offset = getDerived().parseNumber(true); |
| 4486 | size_t SelectorsBegin = Names.size(); | 4501 | size_t SelectorsBegin = Names.size(); |
| 4487 | while (consumeIf('_')) { | 4502 | while (consumeIf('_')) { |
| 4488 | Node *Selector = make<NameType>(parseNumber()); | 4503 | Node *Selector = make<NameType>(parseNumber()); |
| ... | @@ -5141,7 +5156,7 @@ Node *AbstractManglingParser<Alloc, Derived>::parseFloatingLiteral() { | ... | @@ -5141,7 +5156,7 @@ Node *AbstractManglingParser<Alloc, Derived>::parseFloatingLiteral() { |
| 5141 | const size_t N = FloatData<Float>::mangled_size; | 5156 | const size_t N = FloatData<Float>::mangled_size; |
| 5142 | if (numLeft() <= N) | 5157 | if (numLeft() <= N) |
| 5143 | return nullptr; | 5158 | return nullptr; |
| 5144 | StringView Data(First, First + N); | 5159 | std::string_view Data(First, N); |
| 5145 | for (char C : Data) | 5160 | for (char C : Data) |
| 5146 | if (!std::isxdigit(C)) | 5161 | if (!std::isxdigit(C)) |
| 5147 | return nullptr; | 5162 | return nullptr; |
| ... | @@ -5461,7 +5476,8 @@ Node *AbstractManglingParser<Derived, Alloc>::parse() { | ... | @@ -5461,7 +5476,8 @@ Node *AbstractManglingParser<Derived, Alloc>::parse() { |
| 5461 | if (Encoding == nullptr) | 5476 | if (Encoding == nullptr) |
| 5462 | return nullptr; | 5477 | return nullptr; |
| 5463 | if (look() == '.') { | 5478 | if (look() == '.') { |
| 5464 | Encoding = make<DotSuffix>(Encoding, StringView(First, Last)); | 5479 | Encoding = |
| | 5480 | make<DotSuffix>(Encoding, std::string_view(First, Last - First)); |
| 5465 | First = Last; | 5481 | First = Last; |
| 5466 | } | 5482 | } |
| 5467 | if (numLeft() != 0) | 5483 | if (numLeft() != 0) |
| ... | @@ -5497,4 +5513,8 @@ struct ManglingParser : AbstractManglingParser<ManglingParser<Alloc>, Alloc> { | ... | @@ -5497,4 +5513,8 @@ struct ManglingParser : AbstractManglingParser<ManglingParser<Alloc>, Alloc> { |
| 5497 | | 5513 | |
| 5498 | DEMANGLE_NAMESPACE_END | 5514 | DEMANGLE_NAMESPACE_END |
| 5499 | | 5515 | |
| | 5516 | #ifdef _LIBCXXABI_COMPILER_CLANG |
| | 5517 | #pragma clang diagnostic pop |
| | 5518 | #endif |
| | 5519 | |
| 5500 | #endif // DEMANGLE_ITANIUMDEMANGLE_H | 5520 | #endif // DEMANGLE_ITANIUMDEMANGLE_H |