summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Demangle
Commit message (Collapse)AuthorAgeFilesLines
* llvm-undname: Correctly demangle vararg parametersNico Weber2019-06-042-5/+10
| | | | | | | FunctionSignatureNode already had an IsVariadic field, but it wasn't used anywhere yet. Set it and use it. llvm-svn: 362541
* llvm-undname: More coverage-related cleanupsNico Weber2019-06-041-11/+9
| | | | | | | | | | | | | | | | | | | | - The loop in demangleFunctionParameterList() only exits on Error, @, and Z. All 3 cases were handled, so the rest of the function is DEMANGLE_UNREACHABLE. - The loop in demangleTemplateParameterList() always returns on Error, so there's no need to check for that in the loop header and after the loop. - Add test cases for invalid function parameter manglings. - Add a (redundant) test case for a simple template parameter list mangling. - Add a test case pointing out that varargs functions aren't demangled correctly. llvm-svn: 362540
* llvm-undname: Add test coverage for demangleInitFiniStub()Nico Weber2019-06-041-2/+2
| | | | llvm-svn: 362536
* llvm-undname: Yet more coverage for error pathsNico Weber2019-06-041-3/+8
| | | | | | | | | | | | | | | | - For error returns in demangleSpecialTableNode(), demangleLocalStaticGuard(), RTTITypeDescriptor, demangleRttiBaseClassDescriptorNode(), demangleUnsigned(), demangleUntypedVariable() (via RttiBaseClassArray) - For ?_A and ?_P which are handled at early levels of the demangler but are not implemented in a later stage; this is now more obvious - Replace a "default:" with an explicit list of cases, to get -Wswitch check we list all cases llvm-svn: 362520
* llvm-undname: More no-op changes to increase test coverageNico Weber2019-06-041-6/+5
| | | | | | | | | | - Add test coverage around invalid anon namespaces and for error paths in demanglePrimitiveType() and in demangleFullyQualifiedTypeName() - Use DEMANGLE_UNREACHABLE in two more unreachable places llvm-svn: 362514
* llvm-undname: Several behavior-preserving changes to increase coverageNico Weber2019-06-042-16/+10
| | | | | | | | | | | | | | | | | - Replace `Error = true` in a few branches that are truly unreachable with DEMANGLE_UNREACHABLE - Remove early return early in startsWithLocalScopePattern() because it's redundant with the next two early returns - Remove unreachable `case '0'` (it's handled in the branch below) - Remove an unused bool return - Add test coverage for several early error returns, mostly in array type parsing llvm-svn: 362506
* llvm-undname; Add more test coverage for demangleFunctionClass()Nico Weber2019-06-021-2/+2
| | | | | | | | Also add two FC_Far that seem to be missing, by symmetry from the public and protected cases. (But FC_Far isn't really a thing anymore, so this doesn't really have an observable effect.) llvm-svn: 362344
* Remove code path that's dead after r358835Nico Weber2019-06-021-4/+2
| | | | llvm-svn: 362333
* llvm-undname: Support demangling char8_tNico Weber2019-05-282-0/+3
| | | | | | Ports clang's mangling support added in r354633 to llvm-undname. llvm-svn: 361839
* llvm-undname: Add support for local static thread guardsNico Weber2019-05-282-3/+9
| | | | llvm-svn: 361835
* llvm-undname: Remove unreachable statementNico Weber2019-05-281-1/+0
| | | | llvm-svn: 361786
* llvm-undname: Extract demangleMD5Name() method; no behavior changeNico Weber2019-05-271-30/+34
| | | | llvm-svn: 361783
* llvm-undname: Make demangling of MD5 names more robustNico Weber2019-05-271-3/+25
| | | | | | | | | | | | | | | | Demangler::parse() for MD5 names would: 1. Put all remaining text into the MD5 name sight unseen 2. Not modify MangledName This meant that if the demangler recursively called parse() (e.g. in demangleLocallyScopedNamePiece()), every recursive call that started on an MD5 name would add all remaining bytes to the output buffer but only advance the input by a byte. For valid inputs, MD5 types are never (well, see comments for 2 exceptions) nested, but for invalid input this could cause memory use quadratic in the input size. llvm-svn: 361744
* llvm-undname: Fix an assert-on-invalid, found by oss-fuzzNico Weber2019-05-221-1/+3
| | | | | | | | If a template parameter refers to a pointer to member, but the mangling of that was a string literal instead of a real symbol, llvm-undname used to crash instead of rejecting the input. llvm-svn: 361402
* llvm-undname: Fix assert-on->4GiB-string-literal, found by oss-fuzzNico Weber2019-04-241-1/+4
| | | | llvm-svn: 359109
* llvm-undname: Support demangling the spaceship operatorNico Weber2019-04-232-5/+5
| | | | | | Also add a test for demanling the co_await operator. llvm-svn: 359007
* llvm-undname: Fix an assert-on-invalid, found by oss-fuzzNico Weber2019-04-221-1/+1
| | | | llvm-svn: 358891
* llvm-undname: Fix hex escapes in wchar_t, char16_t, char32_t stringsNico Weber2019-04-211-3/+3
| | | | | | | | | | | | | | | | | llvm-undname used to put '\x' in front of every pair of nibbles, but u"\xD7\xFF" produces a string with 6 bytes: \xD7 \0 \xFF \0 (and \0\0). Correct for a single character (plus terminating \0) is u\xD7FF instead. Now, wchar_t, char16_t, and char32_t strings roundtrip from source to clang-cl (and cl.exe) and then llvm-undname. (...at least as long as it's not a string like L"\xD7FF" L"foo" which gets demangled as L"\xD7FFfoo", where the compiler then considers the "f" as part of the hex escape. That seems ok.) Also add a comment saying that the "almost-valid" char32_t string I added in my last commit is actually produced by compilers. llvm-svn: 358857
* llvm-undname: Fix stack overflow on almost-validNico Weber2019-04-211-3/+3
| | | | | | | | | | | | | | | | | If a unsigned with all 4 bytes non-0 was passed to outputHex(), there were two off-by-ones in it: - Both MaxPos and Pos left space for the final \0, which left the buffer one byte to small. Set MaxPos to 16 instead of 15 to fix. - The `assert(Pos >= 0);` was after a `Pos--`, move it up one line. Since valid Unicode codepoints are <= 0x10ffff, this could never really happen in practice. Found by oss-fuzz. llvm-svn: 358856
* llvm-undname: Fix stack overflow on invalid found by oss-fuzzNico Weber2019-04-211-1/+1
| | | | llvm-svn: 358852
* llvm-undname: Improve string literal demangling with embedded \0 charsNico Weber2019-04-201-2/+5
| | | | | | | | | - Don't assert when a string looks like a u32 string to the heuristic but doesn't have a length that's 0 mod 4. Instead, classify those as u16 with embedded \0 chars. Found by oss-fuzz. - Print embedded nul bytes as \0 instead of \x00. llvm-svn: 358835
* llvm-undname: Attempt to fix leak-on-invalid found by oss-fuzzNico Weber2019-04-191-3/+6
| | | | llvm-svn: 358760
* llvm-undname: Fix two more asserts-on-invalid, found by oss-fuzzNico Weber2019-04-181-3/+4
| | | | llvm-svn: 358708
* llvm-undname: Fix two asserts-on-invalidNico Weber2019-04-181-3/+5
| | | | llvm-svn: 358707
* llvm-undname: Consistently use "return nullptr" in functions returning pointersNico Weber2019-04-161-4/+4
| | | | llvm-svn: 358492
* llvm-undname: Fix nullptr deref on invalid structor names in template argsNico Weber2019-04-161-3/+4
| | | | | | | | | | | | Similar to r358421: A StructorIndentifierNode has a Class field which is read when printing it, but if the StructorIndentifierNode appears in a template argument then demangleFullyQualifiedSymbolName() which sets Class isn't called. Since StructorIndentifierNodes are always leaf names, we can just reject them as well. Found by oss-fuzz. llvm-svn: 358491
* llvm-undname: Fix nullptr deref on invalid conversion operator names in ↵Nico Weber2019-04-151-1/+10
| | | | | | | | | | | | | | | | | template args A ConversionOperatorIdentifierNode has a TargetType which is read when printing it, but if the ConversionOperatorIdentifierNode appears in a template argument there's nothing that can provide the TargetType. Normally the COIN is a symbol (leaf) name and takes its TargetType from the symbol's type, but in a template argument context the COIN can only be either a non-leaf name piece or a type, and must hence be invalid. Similar to the COIN check in demangleDeclarator(). Found by oss-fuzz. llvm-svn: 358421
* llvm-undname: Fix oss-fuzz-foudn crash-on-invalid with incomplete special ↵Nico Weber2019-04-141-0/+4
| | | | | | table nodes llvm-svn: 358367
* llvm-undname: Fix another crash-on-invalid found by oss-fuzzNico Weber2019-04-141-1/+4
| | | | llvm-svn: 358363
* llvm-undname: Use UNREACHABLE after exhaustive switch returning everywhereNico Weber2019-04-111-1/+1
| | | | | | No behavior change. llvm-svn: 358241
* llvm-undname: Name a bool param, no behavior changeNico Weber2019-04-111-5/+6
| | | | llvm-svn: 358240
* llvm-undname: Fix out-of-bounds read on invalid intrinsic function codeNico Weber2019-04-111-3/+9
| | | | | | Found by inspection. llvm-svn: 358239
* llvm-undname: Don't crash on incomplete enum tag manglingsNico Weber2019-04-111-1/+1
| | | | | | Found by inspection. llvm-svn: 358238
* llvm-undname: Fix crash on incomplete virtual this adjustsNico Weber2019-04-111-2/+3
| | | | | | | | Found by oss-fuzz. Also remove an else-after-return, this part has no behavior change. llvm-svn: 358237
* llvm-undname: Fix crash on invalid name in a template parameter pointer to ↵Nico Weber2019-04-111-0/+2
| | | | | | | | member arg Found by oss-fuzz. llvm-svn: 358234
* llvm-undname: Fix another crash-on-invalidNico Weber2019-04-101-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | This fixes a regression from https://reviews.llvm.org/D60354. We used to SymbolNode *Symbol = demangleEncodedSymbol(MangledName, QN); if (Symbol) { Symbol->Name = QN; } but changed that to SymbolNode *Symbol = demangleEncodedSymbol(MangledName, QN); if (Error) return nullptr; Symbol->Name = QN; and one branch somewhere returned a nullptr without setting Error. Looking at the code changed in r340083 and r340710 that branch looks like a remnant from an earlier attempt to demangle RTTI descriptors that has since been rewritten -- so just remove this branch. It shouldn't change behavior for correctly mangled symbols. llvm-svn: 358112
* llvm-undname: Fix more crashes and asserts on invalid inputsNico Weber2019-04-081-24/+76
| | | | | | | | | | | | | | | | | | | | | For functions whose callers don't check that enough input is present, add checks at the start of the function that enough input is there and set Error otherwise. For functions that return AST objects, return nullptr instead of incomplete AST objects with nullptr fields if an error occurred during the function. Introduce a new function demangleDeclarator() for the sequence demangleFullyQualifiedSymbolName(); demangleEncodedSymbol() and use it in the two places that had this sequence. Let this new function check that ConversionOperatorIdentifiers have a valid TargetType. Some of the bad inputs found by oss-fuzz, others by inspection. Differential Revision: https://reviews.llvm.org/D60354 llvm-svn: 357936
* llvm-undname: Name a pair. No behavior change.Nico Weber2019-04-031-3/+5
| | | | | | Differential Revision: https://reviews.llvm.org/D60210 llvm-svn: 357653
* llvm-undname: Fix a crash-on-invalidNico Weber2019-04-031-1/+1
| | | | | | | | Found by oss-fuzz, fixes issue 13260 on oss-fuzz. Differential Revision: https://reviews.llvm.org/D60207 llvm-svn: 357649
* llvm-undame: Fix an assert-on-invalidNico Weber2019-04-031-1/+4
| | | | | | | | Found by oss-fuzz, fixes issue 12432 on os-fuzz. Differential Revision: https://reviews.llvm.org/D60206 llvm-svn: 357648
* llvm-undname: Fix an assert-on-invalidNico Weber2019-04-031-0/+5
| | | | | | | | Found by oss-fuzz, fixes issues 12428 and 12429 on oss-fuzz. Differential Revision: https://reviews.llvm.org/D60204 llvm-svn: 357647
* llvm-undname: Fix a crash-on-invalidNico Weber2019-04-031-0/+4
| | | | | | | | Found by oss-fuzz, fixes issues 12435 and 12438 on oss-fuzz. Differential Revision: https://reviews.llvm.org/D60202 llvm-svn: 357646
* Add missing include (cstdlib) to Demangle.hKonstantin Zhuravlyov2019-01-221-0/+1
| | | | | | Differential Revision: https://reviews.llvm.org/D57035 llvm-svn: 351861
* Update more file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-193-12/+9
| | | | | | | | | | | | | | | | | | 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
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-192-8/+6
| | | | | | | | | | | | | | | | | to reflect the new license. 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: 351636
* Add __[_[_]]Z demangling to new common demangle functionJames Henderson2019-01-181-1/+7
| | | | | | | | | | | | This is a follow-up to r351448. It adds support for other _*Z extensions of the Itanium demanling, to the newly available demangle function heuristic. Reviewed by: erik.pilkington, rupprecht, grimar Differential Revision: https://reviews.llvm.org/D56855 llvm-svn: 351551
* NFC: Make the copies of the demangler byte-for-byte identicalErik Pilkington2019-01-172-11/+11
| | | | | | | | | | | | | | 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
* Move demangling function from llvm-objdump to Demangle libraryJames Henderson2019-01-172-0/+31
| | | | | | | | | | | | | | | | This allows it to be used in an upcoming llvm-readobj change. A small change in internal behaviour of the function is to always call the microsoftDemangle function if the string does not have an itanium encoding prefix, rather than only if it starts with '?'. This is harmless because the microsoftDemangle function does the same check already. Reviewed by: grimar, erik.pilkington Differential Revision: https://reviews.llvm.org/D56721 llvm-svn: 351448
* [llvm-undname] Add support for demangling msvc's noexcept types.Zachary Turner2019-01-082-3/+9
| | | | | | | | | | | Starting in C++17, MSVC introduced a new mangling for function parameters that are themselves noexcept functions. This patch makes llvm-undname properly demangle them. Patch by Zachary Henkel Differential Revision: https://reviews.llvm.org/D55769 llvm-svn: 350656
* [MS Demangler] Add a flag for dumping types without tag specifier.Zachary Turner2019-01-021-8/+10
| | | | | | | | Sometimes it's useful to be able to output demangled names without tag specifiers like "struct", "class", etc. This patch adds a flag enabling this. llvm-svn: 350241
OpenPOWER on IntegriCloud