11 Commits

Author SHA1 Message Date
Zachary Turner
c20481951c [MS Demangler] Properly handle function parameter back-refs.
Properly demangle function parameter back-references.

Previously we treated lists of function parameters and template
parameters the same. There are some important differences with regards
to back-references, and some less important differences regarding which
characters can appear before or after the name.

The important differences are that with a given type T, all instances of
a function parameter list share the same global back-ref table.
Specifically, if X and Y are function pointers, then there are 3
entities in the declaration X func(Y) which all affect and are affected
by the master parameter back-ref table:
  1) The parameter list of X's function type
  2) the parameter list of func itself
  3) The parameter list of Y's function type.

The previous code would create a back-reference table that was local to
a single parameter list, so it would not be shared across parameter
lists.

This was discovered when porting ms-back-references.test from clang's
mangling tests. All of these tests should now pass with the new changes.

In doing so, I split the function for parsing template and function
parameters into two separate functions. This makes the template
parameter list parsing code in particular very small and easy to
understand now.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@338075 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-26 22:13:39 +00:00
Zachary Turner
c2403ba5de [MS Demangler] Print calling convention inside parentheses.
For function pointers, we would print something like

int __cdecl (*)(int)

We need to move the calling convention inside, and print

int (__cdecl *)(int)

This patch implements this change for regular function pointers as
well as member function pointers.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@338068 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-26 20:33:48 +00:00
Zachary Turner
eedd47c7f5 [MS Demangler] Add ms-arg-qualifiers.test
This converts the arg qualifier mangling tests from
clang/CodeGenCXX/mangle-ms-arg-qualifiers.cpp to demangling tests.
Most tests already pass, so this patch doesn't come with any
functional change, just the addition of new tests.  The few tests
that don't pass are left in with a FIXME label so that they don't
run but serve as documentation about what still doesn't work.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@338067 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-26 20:25:35 +00:00
Zachary Turner
d4bb30eca1 [MS Demangler] Demangle pointers to member functions.
After this patch, we can now properly demangle pointers to member
functions.  The calling convention is located in the wrong place,
but this will be fixed in a followup since it also affects non
member function pointers.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@338065 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-26 20:20:10 +00:00
Zachary Turner
3c58d5b196 [MS Demangler] Demangle data member pointers.
Differential Revision: https://reviews.llvm.org/D49630

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@338061 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-26 19:56:09 +00:00
Reid Kleckner
7bf2466873 [Demangle] Attempt to fix arena memory leak
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@337720 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-23 18:21:43 +00:00
Martin Storsjo
bc0cffa673 Remove a superfluous semicolon
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@337599 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-20 18:43:42 +00:00
Zachary Turner
3dd57df1d1 [Demangler] Correctly factor in assignment when allocating.
Incidentally all allocations that we currently perform were
properly aligned, but this was only an accident.

Thanks to Erik Pilkington for catching this.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@337596 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-20 18:35:06 +00:00
Benjamin Kramer
70215f556f [Demangler] Add missing overrides
-Winconsistent-missing-override complains about this.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@337592 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-20 18:22:12 +00:00
Zachary Turner
aeb65f137a Fix a few warnings and style issues in MS demangler.
Also remove a broken test case.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@337591 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-20 18:07:33 +00:00
Zachary Turner
42e40ea33e Add a Microsoft Demangler.
This adds initial support for a demangling library (LLVMDemangle)
and tool (llvm-undname) for demangling Microsoft names.  This
doesn't cover 100% of cases and there are some known limitations
which I intend to address in followup patches, at least until such
time that we have (near) 100% test coverage matching up with all
of the test cases in clang/test/CodeGenCXX/mangle-ms-*.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@337584 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-20 17:27:48 +00:00