summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Demangle/ItaniumDemangle.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.
* Synchronize LLVM's copy of libc++abi's demangler with the libc++abiRichard Smith2019-09-071-0/+10
| | | | | | | | | version after r371273. Also fix a minor issue in r371273 that only surfaced after template instantiation from LLVM's use of the demangler. llvm-svn: 371274
* 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
* [Demangle] remove itaniumFindTypesInMangledNamePavel Labath2018-11-271-9/+0
| | | | | | | | | | | | | | | | Summary: This (very specialized) function was added to enable an LLDB use case. Now that a more generic interface (overriding of parser functions - D52992) is available, and LLDB has been converted to use that (D54074), the function is unused and can be removed. Reviewers: erik.pilkington, sgraenitz, rsmith Subscribers: mgorny, hiraditya, christof, libcxx-commits, llvm-commits Differential Revision: https://reviews.llvm.org/D54893 llvm-svn: 347670
* Make initializeOutputStream() return false on error and true on success.Nico Weber2018-11-111-5/+5
| | | | | | | | As discussed in https://reviews.llvm.org/D52104 Differential Revision: https://reviews.llvm.org/D52143 llvm-svn: 346606
* Port libcxxabi r344607 into llvmPavel Labath2018-10-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The original commit message was: 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. The only difference here is the addition of a unit test which exercises the CRTP mechanism to override a function in the parser. Reviewers: erik.pilkington, rsmith, EricWF Subscribers: mgorny, kristina, llvm-commits Differential Revision: https://reviews.llvm.org/D53300 llvm-svn: 344703
* NFC: Fix a -Wsign-conversion warningErik Pilkington2018-10-151-5/+11
| | | | llvm-svn: 344564
* Update microsoftDemangle() to work more like itaniumDemangle().Nico Weber2018-09-151-15/+0
| | | | | | | | | | | * Use same method of initializing the output stream and its buffer * Allow a nullptr Status pointer * Don't print the mangled name on demangling error * Write to N (if it is non-nullptr) Differential Revision: https://reviews.llvm.org/D52104 llvm-svn: 342330
* Add missing include (<functional> for std::ref)David Blaikie2018-08-201-0/+1
| | | | llvm-svn: 340205
* Move Itanium demangler implementation into a header file and add visitation ↵Richard Smith2018-08-201-4857/+206
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: 340203
* Factor Node creation out of the demangler. No functionality changeRichard Smith2018-08-161-77/+99
| | | | | | intended. llvm-svn: 339944
* [itanium demangler] Add llvm::itaniumFindTypesInMangledName()Erik Pilkington2018-08-131-1/+15
| | | | | | | | | | | | 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-46/+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
* Add some helper functions to the demangle utility classes.Zachary Turner2018-07-171-13/+5
| | | | | | | | | | | | | | These are all methods that, while not currently used in the Itanium demangler, are generally useful enough that it's likely the itanium demangler could find a use for them. More importantly, they are all necessary for the Microsoft demangler which is up and coming in a subsequent patch. Rather than combine these into a single monolithic patch, I think it makes sense to commit this utility code first since it is very simple, this way it won't detract from the substance of the MS demangler patch. llvm-svn: 337316
* [LLVMDemangle] Move some utility classes to header files.Zachary Turner2018-07-161-198/+5
| | | | | | | | | | | | In a followup I'm looking to add a Microsoft demangler. Doing so needs a lot of the same utility classes and feature test macros which are already implemented in ItaniumDemangle.cpp. So move all of these things into header files so that they can be re-used by a new demangler. Differential Revision: https://reviews.llvm.org/D49399 llvm-svn: 337217
* [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: 336311
* 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
* Fix spelling mistakes in comments. NFCI.Simon Pilgrim2018-06-261-4/+4
| | | | llvm-svn: 335603
* Move Compiler.h from Demangle back to SupportDavid Blaikie2018-06-041-2/+70
| | | | | | | | Code review feedback from r328123 prefers copying the few feature test macros used by Demangle into there, rather than sinking the header into an odd corner like Demangle. llvm-svn: 333965
* Reverted commits 333390, 333391 and 333394Serge Pavlov2018-05-291-5/+5
| | | | | | Build of shared library LLVMDemangle.so fails due to dependency problem. llvm-svn: 333395
* Use uniform mechanism for OOM errors handlingSerge Pavlov2018-05-291-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | In r325551 many calls of malloc/calloc/realloc were replaces with calls of their safe counterparts defined in the namespace llvm. There functions generate crash if memory cannot be allocated, such behavior facilitates handling of out of memory errors on Windows. If the result of *alloc function were checked for success, the function was not replaced with the safe variant. In these cases the calling function made the error handling, like: T *NewElts = static_cast<T*>(malloc(NewCapacity*sizeof(T))); if (NewElts == nullptr) report_bad_alloc_error("Allocation of SmallVector element failed."); Actually knowledge about the function where OOM occurred is useless. Moreover having a single entry point for OOM handling is convenient for investigation of memory problems. This change removes custom OOM errors handling and replaces them with calls to functions `llvm::safe_*alloc`. Declarations of `safe_*alloc` are moved to a separate include file, to avoid cyclic dependency in SmallVector.h Differential Revision: https://reviews.llvm.org/D47440 llvm-svn: 333390
* [demangler] Add ItaniumPartialDemangler::isCtorOrDtorFangrui Song2018-05-241-0/+32
| | | | | | | | | | Reviewers: erik.pilkington, ruiu, echristo, pcc Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D47248 llvm-svn: 333159
* [demangler] Add a partial demangling API for LLDB.Erik Pilkington2018-04-121-0/+191
| | | | | | | | | | This parses a mangled name into an AST (typically an intermediate stage in itaniumDemangle) and provides some functions to query certain properties or print certain parts of the demangled name. Differential revision: https://reviews.llvm.org/D44668 llvm-svn: 329951
* [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
* Reapply Support layering fixes.David Blaikie2018-03-211-4/+6
| | | | | | | | | | | | | | | | | | | | Compiler.h is used by Demangle (which Support depends on) - so sink it into Demangle to avoid a circular dependency DataTypes.h is used by llvm-c (which Support depends on) - so sink it into llvm-c. DataTypes.h could probably be fixed the other way - making llvm-c depend on Support instead of Support depending on llvm-c - if anyone feels that's the better option, happy to work with them on that. I /think/ this'll address the layering issues that previous attempts to commit this have triggered in the Modules buildbot, but I haven't been able to reproduce that build so can't say for sure. If anyone's having trouble with this - it might be worth taking a look to see if there's a quick fix/something small I missed rather than revert, but no worries. llvm-svn: 328123
* Revert layering changesJonas Devlieghere2018-03-211-6/+4
| | | | | | | | | | | | This reverts: r328072 "Move Compiler.h from Support to Demangler to fix layering." r328073 "Fix the actual user of DataTypes.h in llvm-c to avoid the circular dependency" Failing bots: http://green.lab.llvm.org/green/job/clang-stage2-coverage-R/ http://green.lab.llvm.org/green/job/clang-stage2-configure-Rlto/ llvm-svn: 328085
* Move Compiler.h from Support to Demangler to fix layering.David Blaikie2018-03-211-4/+6
| | | | | | | | | | | | Support depends on Demangle (Support/Unix/Signals.inc), so Demangle including Support/Compiler.h created a circular dependency. Leave a forwarding shim of Compiler.h because it makes more sense for users (a deeper fix might involve splitting Support into lower and upper Support - but that also sounds a bit weird/awkward) than thinking about the dependency on the Demangler. llvm-svn: 328072
* [demangler] Recopy the demangler from libcxxabi.Erik Pilkington2018-03-191-3943/+4521
| | | | | | | | | Some significant work has gone into libcxxabi's copy of this file: - Uses an AST to represent mangled names. - Support/bugfixes for many C++ features. - Uses LLVM coding style. llvm-svn: 327859
* Silence a bunch of implicit fallthrough warningsAdrian Prantl2017-12-191-1/+2
| | | | llvm-svn: 321114
* [ItaniumDemangle] Fix a exponential string copying bugErik Pilkington2017-05-281-0/+3
| | | | | | This is a port of libcxxabi's r304113. llvm-svn: 304114
* [Demangler] copy changes made in libcxxabi's r303718 to ItaniumDemangleErik Pilkington2017-05-271-21/+28
| | | | llvm-svn: 304053
* Demangler: Fix constructor cv qualifier handlingTamas Berghammer2017-05-241-0/+2
| | | | | | | | | | | | | Previously if we parsed a constructor then we set parsed_ctor_dtor_cv to true and never reseted it. This causes issue when a template argument references a constructor (e.g. type of lambda defined inside a constructor) as we will have the parsed_ctor_dtor_cv flag set what will cause issues when parsing later arguments. Differential Revision: https://reviews.llvm.org/D33385 libcxxabi change: https://reviews.llvm.org/rL303737 llvm-svn: 303738
* Revert r303375 "LLVM_FALLTHROUGH instead of fall-through comment."Rui Ueyama2017-05-181-1/+1
| | | | | | This reverts commit r303375 since it didn't compile. llvm-svn: 303377
* LLVM_FALLTHROUGH instead of fall-through comment.Galina Kistanova2017-05-181-1/+1
| | | | llvm-svn: 303375
* Reduce gcc-7 warnings by fall-through comments.Galina Kistanova2017-05-181-1/+1
| | | | llvm-svn: 303365
* Add support for demangling C++11 thread_local variables. David Bozier2017-01-311-0/+23
| | | | | | | | In clang, the grammar for mangling for these names are "<special-name> ::= TW <object name>" for wrapper variables or "<special-name> ::= TH <object name>" for initialization variables. Initial change was made in libccxxabi r293638 llvm-svn: 293643
* Fix ASAN failure in cxa_demangleMehdi Amini2017-01-271-1/+2
| | | | | | Found with ASAN + libFuzzer by Kostya Serebryany <kcc@google.com> llvm-svn: 293330
* Demangle: correct demangling for CV-qualified functionsSaleem Abdulrasool2017-01-241-6/+9
| | | | | | | | | | | When demangling a CV-qualified function type with a final reference type parameter, we would treat the reference type parameter as a r-value ref accidentally. This would result in the improper decoration of the function type itself. Resolves PR31741! llvm-svn: 292976
OpenPOWER on IntegriCloud