Commit Graph

1285 Commits

Author SHA1 Message Date
Eli Friedman a526f275e3 Whack a bunch of tests in CodeGenCXX to work on ARM (using ARM ABI). Batch 1 of 3 or so.
llvm-svn: 132945
2011-06-13 22:51:21 +00:00
Richard Smith 938f40b5aa Implement support for C++11 in-class initialization of non-static data members.
llvm-svn: 132878
2011-06-11 17:19:42 +00:00
Eli Friedman 300f55dcad PR10120: Make CodeGenModule::getVTableLinkage use NamedDecl::getLinkage to determine whether the vtable should be externally visible, instead of a rough approximation of it which messes up with templates.
While I'm here, zap the other user of isInAnonymousNamespace outside of Decl.cpp.

llvm-svn: 132861
2011-06-10 21:53:06 +00:00
Douglas Gregor c507db4f70 Add name mangling for expr .* expr. Fixes PR9983 / <rdar://problem/9486332>.
llvm-svn: 132659
2011-06-05 05:27:58 +00:00
Galina Kistanova a6faf8e28b These tests require particular registered targets. Declared as such.
llvm-svn: 132623
2011-06-04 04:38:16 +00:00
Galina Kistanova f56b4f6fdd These tests require particular registered targets. Declared as such.
llvm-svn: 132600
2011-06-03 22:24:54 +00:00
Devang Patel 2780e4545a List c++ class type as public type in dwarf debug info output.
llvm-svn: 132357
2011-05-31 20:46:46 +00:00
Chandler Carruth e54ff6cc3e Expand the coverage of the warning for constants on the RHS of logical operands:
return f() || -1;

where the user meant to write '|'.

This bootstraps without any additional warnings.

Patch by Richard Trieu.

llvm-svn: 132327
2011-05-31 05:41:42 +00:00
John McCall 9b382dde92 Convert Clang over to resuming from landing pads with llvm.eh.resume.
It's quite likely that this will explode, but I need to know how. :)

llvm-svn: 132269
2011-05-28 21:13:02 +00:00
Eli Friedman 380b8dad6b Back out r132209; it's breaking nightly tests.
llvm-svn: 132219
2011-05-27 21:32:17 +00:00
John McCall 63fb333fa4 Implement a new, much improved version of the cleanup hack. We just need
to be careful to emit landing pads that are always prepared to handle a
cleanup path.  This is correct mostly because of the fix to the LLVM
inliner, r132200.

llvm-svn: 132209
2011-05-27 20:01:14 +00:00
Chandler Carruth 7c430c0ec2 Enhance Clang to start instantiating static data member definitions
within class templates when they are necessary to complete the type of
the member. The canonical example is code like:

  template <typename T> struct S {
    static const int arr[];
    static const int x;
    static int f();
  };

  template <typename T> const int S<T>::arr[] = { 1, 2, 3 };
  template <typename T> const int S<T>::x = sizeof(arr) / sizeof(arr[0]);
  template <typename T> int S<T>::f() { return x; }

  int x = S<int>::f();

We need to instantiate S<T>::arr's definition to pick up its initializer
and complete the array type. This involves new code to specially handle
completing the type of an expression where the type alone is
insufficient. It also requires *updating* the expression with the newly
completed type. Fortunately, all the other infrastructure is already in
Clang to do the instantiation, do the completion, and prune out the
unused bits of code that result from this instantiation.

This addresses the initial bug in PR10001, and will be a step to
fleshing out other cases where we need to work harder to complete an
expression's type. Who knew we still had missing C++03 "features"?

llvm-svn: 132172
2011-05-27 01:33:31 +00:00
Alexis Hunt 6a31f2c7c9 Delete the extraneous return statement that was causing my earlier
issues and also add a test.

We should now handle defaulted members of templates properly. No
comment as to whether or not this also holds for templated functions,
but defaulting those is kind of insane.

llvm-svn: 131938
2011-05-23 23:56:01 +00:00
Alexis Hunt 1fb4e76218 Correctly propagate defaultedness across template instantiation. This
fixes PR9965, but we're not out of the water yet, as we do not
successfully handle out-of-line definitions, due to my utter
misunderstanding of how we manage templates.

llvm-svn: 131920
2011-05-23 21:07:59 +00:00
Chris Lattner e76b95ae15 make the x86-32 backend specify a byval alignment, even when the
code generator will do it.  With this patch, clang compiles the example
in PR9794 to not have an alloca temporary.

llvm-svn: 131881
2011-05-22 23:35:00 +00:00
Douglas Gregor 347e0f26be Fix our handling of the warning when one tries to pass a
non-POD/non-trivial object throuugh a C-style varargs. The warning
itself was default-mapped to error, but can be downgraded, but we were
treating it in Sema like a hard error, silently dropping the call.

Instead, treat this problem like a warning, and do what the warning
says we do: abort at runtime. To do so, we fake up a __builtin_trap()
expression that gets evaluated as part of the argument.

llvm-svn: 131805
2011-05-21 19:26:31 +00:00
Douglas Gregor 6ab2fa8f78 Introduce Type::isSignedIntegerOrEnumerationType() and
Type::isUnsignedIntegerOrEnumerationType(), which are like
Type::isSignedIntegerType() and Type::isUnsignedIntegerType() but also
consider the underlying type of a C++0x scoped enumeration type.

Audited all callers to the existing functions, switching those that
need to also handle scoped enumeration types (e.g., those that deal
with constant values) over to the new functions. Fixes PR9923 /
<rdar://problem/9447851>.

llvm-svn: 131735
2011-05-20 16:38:50 +00:00
Sebastian Redl 623ea82a6b Reapply r121528, fixing PR9941 by delaying the exception specification check for destructors until the class is complete and destructors have been adjusted.
llvm-svn: 131632
2011-05-19 05:13:44 +00:00
Alexis Hunt d0cdd1fab1 Revert r121528 as it breaks a simple testcase, which leads to, among
other things, libcxx not building.

llvm-svn: 131573
2011-05-18 20:57:11 +00:00
Sebastian Redl b900f04ccc Implement implicit exception specifications of destructors.
llvm-svn: 131528
2011-05-18 05:20:56 +00:00
John McCall 3597b6340c Revert r131434, my commit disabling the complete-object constructor
optimization for abstract classes;  there was a misunderstanding, and
it turns out that there are no kexts which rely on this.

llvm-svn: 131489
2011-05-17 21:05:49 +00:00
Ted Kremenek c249c411c2 Fix crash on C++ code when compiling with -finstrument-functions.
llvm-svn: 131435
2011-05-16 23:49:20 +00:00
John McCall 2ccfe89b3e Emit complete-object constructors for abstract classes in kext mode for
reasons that honestly really, really need to be looked into.

llvm-svn: 131434
2011-05-16 23:34:46 +00:00
Anders Carlsson d6f1518cc9 Fix another regression from the "skip vtable pointer initialization"
optimization. Make sure to require a vtable when trying to get the address
of a VTT, otherwise we would never end up emitting the VTT.

llvm-svn: 131400
2011-05-16 04:08:36 +00:00
John McCall 7ec4b4342c Don't actually emit calls to the reserved global placement new and delete
operators;  their semantics are guaranteed by the language.

If someone wants to argue that freestanding compiles shouldn't recognize
this, I might be convinceable.

llvm-svn: 131395
2011-05-16 01:05:12 +00:00
Anders Carlsson 49c0bd2a25 Re-enable the fix for PR9181 now that all the edge cases are handled.
llvm-svn: 131385
2011-05-15 17:36:21 +00:00
John McCall 036f2f6b35 The array-size operand to a new-expression is not necessarily a size_t.
It can be larger, it can be smaller, it can be signed, whatever.  Handle
all the crazy cases with grace and spirit.

llvm-svn: 131378
2011-05-15 07:14:44 +00:00
Anders Carlsson b55c8c127e Disable the optimization until the bug noticed by Sean Hunt has been fixed.
llvm-svn: 131372
2011-05-15 01:50:14 +00:00
Anders Carlsson 9bd7d16440 When emitting the destructor for a class with a vtable, if we can determine
that the destructor body is trivial and that all member variables also have either
trivial destructors or trivial destructor bodies, we don't need to initialize the
vtable pointers since no virtual member functions will be called on the destructor.

Fixes PR9181.

llvm-svn: 131368
2011-05-14 23:26:09 +00:00
Douglas Gregor 61226d3fcf When determining whether we can make a declaration into a global
constant, also consider whether it's a class type that has any mutable
fields. If so, it can't be a global constant.

llvm-svn: 131276
2011-05-13 01:05:07 +00:00
Anders Carlsson cc53197903 Don't emit complete constructors for abstract classes. Also, don't emit
complete destructors for abstract classes unless the destructor is virtual
and thus needs to be in the vtable.

llvm-svn: 131068
2011-05-08 17:25:05 +00:00
Douglas Gregor 2d1c055eba In C++, allow us to emit a global as 'constant' even if it has class
type, so long as it is known to have a constant initializer and the
class type is a POD class. Fixes <rdar://problem/9306265>.

llvm-svn: 131060
2011-05-07 22:06:45 +00:00
Eli Friedman 49a94b1c7c Add an implementation of thunks for varargs methods. The implementation is a bit messy, but it is correct as long as the method in question doesn't use indirect gotos. A couple of possible alternative implementations are outlined in FIXME's in this patch. rdar://problem/8077308 .
llvm-svn: 130993
2011-05-06 17:27:27 +00:00
Richard Smith 3f1b5d077b Implement support for C++0x alias templates.
llvm-svn: 130953
2011-05-05 21:57:07 +00:00
John McCall 3ab847648f Type prefixes of unresolved-names should only be mangled as unresolved-types
if they match that production, i.e. if they're template type parameters
or decltypes (or, as an obvious case not yet described in the ABI document,
if they're template template parameters applied to template arguments).

llvm-svn: 130824
2011-05-04 01:45:19 +00:00
Alexis Hunt f9b554bef9 Fix the delegating constructors test to not rely on basic block names.
llvm-svn: 130813
2011-05-04 00:59:33 +00:00
Alexis Hunt 9d47faf686 Ensure that destructors are properly inovked when an exception leaves
the body of a delegating constructor call.

This means that the delegating constructor implementation should be
complete and correct, though there are some rough edges (diagnostic
quality with the cycle detection and using a deleted destructor).

llvm-svn: 130803
2011-05-03 23:05:34 +00:00
NAKAMURA Takumi bb9ffbdc89 test/CodeGenCXX/vtable-debug-info.cpp: It does not crash on mingw.
FIXME: It would crash with -integrated-as. Implement -g on MCCOFF.
llvm-svn: 130682
2011-05-02 04:50:00 +00:00
NAKAMURA Takumi 0760218bca test/CodeGenCXX/debug-info-namespace.cpp: Add explicit -fverbose-asm to cc1 to let cygming pass.
This test seeks a verbose comment in output. By default, "-integrated-as" sets verbose-asm. Cygming is not ready for -integrated-as yet.

llvm-svn: 130681
2011-05-02 04:49:53 +00:00
John McCall 8fb0d9d24a Store a parameter index and function prototype depth in every
parameter node and use this to correctly mangle parameter
references in function template signatures.

A follow-up patch will improve the storage usage of these
fields;  here I've just done the lazy thing.

llvm-svn: 130669
2011-05-01 22:35:37 +00:00
Alexis Hunt 61bc173784 Fully implement delegating constructors!
As far as I know, this implementation is complete but might be missing a
few optimizations. Exceptions and virtual bases are handled correctly.

Because I'm an optimist, the web page has appropriately been updated. If
I'm wrong, feel free to downgrade its support categories.

llvm-svn: 130642
2011-05-01 07:04:31 +00:00
Argyrios Kyrtzidis 03535265ef Cut down unnecessary zero'ing when value-initializing arrays of C++ objects.
-C++ objects with user-declared constructor don't need zero'ing.
-We can zero-initialize arrays of C++ objects in "bulk" now, in which case don't zero-initialize each object again.

llvm-svn: 130453
2011-04-28 22:57:55 +00:00
Argyrios Kyrtzidis e07425a5e7 When value-initializing the elements of an array not not included in the initializer make sure
that a non-trivial C++ constructor gets called.

Fixes rdar://9347552 & http://llvm.org/PR9801

llvm-svn: 130421
2011-04-28 18:53:58 +00:00
John McCall 7f0a0d55c0 Implement the mangling for non-ADL call expressions that we just
worked out.

llvm-svn: 130376
2011-04-28 02:52:03 +00:00
John McCall a85af56e66 When block-capturing a variable with a non-trivial destructor,
make sure to mark the destructor.  This normally isn't required,
because the destructor should have been marked as part of the
declaration of the local, but it's necessary when the variable
is a parameter because it's the call sites that are responsible
for those destructors.

llvm-svn: 130372
2011-04-28 02:15:35 +00:00
John Wiegley 65497cce20 t/clang/type-traits
Patch authored by John Wiegley.

These type traits are used for parsing code that employs certain features of
the Embarcadero C++ compiler.  Several of these constructs are also desired by
libc++, according to its project pages (such as __is_standard_layout).

llvm-svn: 130342
2011-04-27 23:09:49 +00:00
Anders Carlsson c5d3ba1aad When compiling with -fno-threadsafe-statics, guard variables for globals with internal linkage don't have to be i64, i8 works just fine!
llvm-svn: 130286
2011-04-27 04:37:08 +00:00
John McCall 617339e692 GCC seems to create address-of expression manglings when passing *any*
function as a template argument where a pointer to function is wanted.
Just extend the existing hack.

llvm-svn: 130084
2011-04-24 08:43:07 +00:00
John McCall 6dc0a2b467 Update the mangler for some of the "new" unresolved-name manglings.
I've sent off an email requesting clarification on a few things that
I wasn't sure how to handle.

This also necessitated making prefixes and unresolved-prefixes get
mangled separately.

llvm-svn: 130083
2011-04-24 08:23:24 +00:00
John McCall d8d1e2ae66 The ABI settled on mangling float literals with lowercase hex dumps.
APInt::toString doesn't do those, but it's easy to postprocess that output,
and that's probably better than adding another knob to that method.

llvm-svn: 130081
2011-04-24 03:07:16 +00:00