Commit Graph

1668 Commits

Author SHA1 Message Date
John McCall c7c96d5ea3 Restructure some of the member-pointer tests, implicitly
removing some that were added without a triple (and moving
their tests into files that appropriately test multiple
architectures).

llvm-svn: 155920
2012-05-01 17:32:20 +00:00
NAKAMURA Takumi 4ad81df818 clang/test/CodeGenCXX: Fix two tests, destructors.cpp and microsoft-abi-array-cookies.cpp, for -Asserts.
llvm-svn: 155913
2012-05-01 11:13:04 +00:00
John McCall c84ed6a336 Abstract the emission of global destructors into ABI-specific code
and only consider using __cxa_atexit in the Itanium logic.  The
default logic is to use atexit().

Emit "guarded" initializers in Microsoft mode unconditionally.
This is definitely not correct, but it's closer to correct than
just not emitting the initializer.

Based on a patch by Timur Iskhodzhanov!

llvm-svn: 155894
2012-05-01 06:13:13 +00:00
David Blaikie 7afed5e5bf PR12710 - broken default argument handling for templates.
I broke this in r155838 by not actually instantiating non-dependent default arg
expressions. The motivation for that change was to avoid producing duplicate
conversion warnings for such default args (we produce them once when we parse
the template - there's no need to produce them at each instantiation) but
without actually instantiating the default arg, things break in weird ways.

Technically, I think we could still get the right diagnostic experience without
the bugs if we instantiated the non-dependent args (for non-dependent params
only) immediately, rather than lazily. But I'm not sure if such a refactoring/
change would be desirable so here's the conservative fix for now.

llvm-svn: 155893
2012-05-01 06:05:57 +00:00
John McCall 7f0245d930 Remove some not-very-stable assumptions from this testcase.
llvm-svn: 155889
2012-05-01 05:29:32 +00:00
John McCall b91cd6687c Refactor the C++ ABI code a little bit to take advantage of
what I'm going to treat as basically universal properties of
array-cookie code.  Implement MS array cookies on top of that.
Based on a patch by Timur Iskhodzhanov!

llvm-svn: 155886
2012-05-01 05:23:51 +00:00
John McCall 23dfaa1cef When mangling a synthetic function declaration, we might not have
type-source information for its parameters.  Don't crash when
mangling them in the MS C++ ABI.  Patch by Timur Iskhodzhanov!

llvm-svn: 155879
2012-05-01 02:33:44 +00:00
Richard Smith d494c500a0 PR12224 (sort of): Diagnose inheriting constructor declarations in C++11 mode.
We do not support IRGen for these, and get some parts of the semantic analysis
wrong.

llvm-svn: 155728
2012-04-27 19:33:05 +00:00
Eli Friedman f927b8bc81 Add a missing check in CodeGen of packed classes with vtables. <rdar://problem/11324125>.
llvm-svn: 155689
2012-04-27 02:34:46 +00:00
Eric Christopher 3cc207bbcc Forward declarations should take a context. This helps the debugger
find forward declarations in the context that the actual definition
will occur.

rdar://11291658

llvm-svn: 155381
2012-04-23 19:00:24 +00:00
Rafael Espindola b522a5f246 Fix visibility when we have two types with explicit visibility in a template
argument list.

llvm-svn: 155368
2012-04-23 17:51:55 +00:00
Rafael Espindola 23fd21d4ee Add another testcase that was not being covered.
llvm-svn: 155351
2012-04-23 14:02:53 +00:00
Rafael Espindola cba4879534 Add a testcase that we already get right but was not being tested. Found
by a chrome build on OS X. Thanks to Nico Weber for testing a patch and
providing the .ii file.

llvm-svn: 155326
2012-04-22 22:31:25 +00:00
Rafael Espindola 1e762442c7 Cleanup testcase.
llvm-svn: 155317
2012-04-22 16:03:00 +00:00
Rafael Espindola bbc5cbc410 An attribute in a explicit template installation should take precedence over
the tempale arguments in deciding the visibility.

This agrees with gcc 4.7.

Found by trying to build chrome with component=shared_library with 155314
reverted.

llvm-svn: 155316
2012-04-22 15:31:59 +00:00
Rafael Espindola 6b6e879221 Revert 155102 but add a fixme while I debug what is wrong with chrome's
components build.

llvm-svn: 155314
2012-04-22 12:37:27 +00:00
Richard Smith f3c37e89a1 PR12571: Objects of type clang::ConstantArrayType aren't always emitted with
type llvm::ArrayType -- sometimes we emit them as packed structs. Don't assert
if such a global array has an element type with a non-trivial destructor.

llvm-svn: 155305
2012-04-22 05:51:36 +00:00
Rafael Espindola fae3f908d8 Add another missing testcase.
llvm-svn: 155304
2012-04-22 02:41:22 +00:00
Rafael Espindola 4304101fb2 Add a testcase we were already getting right, but were not testing for.
llvm-svn: 155302
2012-04-22 01:22:25 +00:00
Rafael Espindola 8add48ec9e Fix handling of template parameters. Found by inspection. GCC 4.7 agrees
with this testcase.

llvm-svn: 155301
2012-04-22 00:43:48 +00:00
Timur Iskhodzhanov f32a377a7c Fix bug 12574 - Avoid infinite recursion in constructors and destructors when using Microsoft C++ ABI
llvm-svn: 155189
2012-04-20 08:05:00 +00:00
Rafael Espindola 53cf219367 In mergeVisibility, if we already have an explicit visibility, keep it.
This fixes the included testcase and lets us simplify the code a bit. It
does require using mergeWithMin when merging class information to its
members. Expand the comments to explain why that works.

llvm-svn: 155103
2012-04-19 05:50:08 +00:00
Rafael Espindola 1280fe6245 In mergeVisibilityWithMin, let an implicit hidden symbol take precedence over
an explicit default one. This means that with -fvisibility hidden we
now produce a hidden symbol for

template <typename T>
class DEFAULT foo {
  void bar() {}
};
class zed {};
template class foo<zed>;

This matches the behaviour of gcc 4.7.

llvm-svn: 155102
2012-04-19 05:34:51 +00:00
Richard Smith d372942d77 PR 12586: Fix assert while running libc++ testsuite: deal with exception
specifications on member function templates of class templates and other such
nested beasties. Store the function template from which we are to instantiate
an exception specification rather than trying to deduce it. Plus some
additional test cases.

llvm-svn: 155076
2012-04-19 00:08:28 +00:00
Richard Smith 79a52e5709 PR12569: Instantiate exception specifications of explicit instantiations
and explicit specializations of function templates appropriately.

llvm-svn: 154956
2012-04-17 22:30:01 +00:00
Richard Smith f623c96260 Implement DR1330 in C++11 mode, to support libstdc++4.7 which uses it.
We have a new flavor of exception specification, EST_Uninstantiated. A function
type with this exception specification carries a pointer to a FunctionDecl, and
the exception specification for that FunctionDecl is instantiated (if needed)
and used in the place of the function type's exception specification.

When a function template declaration with a non-trivial exception specification
is instantiated, the specialization's exception specification is set to this
new 'uninstantiated' kind rather than being instantiated immediately.

Expr::CanThrow has migrated onto Sema, so it can instantiate exception specs
on-demand. Also, any odr-use of a function triggers the instantiation of its
exception specification (the exception specification could be needed by IRGen).
In passing, fix two places where a DeclRefExpr was created but the corresponding
function was not actually marked odr-used. We used to get away with this, but
don't any more.

Also fix a bug where instantiating an exception specification which refers to
function parameters resulted in a crash. We still have the same bug in default
arguments, which I'll be looking into next.

This, plus a tiny patch to fix libstdc++'s common_type, is enough for clang to
parse (and, in very limited testing, support) all of libstdc++4.7's standard
headers.

llvm-svn: 154886
2012-04-17 00:58:00 +00:00
Rafael Espindola 78158af59c Revert r154749 for now at John McCall's request.
llvm-svn: 154846
2012-04-16 18:46:26 +00:00
Douglas Gregor 3024f07c12 Implement C++11 [expr.prim.general]p3, which permits the use of 'this'
in the declaration of a non-static member function after the
(optional) cv-qualifier-seq, which in practice means in the exception
specification and late-specified return type. 

The new scheme here used to manage 'this' outside of a member function
scope is more general than the Scope-based mechanism previously used
for non-static data member initializers and late-parsesd attributes,
because it can also handle the cv-qualifiers on the member
function. Note, however, that a separate pass is required for static
member functions to determine whether 'this' was used, because we
might not know that we have a static function until after declaration
matching.

Finally, this introduces name mangling for 'this' and for the implicit
'this', which is intended to match GCC's mangling. Independent
verification for the new mangling test case would be appreciated.

Fixes PR10036 and PR12450.

llvm-svn: 154799
2012-04-16 07:05:22 +00:00
Richard Smith 9ec1e48b59 PR12226: don't generate wrong code if a braced string literal is used to
initialize an array of unsigned char. Outside C++11 mode, this bug was benign,
and just resulted in us emitting a constant which was double the required
length, padded with 0s. In C++11, it resulted in us generating an array whose
first element was something like  i8 ptrtoint ([n x i8]* @str to i8).

llvm-svn: 154756
2012-04-15 02:50:59 +00:00
Rafael Espindola 0aec8ece52 Consider visibility attributes last, so that they take precedence.
I am working on a cleaner fix, but this gets the case in PR12552 passing.

llvm-svn: 154749
2012-04-14 15:21:19 +00:00
John McCall 8c38d35b05 Don't enter cleanups for unreachable variables. It's impossible to
jump into these scopes, and the cleanup-entering code sometimes wants
to do some operations first (e.g. a GEP), which can leave us with
unparented IR.

llvm-svn: 154684
2012-04-13 18:44:05 +00:00
John McCall 32233a7c1a Fix a trivial oversight with apple-kext static local destructors
and add a test case.

llvm-svn: 154653
2012-04-13 02:53:27 +00:00
Douglas Gregor 298f43df14 Fix some i1/i8 confusion within _Atomic(bool) in IR generation, both
in general (such an atomic has boolean representation) and
specifically for IR generation of __c11_atomic_init. The latter also
means actually using initialization semantics for this initialization,
rather than just creating a store.

On a related note, make sure we actually put in non-atomic-to-atomic
conversions when performing an implicit conversion sequence. IR
generation is far too kind here, but we still want the ASTs to make
sense.

llvm-svn: 154612
2012-04-12 20:42:30 +00:00
Eric Christopher 5d7fe46ceb Testcase for previous commit.
rdar://11079003

llvm-svn: 154571
2012-04-12 00:36:10 +00:00
Richard Smith be646db000 Update recently-added test to use new __c11_ form of atomic builtins.
llvm-svn: 154514
2012-04-11 18:00:46 +00:00
David Chisnall eb9496efc7 Make __atomic_init() (soon to be __c11_atomic_init()) work with non-scalar types.
llvm-svn: 154507
2012-04-11 17:24:05 +00:00
David Chisnall 28397be059 Allow c++ initialisers to initialise _Atomic fields.
llvm-svn: 154499
2012-04-11 15:29:15 +00:00
Douglas Gregor 11a434ab2e Improve the printing of __PRETTY_FUNCTION__ more provide more
information and more closely match GCC's, from Nikola Smiljanic!

llvm-svn: 154430
2012-04-10 20:14:15 +00:00
Richard Smith 4051ff7650 Don't forget to evaluate the subexpression in a null pointer cast. If we're
converting from std::nullptr_t, the subexpression might have side-effects.

llvm-svn: 154278
2012-04-08 08:02:07 +00:00
Douglas Gregor 31f55dced5 Implement support for null non-type template arguments for non-type
template parameters of pointer, pointer-to-member, or nullptr_t
type in C++11. Fixes PR9700 / <rdar://problem/11193097>.

llvm-svn: 154219
2012-04-06 22:40:38 +00:00
John McCall 76cc43a2a4 Use atexit when __cxa_atexit isn't available instead of adding a
global destructor entry.  For some reason this isn't enabled for
apple-kexts;  it'd be good to have documentation for that.

Based on a patch by Nakamura Takumi!

llvm-svn: 154191
2012-04-06 18:21:06 +00:00
Richard Smith 9380e0ea23 Implement C++11 [temp.arg.nontype]'s permission to use the address of an object
or function with internal linkage as a non-type template argument.

llvm-svn: 154053
2012-04-04 21:11:30 +00:00
Douglas Gregor b61e809b42 Move the computation of the lambda mangling information (mangling
number + context) to the point where we initially start defining the
lambda, so that the linkage won't change when that information is made
available. Fixes the assertion in <rdar://problem/11182962>.

Plus, actually mangle the context of lambdas properly.

llvm-svn: 154029
2012-04-04 17:40:10 +00:00
David Chisnall 5221a947a5 Don't crash (assert failure) when generating blocks for C++ types with a non-const copy constructor.
This was caused by the code deciding the number of fields in the byref structure using a different test to the part of the code creating the GEPs into said structure.  

llvm-svn: 154013
2012-04-04 13:07:13 +00:00
Eric Christopher b7e821a6aa Change location information for synthesized properties to be at the
property file/line rather than the @synthesize file/line. Avoids
some nasty confusing-ness with conflating the file from the scope
and the line from the original declaration. Use    the current scope
location as a separate parameter so that we can    match it up
better in the line table with the beginning of the scope.

Update a couple of testcases accordingly since I had to change
that we actually use the passed in location in EmitFunctionStart
and for the new metadata parameter and add a new testcase to
make sure we've got the right line numbers for synthesized
properties.

Part of rdar://11026482

llvm-svn: 153917
2012-04-03 00:44:15 +00:00
John McCall b88a566cc1 Make sure we unique static-local decls across multiple emissions of
the function body, but do so in a way that doesn't make any assumptions
about the static local actually having a proper, unique mangling,
since apparently we don't do that correctly at all.

llvm-svn: 153776
2012-03-30 21:00:39 +00:00
Chandler Carruth 8453795255 Revert r153723, and its follow-ups r153728 and r153733.
These patches cause us to miscompile and/or reject code with static
function-local variables in an extern-C context. Previously, we were
papering over this as long as the variables are within the same
translation unit, and had not seen any failures in the wild. We still
need a proper fix, which involves mangling static locals inside of an
extern-C block (as GCC already does), but this patch causes pretty
widespread regressions. Firefox, and many other applications no longer
build.

Lots of test cases have been posted to the list in response to this
commit, so there should be no problem reproducing the issues.

llvm-svn: 153768
2012-03-30 19:44:53 +00:00
John McCall 87590e60c0 Do the static-locals thing properly in the face of unions and
other things which might mess with the variable's type.

llvm-svn: 153733
2012-03-30 07:09:50 +00:00
John McCall 947c1830e4 When emitting a static local variable in C++, handle
the case that the variable already exists.  Partly this is just
protection against people making crazy declarations with custom
asm labels or extern "C" names that intentionally collide with
the manglings of such variables, but the main reason is that we
can actually emit a static local variable twice with the
requirement that it match up.  There may be other cases with
(e.g.) the various nested functions, but the main exemplar is
with constructor variants, where we can be forced into
double-emitting the function body under certain circumstances
like (currently) the presence of virtual bases.

llvm-svn: 153723
2012-03-30 04:25:14 +00:00
Eli Friedman a154dd5b33 ConstStructBuilder: fix offset math for base classes so it works correctly in general. Found by inspection.
llvm-svn: 153720
2012-03-30 03:55:31 +00:00