summaryrefslogtreecommitdiffstats
path: root/libcxxabi/src/cxa_demangle.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [demangle] NFC: get rid of NodeOrStringErik Pilkington2019-11-041-8/+0
| | | | | | This class was a bit overengineered, and was triggering some PVS warnings. Instead, put strings into a NameType and let clients unconditionally treat it as a Node.
* Implement demangling support for C++20 lambda expression extensions.Richard Smith2019-09-061-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | This implements demangling support for the mangling extensions specified in https://github.com/itanium-cxx-abi/cxx-abi/pull/85, much of which is implemented in Clang r359967 and r371004. Specifically, this provides demangling for: * <template-param-decl> in <lambda-sig> * <template-param> with non-zero level * lambda-expression literals (not emitted by Clang yet) * nullptr literals * string literals (The final two seem unrelated, but handling them was necessary in order to disambiguate between lambda expressions and the other forms of literal for which we have a type but no value.) When demangling a <lambda-sig>, we form template parameters with no corresponding argument, so we cannot substitute in the argument in the demangling. Instead we invent synthetic names for the template parameters (eg, '[]<typename $T>($T *x)'). llvm-svn: 371273
* Update more file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | | to reflect the new license. These used slightly different spellings that defeated my regular expressions. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351648
* NFC: Make the copies of the demangler byte-for-byte identicalErik Pilkington2019-01-171-6/+1
| | | | | | | | | | | | | | With this patch, the copies of the files ItaniumDemangle.h, StringView.h, and Utility.h are kept byte-for-byte in sync between libcxxabi and llvm. All differences (namespaces, fallthrough, and unreachable macros) are defined in each copies' DemanglerConfig.h. This patch also adds a script to copy changes from libcxxabi (cp-to-llvm.sh), and a README.txt explaining the situation. Differential revision: https://reviews.llvm.org/D53538 llvm-svn: 351474
* Port LLVM r346606 to libcxxabi.Nico Weber2018-11-111-1/+1
| | | | llvm-svn: 346607
* cxa_demangle: make demangler's parsing functions overridablePavel Labath2018-10-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This uses CRTP (for performance reasons) to allow a user the override demangler functions to implement custom parsing logic. The motivation for this is LLDB, which needs to occasionaly modify the mangled names. One such instance is already implemented via the TypeCallback member, but this is very specific functionality which does not help with any other use case. Currently we have a use case for modifying the constructor flavours, which would require adding another callback. This approach does not scale. With CRTP, the user (LLDB) can override any function it needs without any special support from the demangler library. After LLDB is ported to use this instead of the TypeCallback mechanism, the callback can be removed. More context can be found in D50599. Reviewers: erik.pilkington, rsmith Subscribers: christof, ldionne, llvm-commits, libcxx-commits Differential Revision: https://reviews.llvm.org/D52992 llvm-svn: 344607
* NFC: Fix a -Wsign-conversion warningErik Pilkington2018-10-151-5/+11
| | | | llvm-svn: 344564
* Merge Demangle change in r342330 to libcxxabi.Nico Weber2018-09-151-15/+0
| | | | | | Differential Revision: https://reviews.llvm.org/D52104 llvm-svn: 342331
* Port LLVM r340203 (and r340205) to libcxxabi.Richard Smith2018-08-201-4835/+186
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Move Itanium demangler implementation into a header file and add visitation support. Summary: This transforms the Itanium demangler into a generic reusable library that can be used to build, traverse, and transform Itanium mangled name trees. This is in preparation for adding a canonicalizing demangler, which cannot live in the Demangle library for layering reasons. In order to keep the diffs simpler, this patch moves more code to the new header than is strictly necessary: in particular, all of the printLeft / printRight implementations can be moved to the implementation file. (And indeed we could make them non-virtual now if we wished, and remove the vptr from Node.) All nodes are now included in the Kind enumeration, rather than omitting some of the Expr nodes, and the three different floating-point literal node types now have distinct Kind values. As a proof of concept for the visitation / matching mechanism, this patch implements a Node dumping facility on top of it, replacing the prior mechanism that produced the pretty-printed output rather than a tree dump. Sample dump output: FunctionEncoding( NameType("int"), NameWithTemplateArgs( NestedName( NameWithTemplateArgs( NameType("A"), TemplateArgs( {NameType("B")})), NameType("f")), TemplateArgs( {NameType("int")})), {}, <null>, QualConst, FunctionRefQual::FrefQualLValue) As a next step, it would make sense to move the LLVM high-level interface to the demangler (the itaniumDemangler function and ItaniumPartialDemangler class) into the Support library, and implement them in terms of the Demangle library. This would allow the libc++abi demangler implementation to be an identical copy of the llvm Demangle library, and would allow the LLVM implementation to reuse LLVM components such as llvm::BumpPtrAllocator, but we'll need to decide how to coordinate that with the MS ABI demangler, so I'm not doing that in this patch. No functionality change intended other than the behavior of dump(). Reviewers: erik.pilkington, zturner, chandlerc, dlj Subscribers: aheejin, llvm-commits Differential Revision: https://reviews.llvm.org/D50930 llvm-svn: 340207
* Factor Node creation out of the demangler. No functionality change intended.Richard Smith2018-08-161-72/+94
| | | | | | (This is a port of llvm r339944 to libcxxabi.) llvm-svn: 339952
* [itanium demangler] Add llvm::itaniumFindTypesInMangledName()Erik Pilkington2018-08-131-0/+6
| | | | | | | | | | | | This function calls a callback whenever a <type> is parsed. This is necessary to implement FindAlternateFunctionManglings in LLDB, which uses a similar hack in FastDemangle. Once that function has been updated to use this version, FastDemangle can finally be removed. Differential revision: https://reviews.llvm.org/D50586 llvm-svn: 339580
* [itanium demangler] Support dot suffixes on block invocation functionsErik Pilkington2018-08-021-0/+2
| | | | | | rdar://32378759 llvm-svn: 338747
* [demangler] Fix an oss-fuzz bug from r338138Erik Pilkington2018-07-281-0/+8
| | | | | | | | Stack overflow on invalid. While collapsing references, we were skipping over a cycle check in ForwardTemplateReference leading to a stack overflow. This commit fixes the problem by duplicating the cycle check in ReferenceType. llvm-svn: 338190
* [demangler] Support for reference collapsingErik Pilkington2018-07-271-45/+56
| | | | | | llvm.org/PR38323 llvm-svn: 338138
* [demangler] call terminate() if allocation failedErik Pilkington2018-07-231-4/+13
| | | | | | | | | | We really should set *status to memory_alloc_failure, but we need to refactor the demangler a bit to properly propagate the failure up the stack. Until then, its better to explicitly terminate then rely on a null dereference crash. rdar://31240372 llvm-svn: 337759
* Merge changes to ItaniumDemangle over to libcxxabi.Zachary Turner2018-07-201-155/+24
| | | | | | | | | | | ItaniumDemangle had a small NFC refactor to make some of its code reusable by the newly added Microsoft demangler. To keep the libcxxabi demangler as close as possible to the master copy this refactor is being merged over. Differential Revision: https://reviews.llvm.org/D49575 llvm-svn: 337582
* [demangler] Avoid alignment warningSerge Pavlov2018-07-051-1/+1
| | | | | | | | | | | | | | The alignment specified by a constant for the field `BumpPointerAllocator::InitialBuffer` exceeded the alignment guaranteed by `malloc` and `new` on Windows. This change set the alignment value to that of `long double`, which is defined by the used platform. It fixes https://bugs.llvm.org/show_bug.cgi?id=37944. Differential Revision: https://reviews.llvm.org/D48889 llvm-svn: 336312
* Revert r336159, r336157. Some bots failed on qualified std::max_align_t, and ↵Erik Pilkington2018-07-031-2/+1
| | | | | | | | | | | other on unqualified max_align_t. I'll take another stab at this tomorrow. Any ideas for fixing this would be appreciated! http://lab.llvm.org:8011/builders/lld-x86_64-darwin13/builds/23071/steps/build_Lld/logs/stdio http://lab.llvm.org:8011/builders/clang-with-thin-lto-ubuntu/builds/11185/steps/build-stage1-compiler/logs/stdio llvm-svn: 336162
* Some buildbots were choking on std::max_align_t, try using the global alias.Erik Pilkington2018-07-031-1/+1
| | | | llvm-svn: 336159
* [demangler] Fix a MSVC alignment warning.Erik Pilkington2018-07-031-1/+2
| | | | | | This should fix llvm.org/PR37944 llvm-svn: 336157
* [demangler] NFC: Some refactoring to support partial demangling.Erik Pilkington2018-04-121-42/+97
| | | | | | | I'm committing this to libcxxabi too so that the two demanglers remain as simular as possible. llvm-svn: 329950
* [demangler] Support for fold expressions.Erik Pilkington2018-04-091-3/+126
| | | | llvm-svn: 329601
* [demangler] Support for <data-member-prefix>.Erik Pilkington2018-04-091-0/+9
| | | | llvm-svn: 329600
* [demangler] Support for partially substituted sizeof....Erik Pilkington2018-04-091-1/+24
| | | | llvm-svn: 329599
* [demangler] Fix a bug in r328464 found by oss-fuzz.Erik Pilkington2018-03-261-2/+27
| | | | llvm-svn: 328507
* [demangler] Use a back-patching scheme to resolve forward references.Erik Pilkington2018-03-251-40/+79
| | | | | | | | | | | | | | | Strictly in a conversion operator's type, a <template-param> refers to a <template-arg> that is further ahead in the mangled name. Instead of doing a second parse to resolve these, introduce a ForwardTemplateReference Node and back-patch the referenced <template-arg> when we're in the right context. This is also a correctness fix, previously we would only do a second parse if the <template-param> was out of bounds in the current set of <template-args>. This lead to misdemangles (gasp!) when the conversion operator was a member of a templated struct, for instance. llvm-svn: 328464
* [demangler] Tweak how parameter pack sizes are determined.Erik Pilkington2018-03-251-210/+105
| | | | | | | | Rather than eagerly propagating up parameter pack sizes in Node ctors, find the parameter pack size during printing. This is being done to support back-patching forward referencing <template-param>s. llvm-svn: 328463
* [demangler] Support for clang's enable_if attribute.Erik Pilkington2018-03-251-6/+35
| | | | | | Fixes PR33569. llvm-svn: 328462
* [demangler] Support for <template-param>s in generic lambdas.Erik Pilkington2018-03-161-12/+14
| | | | | | | These <template-param>s refer to "artifical" <template-arg>s that don't appear in the mangled name, so we just print them as "auto". llvm-svn: 327690
* [demangler] Simplify printing of structured bindings.Erik Pilkington2018-03-101-1/+1
| | | | | | Thanks to Richard Smith for the post-commit review! llvm-svn: 327228
* [demangler] Support for sequence numbers on lifetime extended temporaries.Erik Pilkington2018-03-101-0/+8
| | | | llvm-svn: 327227
* [demangler] Support for structured bindings.Erik Pilkington2018-03-101-3/+26
| | | | llvm-svn: 327226
* [demangler] Fix a mistake in r326797.Erik Pilkington2018-03-071-2/+2
| | | | | | Thanks to Nico Weber for pointing this out! llvm-svn: 326871
* [demangler] Modernize the rest of the demangler.Erik Pilkington2018-03-061-458/+287
| | | | llvm-svn: 326797
* [demangler] Modernize parse_unresolved_name.Erik Pilkington2018-03-061-403/+177
| | | | llvm-svn: 326796
* [demangler] Modernize parse_name.Erik Pilkington2018-03-051-1238/+727
| | | | llvm-svn: 326717
* [demangler] Support for exception specifications on function types.Erik Pilkington2018-02-141-4/+80
| | | | llvm-svn: 325093
* [demangler] Simplify the AST for function types, NFC.Erik Pilkington2018-02-141-92/+66
| | | | llvm-svn: 325092
* [demangler] Support for inheriting constructors.Erik Pilkington2018-02-131-0/+5
| | | | | | Fixes PR33223. llvm-svn: 325023
* [demangler] Rewrite parse_nested_name in the new style.Erik Pilkington2018-02-131-280/+206
| | | | llvm-svn: 325022
* [demangler] Support for initializer lists and designated initializers.Erik Pilkington2018-02-131-2/+142
| | | | llvm-svn: 324970
* [demangler] Support for dependent elaborate type specifiers.Erik Pilkington2018-02-131-2/+39
| | | | llvm-svn: 324969
* [demangler] All <qualifiers> on one type should share one entry in the ↵Erik Pilkington2018-02-131-45/+51
| | | | | | | | substitution table. Previously, both <extended-qualifier>s and <CV-qualifiers> got their own entries. llvm-svn: 324968
* [demangler] Refactor the type parserErik Pilkington2018-02-051-821/+595
| | | | | | Differential revision: https://reviews.llvm.org/D41889 llvm-svn: 324282
* [demangler] return early if conditional expr parsing failedErik Pilkington2018-02-051-2/+7
| | | | | | This should fix some bugs found by oss-fuzz. llvm-svn: 324203
* [demangler] Clean up the expression parserErik Pilkington2018-02-021-1441/+843
| | | | | | | | | | | | | | | | This commit cleans up the expression parser, using a new style: - parse* functions now return Node pointers. - The mangled name is now held in Db and accessed with look() and consume() - LLVM coding style This style is meant to avoid the 2 most common types of bugs in the old demanger, namely misusing the Names stack (ie, calling back() on empty) and going out of bounds on the mangled name. I also think it makes the demangler a lot cleaner. Differential revision: https://reviews.llvm.org/D41887 llvm-svn: 324111
* [demangler] Improve variadic template supportErik Pilkington2018-01-311-376/+585
| | | | | | | | | | | | | | This commit changes how variadic templates are represented in the demangler, in order to fix some longstanding bugs. Now instead of expanding variadic templates during parsing, the expansion is done during printing by reusing the unexpanded AST. This allows the demangler to handle cases where multiple packs contribute to a single production, and correctly handle "Dp" and "sp" productions, which corrispond to pack expansions in type and expression contexts. Differential revision: https://reviews.llvm.org/D41885 llvm-svn: 323906
* [demangler] Support for abi_tag attributeErik Pilkington2017-11-221-16/+76
| | | | | | Differential revision: https://reviews.llvm.org/D40279 llvm-svn: 318874
* [demangler] Document some features that the demangler doesn't yet support, NFCErik Pilkington2017-11-211-0/+6
| | | | llvm-svn: 318765
* [demangler] Fix some more -Wshadow warnings I missed in r310535Erik Pilkington2017-08-101-3/+3
| | | | llvm-svn: 310546
OpenPOWER on IntegriCloud