Commit Graph

192 Commits

Author SHA1 Message Date
Alexis Hunt 656bb314d9 Reapplying patch to change StmtNodes.def to StmtNodes.td, this time
with no whitespace. This will allow statements to be referred to in
attribute TableGen files.

llvm-svn: 103087
2010-05-05 15:24:00 +00:00
Alexis Hunt a8136cc408 Revert r103072; I accidentally ended up deleting a bunch of trailing
whitespace which makes this patch unreadable. Will recommit without the
whitespace.

llvm-svn: 103086
2010-05-05 15:23:54 +00:00
Alexis Hunt b9f408a873 Change StmtNodes.def to StmtNodes.td in anticipation of a rewrite of attributes
llvm-svn: 103072
2010-05-05 04:13:52 +00:00
Douglas Gregor 7988def89f Improve name mangling for dependent template names (e.g., typename
T::template apply<U>), handling a few cases where we previously failed
and performing substitutions on such dependent names. Fixes a crash in
Boost.PropertyTree.

llvm-svn: 102490
2010-04-28 05:58:56 +00:00
John McCall 2408e32096 Make the InjectedClassNameType the canonical type of the current instantiation
of a class template or class template partial specialization.  That is to
say, in
  template <class T> class A { ... };
or
  template <class T> class B<const T*> { ... };
make 'A<T>' and 'B<const T*>' sugar for the corresponding InjectedClassNameType
when written inside the appropriate context.  This allows us to track the
current instantiation appropriately even inside AST routines.  It also allows
us to compute a DeclContext for a type much more efficiently, at some extra
cost every time we write a template specialization (which can be optimized,
but I've left it simple in this patch).

llvm-svn: 102407
2010-04-27 00:57:59 +00:00
Douglas Gregor ffe0884bc4 Emit a lame diagnostic when we can't mangle operator names
llvm-svn: 102168
2010-04-23 03:19:53 +00:00
Douglas Gregor 173627188d Mangle dependent template names such as the nested-name-specifier in
T::apply <U>::type

Fixes PR6899, although I want to dig a little deeper into the FIXME
for dependent template names that refer to operators.

llvm-svn: 102167
2010-04-23 03:10:43 +00:00
Fariborz Jahanian acdfa7acfe Fixes a code gen. bug by removing an assert.
It is ok to have c++-ness inside extern "C" 
block. Fixes pr6644.

llvm-svn: 101948
2010-04-20 22:02:31 +00:00
Anders Carlsson 11e5140db9 Vtable -> VTable renames across the board.
llvm-svn: 101666
2010-04-17 20:15:18 +00:00
Benjamin Kramer b11416d061 Add raw_ostream operators to NamedDecl for convenience. Switch over all users of getNameAsString on a stream.
The next step is to print the name directly into the stream, avoiding a temporary std::string copy.

llvm-svn: 101632
2010-04-17 09:33:03 +00:00
Benjamin Kramer 1554e4a4bb A bunch of string-related microoptimizations in Mangler.
llvm-svn: 100928
2010-04-10 16:03:31 +00:00
John McCall e2f3524f83 Doug pointed out that we have a perfectly reasonable expression here to
serve as a source of source locations for the can't-yet-mangle diagnostic.

llvm-svn: 100924
2010-04-10 09:39:25 +00:00
John McCall e8917e0fd2 Mangle some expressions with codegen implications but no mangling "overhead".
llvm-svn: 100909
2010-04-09 22:54:09 +00:00
John McCall 6936c863b0 Provide an extremely unsatisfactory diagnostic (instead of crashing) when
mangling an unknown expression kind.  Also conveniently tells the user what
kind of expression they should add to the mangler!

llvm-svn: 100907
2010-04-09 22:26:14 +00:00
John McCall 09277542f2 Provide manglings for bool and character literal expressions. These are
just integer-literal expressions with special case implementations in the AST.

Fixes rdar://problem/7825453.

llvm-svn: 100905
2010-04-09 21:48:08 +00:00
Anders Carlsson af2a317e05 Rename CGVtable files to CGVTables.
llvm-svn: 100778
2010-04-08 16:30:25 +00:00
Douglas Gregor 0208535fda Extend DependentNameType with a keyword enum that specifies whether
this was parsed as a typename-specifier, elaborated-type-specifier
(including the kind), or just a dependent qualified type name.

llvm-svn: 100039
2010-03-31 20:19:30 +00:00
Douglas Gregor c1d2d8a014 Rename TypenameType to DependentNameType in anticipation of some
refactoring work in this area.

llvm-svn: 100019
2010-03-31 17:34:00 +00:00
Anders Carlsson f141dd1b95 Remove the old vtable layout code.
llvm-svn: 99869
2010-03-30 03:43:47 +00:00
Nick Lewycky 3cfe6af8b5 Implement new mangling for vectors.
llvm-svn: 99616
2010-03-26 07:18:04 +00:00
Anders Carlsson cd836f0b5f More thunks scaffolding.
llvm-svn: 99294
2010-03-23 17:17:29 +00:00
Rafael Espindola cd7eef900f Correctly mangle dependent TypenameType.
Fixes PR6625.

llvm-svn: 98707
2010-03-17 04:28:11 +00:00
Kovarththanan Rajaratnam ba2c65277a Use SmallString instead of SmallVector
llvm-svn: 98436
2010-03-13 10:17:05 +00:00
Rafael Espindola 4d5c3d99e5 Correctly mangle address of member in template arguments. Fixes PR6460
llvm-svn: 98254
2010-03-11 14:07:00 +00:00
Douglas Gregor 577cf97cf3 Don't turn off mangling in implicitly extern "C" system headers. GCC
doesn't do this on any of the major platforms, and we don't really
support any of the platforms that do (nor will we actually handle
those headers well). Fixes PR6217; see PR6530 for details on what we
would need to do to support these platforms.

llvm-svn: 97899
2010-03-07 05:10:40 +00:00
Fariborz Jahanian 9eba9dfb0c Refactor local class name mangling and make it
ABI conforming.

llvm-svn: 97702
2010-03-04 01:02:03 +00:00
Fariborz Jahanian a529c25555 Implements mangling of local class names to
fix a code gen crash. This is WIP as not
all ABI cases are covered (there is a FIXME to 
this effect). Fixes radar 7696748.

llvm-svn: 97658
2010-03-03 19:41:08 +00:00
John McCall bd8d9bd39c Split out types that are non-canonical unless dependent as their own
category.  Use this in a few places to eliminate unnecessary TST cases and
do some future-proofing.  Provide terrible manglings for typeof.  Mangle
decltype with some hope of accuracy.

Our manglings for some of the cases covered in the testcase are different
from gcc's, which I've raised as an issue with the ABI list.

llvm-svn: 97523
2010-03-01 23:49:17 +00:00
John McCall de9607bc6f The latest draft uses 'dt' to mangle member expressions, and now so do we.
llvm-svn: 97479
2010-03-01 19:12:25 +00:00
Douglas Gregor a51c67424e Improve name mangling for dependently-scoped declaration references.
llvm-svn: 97422
2010-02-28 22:05:49 +00:00
Douglas Gregor 5610db6923 Add name mangling for DeclRefExprs that refer to external names
llvm-svn: 97418
2010-02-28 21:40:32 +00:00
Eli Friedman 1e6bc133ce Make previous fix handle a few more edge cases.
llvm-svn: 96962
2010-02-23 18:25:09 +00:00
Eli Friedman ad5f0789f6 PR6400: Handle an extreme edge case in mangling correctly.
llvm-svn: 96961
2010-02-23 18:20:18 +00:00
Anders Carlsson 2c4de4c31e Only append 'L' for internal variable declarations, not all declarations. (Found by the mangle checker, yay)
llvm-svn: 95485
2010-02-06 04:52:27 +00:00
Douglas Gregor cae03b1e6d Assert when we try to mangle a dependent template name, rather than
crashing unceremoniously.

llvm-svn: 95464
2010-02-06 01:09:36 +00:00
Douglas Gregor a16b0cae9a Implement name mangling for template template parameters
llvm-svn: 95427
2010-02-05 20:45:00 +00:00
Anders Carlsson c6eec40189 Check in a mangle checker that's turned off by default.
llvm-svn: 95377
2010-02-05 07:31:37 +00:00
John McCall d061b4429e Mangle member expressions. Also invented.
llvm-svn: 95284
2010-02-04 02:56:29 +00:00
John McCall 11ef09f8b5 Add a cautionary note about the mangling I just invented.
llvm-svn: 95275
2010-02-04 01:48:38 +00:00
John McCall 09de8ecd88 Add mangling support for calls, sizeof/alignof, constructor calls,
float literals, and unresolved lookups (which required hand-wavey extensions).

llvm-svn: 95273
2010-02-04 01:42:13 +00:00
Douglas Gregor 7dc5c17d92 When a function or variable somehow depends on a type or declaration
that is in an anonymous namespace, give that function or variable
internal linkage.

This change models an oddity of the C++ standard, where names declared
in an anonymous namespace have external linkage but, because anonymous
namespace are really "uniquely-named" namespaces, the names cannot be
referenced from other translation units. That means that they have
external linkage for semantic analysis, but the only sensible
implementation for code generation is to give them internal
linkage. We now model this notion via the UniqueExternalLinkage
linkage type. There are several changes here:

  - Extended NamedDecl::getLinkage() to produce UniqueExternalLinkage
    when the declaration is in an anonymous namespace.
  - Added Type::getLinkage() to determine the linkage of a type, which
    is defined as the minimum linkage of the types (when we're dealing
    with a compound type that is not a struct/class/union).
  - Extended NamedDecl::getLinkage() to consider the linkage of the
    template arguments and template parameters of function template
    specializations and class template specializations.
  - Taught code generation to rely on NamedDecl::getLinkage() when
    determining the linkage of variables and functions, also
    considering the linkage of the types of those variables and
    functions (C++ only). Map UniqueExternalLinkage to internal
    linkage, taking out the explicit checks for
    isInAnonymousNamespace().

This fixes much of PR5792, which, as discovered by Anders Carlsson, is
actually the reason behind the pass-manager assertion that causes the
majority of clang-on-clang regression test failures. With this fix,
Clang-built-Clang+LLVM passes 88% of its regression tests (up from
67%). The specific numbers are:

LLVM:
  Expected Passes    : 4006
  Expected Failures  : 32
  Unsupported Tests  : 40
  Unexpected Failures: 736

Clang:
  Expected Passes    : 1903
  Expected Failures  : 14
  Unexpected Failures: 75

Overall:
  Expected Passes    : 5909
  Expected Failures  : 46
  Unsupported Tests  : 40
  Unexpected Failures: 811

Still to do:
  - Improve testing
  - Check whether we should allow the presence of types with
  InternalLinkage (in addition to UniqueExternalLinkage) given
  variables/functions internal linkage in C++, as mentioned in
  PR5792. 
  - Determine how expensive the getLinkage() calls are in practice;
  consider caching the result in NamedDecl.
  - Assess the feasibility of Chris's idea in comment #1 of PR5792.

llvm-svn: 95216
2010-02-03 09:33:45 +00:00
John McCall 2adddcae7e Remove abstract expression kinds from the StmtClass enum. Update a few users
appropriately.  Call out a few missing cases in the expression mangler.

llvm-svn: 95176
2010-02-03 00:55:45 +00:00
Douglas Gregor 16810ca647 Name mangling for cast expressions, from Matthias Schiffer! Fixes PR5876.
llvm-svn: 94811
2010-01-29 16:37:09 +00:00
Alexis Hunt aecc45cb3c Mangle static variables with an extra name to distinguish them from non-static variables in the same TU.
Fixes PR5966 for real this time; also reverts r92911, which had a incorrect fix.

llvm-svn: 94352
2010-01-24 03:04:27 +00:00
Nuno Lopes 950d5b2cd3 fix PR5869: mangle static symbols like gcc does to make it easier to diff symbol tables
llvm-svn: 92911
2010-01-07 09:36:51 +00:00
Anders Carlsson 88ea2455f8 Get rid of FixedWidthIntType, as suggested by Chris and Eli.
llvm-svn: 92246
2009-12-29 07:07:36 +00:00
Anders Carlsson a88d197284 Mangle block pointer types. Fixes PR5858.
llvm-svn: 92069
2009-12-23 22:31:44 +00:00
Douglas Gregor 247894b361 There is no such thing as typeinfo for a cv-qualified type. Assert
that this is true when mangling, then fix up the various places in
Sema and/or CodeGen that need to remove qualifiers. Addresses a
linking issue when building LLVM with Clang.

llvm-svn: 92064
2009-12-23 22:04:40 +00:00
Anders Carlsson 910847c149 Mangle template template parameters. Fixes PR5861.
llvm-svn: 92030
2009-12-23 19:30:55 +00:00
Anders Carlsson 8a35c7982c Make sure that we mangle overloaded operators that are member functions correctly, giving them the correct arity.
With this seemingly insignificant fix, we are now able to build and link clang using clang itself! (LLVM still has to be built with gcc for the time being).

llvm-svn: 91893
2009-12-22 06:36:32 +00:00