Commit Graph

20 Commits

Author SHA1 Message Date
Erik Pilkington
1e9ed47d14 [ItaniumDemangle] Fix a exponential string copying bug
This is a port of libcxxabi's r304113.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304114 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-28 23:24:52 +00:00
Erik Pilkington
bf14f47c78 [Demangler] copy changes made in libcxxabi's r303718 to ItaniumDemangle
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304053 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-27 01:48:34 +00:00
Tamas Berghammer
b762e5bdbc Demangler: Fix constructor cv qualifier handling
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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303738 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-24 11:29:02 +00:00
Rui Ueyama
54d256ca56 Revert r303375 "LLVM_FALLTHROUGH instead of fall-through comment."
This reverts commit r303375 since it didn't compile.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303377 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-18 20:18:24 +00:00
Galina Kistanova
f73a055bca LLVM_FALLTHROUGH instead of fall-through comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303375 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-18 20:01:52 +00:00
Galina Kistanova
8762436dd0 Reduce gcc-7 warnings by fall-through comments.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303365 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-18 17:53:47 +00:00
David Bozier
34d37a4707 Add support for demangling C++11 thread_local variables.
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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293643 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-31 15:56:36 +00:00
Mehdi Amini
e1698550ad Fix ASAN failure in cxa_demangle
Found with ASAN + libFuzzer by Kostya Serebryany <kcc@google.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293330 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-27 20:32:16 +00:00
Saleem Abdulrasool
815bff1cc4 Demangle: correct demangling for CV-qualified functions
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!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292976 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-24 20:04:58 +00:00
Saleem Abdulrasool
ed1b025f1b Demangle: use named values for CV qualifiers
Rather than hard-coding magic values of 1, 2, 4 (bit-field), use an enum
to name the values.  NFC.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292975 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-24 20:04:56 +00:00
Saleem Abdulrasool
60b4e66e58 Demangle: avoid butchering parameter type
When demangling a CV-qualified function type with a final parameter with
a reference type, we would insert the CV qualification on the parameter
rather than the function, and in the process adjust the insertion point
by one extra, splitting the type name.  This avoids doing so, even
though the attribution is still incorrect.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292965 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-24 18:52:19 +00:00
Saleem Abdulrasool
f2a3664b8a Revert "Demangle: only demangle mangled symbols"
This reverts SVN r286795.  This was incorrect the demangler is expected
to be able to demangle types as well as functions.  This makes the
behaviour of itaniumDemangle similar to __cxa_demangle once more.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292573 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-20 03:54:04 +00:00
Saleem Abdulrasool
902878bb3f Demangle: remove references to allocator for default allocator
The demangler had stopped using a custom allocator but had not been updated to
remove the use of the explicit allocator passing.  This removes that as we do
not need to do anything special here anymore.  This just makes the code more
compact.  NFC.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@287472 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-20 00:20:27 +00:00
Saleem Abdulrasool
21918ee4aa Demangle: remove unnecessary typedef for std::vector
We could create a local typedef for std::vector called Vector.  Inline the use
of std::vector rather than use the typedef.  NFC.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@287471 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-20 00:20:25 +00:00
Saleem Abdulrasool
e17a816352 Demangle: replace custom typedef for std::string with std::string
We created a local typedef for `std::basic_string<char, std::char_traits<char>>`
which is just `std::string`.  Remove the local typedef and propagate the type
information through the rest of the demangler.  NFC.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@287470 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-20 00:20:23 +00:00
Saleem Abdulrasool
7f90f9e9a9 Demangle: use direct member initialization (NFC)
Prefer direct member initialization over the explicit out-of-line initialization
for the construction of the local type.  NFC.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@287469 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-20 00:20:20 +00:00
Saleem Abdulrasool
1d94ec7787 Demangle: only demangle mangled symbols
Only attempt to demangle symbols which have the itanium C++ prefix of `_Z`.
This ensures that we do not treat any symbol name as a managled named.  We would
previously treat a C function `f` as a mangled name and decode that to `float`
incorrectly.

While it is easy to add tests for this, Mehdi recommended against introducing
tests for the demangler as libc++abi should cover the testing.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@286795 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-14 04:54:47 +00:00
Rafael Espindola
fec7b4848f Avoid using alignas and constexpr.
This requires removing the custom allocator, since Demangle cannot
depend on Support and so cannot use Compiler.h.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@280750 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-06 20:36:24 +00:00
Reid Kleckner
6b15e984c4 Fix ItaniumDemangle.cpp build with MSVC 2013
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@280740 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-06 19:39:56 +00:00
Rafael Espindola
ec44cfdaf0 Add an c++ itanium demangler to llvm.
This adds a copy of the demangler in libcxxabi.

The code also has no dependencies on anything else in LLVM. To enforce
that I added it as another library. That way a BUILD_SHARED_LIBS will
fail if anyone adds an use of StringRef for example.

The no llvm dependency combined with the fact that this has to build
on linux, OS X and Windows required a few changes to the code. In
particular:

    No constexpr.
    No alignas

On OS X at least this library has only one global symbol:
__ZN4llvm16itanium_demangleEPKcPcPmPi

My current plan is:

    Commit something like this
    Change lld to use it
    Change lldb to use it as the fallback

    Add a few #ifdefs so that exactly the same file can be used in
    libcxxabi to export abi::__cxa_demangle.

Once the fast demangler in lldb can handle any names this
implementation can be replaced with it and we will have the one true
demangler.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@280732 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-06 19:16:48 +00:00