9 Commits

Author SHA1 Message Date
Nico Weber
65bbccae60 [MS Demangler] Print public:, protected:, private: if set in FunctionClass or a variable's StorageClass.
undname prints them, and the information is in the decorated name, so we probably shouldn't lose it when undecorating.

I spot-checked a few of the funnier-looking outputs, and undname has the same output.

Differential Revision: https://reviews.llvm.org/D54396


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@346791 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-13 20:18:26 +00:00
Nico Weber
86c04a0332 [MS demangler] Use a slightly shorter unmangling for mangled strings.
Before: const wchar_t * {L"%"}
Now: L"%"

See also PR39593.
Differential Revision: https://reviews.llvm.org/D54294


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@346544 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-09 19:28:50 +00:00
Reid Kleckner
b7d45e1d88 Fix clang -Wimplicit-fallthrough warnings across llvm, NFC
This patch should not introduce any behavior changes. It consists of
mostly one of two changes:
1. Replacing fall through comments with the LLVM_FALLTHROUGH macro
2. Inserting 'break' before falling through into a case block consisting
   of only 'break'.

We were already using this warning with GCC, but its warning behaves
slightly differently. In this patch, the following differences are
relevant:
1. GCC recognizes comments that say "fall through" as annotations, clang
   doesn't
2. GCC doesn't warn on "case N: foo(); default: break;", clang does
3. GCC doesn't warn when the case contains a switch, but falls through
   the outer case.

I will enable the warning separately in a follow-up patch so that it can
be cleanly reverted if necessary.

Reviewers: alexfh, rsmith, lattner, rtrieu, EricWF, bollu

Differential Revision: https://reviews.llvm.org/D53950

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@345882 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-01 19:54:45 +00:00
Zachary Turner
c35d5db855 [MS Demangler] Expose the Demangler AST publicly.
LLDB would like to use this in order to build a clang AST from
a mangled name.

This is NFC otherwise.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@345837 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-01 15:07:32 +00:00
Zachary Turner
6568fb5f19 [MS Demangler] Fix several crashes and demangling bugs.
These bugs were found by writing a Python script which spidered
the entire Chromium build directory tree demangling every symbol
in every object file.  At the start, the tool printed:

  Processed 27443 object files.
  2926377/2936108 symbols successfully demangled (99.6686%)
  9731 symbols could not be demangled (0.3314%)
  14589 files crashed while demangling (53.1611%)

After this patch, it prints:

  Processed 27443 object files.
  41295518/41295617 symbols successfully demangled (99.9998%)
  99 symbols could not be demangled (0.0002%)
  0 files crashed while demangling (0.0000%)

The issues fixed in this patch are:

  * Ignore empty parameter packs.  Previously we would encounter
    a mangling for an empty parameter pack and add a null node
    to the AST.  Since we don't print these anyway, we now just
    don't add anything to the AST and ignore it entirely.  This
    fixes some of the crashes.

  * Account for "incorrect" string literal demanglings.  Apparently
    an older version of clang would not truncate mangled string
    literals to 32 bytes of encoded character data.  The demangling
    code however would allocate a 32 byte buffer thinking that it
    would not encounter more than this, and overrun the buffer.
    We now demangle up to 128 bytes of data, since the buggy
    clang would encode up to 32 *characters* of data.

  * Extended support for demangling init-fini stubs.  If you had
    something like
      struct Foo {
        static vector<string> S;
      };
    this would generate a dynamic atexit initializer *for the
    variable*.  We didn't handle this, but now we print something
    nice.  This is actually an improvement over undname, which will
    fail to demangle this at all.

  * Fixed one case of static this adjustment.  We weren't handling
    several thunk codes so we didn't recognize the mangling.  These
    are now handled.

  * Fixed a back-referencing problem.  Member pointer templates
    should have their components considered for back-referencing

The remaining 99 symbols which can't be demangled are all symbols
which are compiler-generated and undname can't demangle either.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341000 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-29 23:56:09 +00:00
Zachary Turner
ef6d9043af Add support for various C++14 demanglings.
Mostly this includes <auto> and <decltype-auto> return values.
Additionally, this fixes a fairly obscure back-referencing bug
that was encountered in one of the C++14 tests, which is that
if you have something like Foo<&bar, &bar> then the `bar`
forms a backreference.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340896 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-29 04:12:44 +00:00
Zachary Turner
2e2b1e2608 [MS Demangler] Add output flags to all function calls.
Previously we had a FunctionSigFlags, but it's more flexible
to just have one set of output flags that apply to the entire
process and just pipe the entire set of flags through the
output process.

This will be useful when we start allowing the user to customize
the outputting behavior.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340894 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-29 03:59:17 +00:00
Chandler Carruth
b19b37f8f0 Fix this file to have the necessary standard library includes and use
the `std::` namespace. Should fix a number of build bots as well.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340721 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-27 06:52:14 +00:00
Zachary Turner
6e3e8a765e [MS Demangler] Re-write the Microsoft demangler.
This is a pretty large refactor / re-write of the Microsoft
demangler.  The previous one was a little hackish because it
evolved as I was learning about all the various edge cases,
exceptions, etc.  It didn't have a proper AST and so there was
lots of custom handling of things that should have been much
more clean.

Taking what was learned from that experience, it's now
re-written with a completely redesigned and much more sensible
AST.  It's probably still not perfect, but at least it's
comprehensible now to someone else who wants to come along
and make some modifications or read the code.

Incidentally, this fixed a couple of bugs, so I've enabled
the tests which now pass.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340710 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-27 03:48:03 +00:00