Граф коммитов

1770 Коммитов

Автор SHA1 Сообщение Дата
Chandler Carruth d964d63809 Fix non-deterministic iteration order when walking the specializations
of templates by using the newly introduce FoldingSetVector. This
preserves insertion order for all iteration of specializations.

I've also included a somewhat terrifying testcase that rapidly builds up
a large number of functions. This is enough that any system with ASLR
will have non-deterministic debug information generated for the test
case without the fix here as the debug information is generated in part
by walking these specializations.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156133 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-03 23:49:05 +00:00
John McCall 92c6c90e90 Merge x86-64-abi-sret-vs-2word-struct-param.cpp into the generic
x86_64-arguments.cpp test file and be sure to test the coerced
case as well.  Thanks to Wei-Ren Chen for bringing this test
to my attention.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156047 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-03 01:34:46 +00:00
John McCall 2a7b09db93 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).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155920 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-01 17:32:20 +00:00
NAKAMURA Takumi 287ab9fe92 clang/test/CodeGenCXX: Fix two tests, destructors.cpp and microsoft-abi-array-cookies.cpp, for -Asserts.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155913 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-01 11:13:04 +00:00
John McCall 20bb175cb8 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!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155894 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-01 06:13:13 +00:00
David Blaikie 5729672524 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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155893 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-01 06:05:57 +00:00
John McCall 2e7651dc80 Remove some not-very-stable assumptions from this testcase.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155889 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-01 05:29:32 +00:00
John McCall e2b45e2a43 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!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155886 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-01 05:23:51 +00:00
John McCall 3a8ac07956 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!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155879 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-01 02:33:44 +00:00
Richard Smith a1366cbab8 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155728 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-27 19:33:05 +00:00
Eli Friedman c8f11e9b4b Add a missing check in CodeGen of packed classes with vtables. <rdar://problem/11324125>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155689 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-27 02:34:46 +00:00
Eric Christopher 87380aaf42 Forward declarations should take a context. This helps the debugger
find forward declarations in the context that the actual definition
will occur.

rdar://11291658

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155381 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-23 19:00:24 +00:00
Rafael Espindola 923b0c9337 Fix visibility when we have two types with explicit visibility in a template
argument list.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155368 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-23 17:51:55 +00:00
Rafael Espindola 546ee6dbca Add another testcase that was not being covered.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155351 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-23 14:02:53 +00:00
Rafael Espindola a5416bd3ca 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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155326 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-22 22:31:25 +00:00
Rafael Espindola 71776efce5 Cleanup testcase.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155317 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-22 16:03:00 +00:00
Rafael Espindola f6a8b9cba4 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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155316 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-22 15:31:59 +00:00
Rafael Espindola 51183374a5 Revert 155102 but add a fixme while I debug what is wrong with chrome's
components build.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155314 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-22 12:37:27 +00:00
Richard Smith 1664d540d1 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155305 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-22 05:51:36 +00:00
Rafael Espindola a77e072634 Add another missing testcase.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155304 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-22 02:41:22 +00:00
Rafael Espindola bc356d0aa9 Add a testcase we were already getting right, but were not testing for.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155302 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-22 01:22:25 +00:00
Rafael Espindola 60115a0453 Fix handling of template parameters. Found by inspection. GCC 4.7 agrees
with this testcase.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155301 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-22 00:43:48 +00:00
Timur Iskhodzhanov 8560791791 Fix bug 12574 - Avoid infinite recursion in constructors and destructors when using Microsoft C++ ABI
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155189 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-20 08:05:00 +00:00
Rafael Espindola c7e606086a 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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155103 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-19 05:50:08 +00:00
Rafael Espindola 1c7eed7e6e 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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155102 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-19 05:34:51 +00:00
Richard Smith 13bffc532b 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155076 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-19 00:08:28 +00:00
Richard Smith 87162c2e52 PR12569: Instantiate exception specifications of explicit instantiations
and explicit specializations of function templates appropriately.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154956 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-17 22:30:01 +00:00
Richard Smith e6975e9b09 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154886 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-17 00:58:00 +00:00
Rafael Espindola e9836a27cf Revert r154749 for now at John McCall's request.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154846 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-16 18:46:26 +00:00
Douglas Gregor cefc3afac1 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154799 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-16 07:05:22 +00:00
Richard Smith fe587201fe 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).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154756 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-15 02:50:59 +00:00
Rafael Espindola 767f7c7558 Consider visibility attributes last, so that they take precedence.
I am working on a cleaner fix, but this gets the case in PR12552 passing.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154749 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-14 15:21:19 +00:00
John McCall 38baeabb25 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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154684 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-13 18:44:05 +00:00
John McCall 7444639f27 Fix a trivial oversight with apple-kext static local destructors
and add a test case.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154653 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-13 02:53:27 +00:00
Douglas Gregor 47bfcca2d6 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154612 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-12 20:42:30 +00:00
Eric Christopher 4f95f6444a Testcase for previous commit.
rdar://11079003

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154571 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-12 00:36:10 +00:00
Richard Smith 944b5623c3 Update recently-added test to use new __c11_ form of atomic builtins.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154514 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-11 18:00:46 +00:00
David Chisnall 5d70cfddc8 Make __atomic_init() (soon to be __c11_atomic_init()) work with non-scalar types.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154507 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-11 17:24:05 +00:00
David Chisnall 3a3c9b26de Allow c++ initialisers to initialise _Atomic fields.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154499 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-11 15:29:15 +00:00
Douglas Gregor abf65ce5dd Improve the printing of __PRETTY_FUNCTION__ more provide more
information and more closely match GCC's, from Nikola Smiljanic!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154430 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-10 20:14:15 +00:00
Richard Smith 49149fe0d2 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154278 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-08 08:02:07 +00:00
Douglas Gregor d2008e2c80 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>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154219 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-06 22:40:38 +00:00
John McCall 30fa3707c4 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!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154191 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-06 18:21:06 +00:00
Richard Smith b4051e7047 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154053 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-04 21:11:30 +00:00
Douglas Gregor f54486acc1 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154029 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-04 17:40:10 +00:00
David Chisnall 9595dae5f7 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.  



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154013 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-04 13:07:13 +00:00
Eric Christopher ea32047660 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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153917 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-03 00:44:15 +00:00
John McCall 355bba72ca 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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153776 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-30 21:00:39 +00:00
Chandler Carruth 0f30a12ce7 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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153768 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-30 19:44:53 +00:00
John McCall 49d26d2817 Do the static-locals thing properly in the face of unions and
other things which might mess with the variable's type.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153733 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-30 07:09:50 +00:00
John McCall 9993cc7b56 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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153723 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-30 04:25:14 +00:00
Eli Friedman 5fe61c6cb0 ConstStructBuilder: fix offset math for base classes so it works correctly in general. Found by inspection.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153720 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-30 03:55:31 +00:00
Chad Rosier 649b4a1a9b Revert r153613 as it's causing large compile-time regressions on the nightly testers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153660 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-29 17:37:10 +00:00
John McCall 57cd1b89cd When we can't prove that the target of an aggregate copy is
a complete object, the memcpy needs to use the data size of
the structure instead of its sizeof() value.  Fixes PR12204.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153613 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-28 23:30:44 +00:00
Chandler Carruth 82fe6aea40 Move the emission of strict enum range metadata behind a flag (the same
flag as GCC uses: -fstrict-enums). There is a *lot* of code making
unwarranted assumptions about the underlying type of enums, and it
doesn't seem entirely reasonable to eagerly break all of it.

Much more importantly, the current state of affairs is *very* good at
optimizing based upon this information, which causes failures that are
very distant from the actual enum. Before we push for enabling this by
default, I think we need to implement -fcatch-undefined-behavior support
for instrumenting and trapping whenever we store or load a value outside
of the range. That way we can track down the misbehaving code very
quickly.

I discussed this with Rafael, and currently the only important cases he
is aware of are the bool range-based optimizations which are staying
hard enabled. We've not seen any issue with those either, and they are
much more important for performance.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153550 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-27 23:58:37 +00:00
Rafael Espindola 74873c478f Fix copy and pasto.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153385 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-24 16:57:10 +00:00
Rafael Espindola c3f8955d7d Add back r153360 with a fix for enums that cover all the 32 bit values.
Thanks to NAKAMURA Takumi for finding it!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153383 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-24 16:50:34 +00:00
NAKAMURA Takumi 88a569a978 Revert r153360 (and r153380), "Second part of PR12251. Produce the range metadata in clang for booleans and".
For i686 targets (eg. cygwin), I saw "Range must not be empty!" in verifier.

It produces (i32)[0x80000000:0x80000000) from (uint64_t)[0xFFFFFFFF80000000ULL:0x0000000080000000ULL), for signed i32 on MDNode::Range.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153382 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-24 14:43:42 +00:00
Benjamin Kramer 539a2308a9 On i386 the alignment of i64 is 4, not 8.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153380 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-24 13:22:50 +00:00
Rafael Espindola e27af29401 Second part of PR12251. Produce the range metadata in clang for booleans and
c++ enums.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153360 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-24 00:28:06 +00:00
Chandler Carruth 8bd37f1197 Relax the FileCheck assertions in this test a touch. Previously the test
relied on an artifact of how the inliner and subsequent passes in
clang's -O3 mode happen to treat basic blocks and the labels for the
basic blocks. In my work on the inliner, and changed this fundamental
assumption, and the label that was being checked on the entry basic
block will no longer appear in opt builds. There was no reason to expect
the label to always be present anyways, much to my regret.

I've changed the test to just ensure that we return an immediate
constant. If there are intervening instructions, that's bad, but not
really that relevant to the test.

I'd love it if others have a better way of checking that a function body
contains only a 'ret' instruction that isn't dependent on whether or not
the entry block receives a label...

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153243 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-22 06:22:13 +00:00
John McCall 260a3e4370 For the annals of subtle but terrible bugs: fix a longstanding bug
in vtable layout where virtual methods inherited from virtual bases
could be assigned the same vcall adjustment slot if they shared
a name and parameter signature but differed in their
cv-qualification.  The code was already trying to handle this
case, but unfortunately used the ordinary type qualifiers
(which are always empty here) instead of the method qualifiers.
This seems like something that the API should discourage, but
I don't know how to carry that principle out in this instance.

Eliminate this function's need for an ASTContext while we're at it.

This bug affects the ABI, and fixing it brings us into accord with
the Itanium ABI (and GCC's implementation of it), but, obviously,
technically breaks full compatibility with previous releases of Clang.
Just letting you know.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153168 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-21 06:57:19 +00:00
Benjamin Kramer fce80091da Fix a use-after-free in thunk emission. EmitThunk may call RAUW on Init, invalidating the pointer.
Fixes PR12284. The test case only triggered under asan/valgrind, but it's better than nothing.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153120 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-20 20:18:13 +00:00
Benjamin Kramer 6181e56a44 Debug info: Tighten up uses of plain MDNode pointers which don't survive replaceOperandWith.
TrackingVH notices when it gets RAUW'd. Fixes PR12305 and PR12315.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153115 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-20 19:49:14 +00:00
Bill Wendling 2eb2729310 Make the storing variable's name generic.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152963 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-16 23:37:23 +00:00
Bill Wendling 08212631e1 When "low alignment" is specified, then set the alignment of the aggregate's
store to 1. This allows code-gen to select a more appropriate alignment. If left
to zero, an alignment greater than the alignment of the pointer may be selected,
causing code-gen to use instructions which require an alignment greater than the
pointer guarantees.
<rdar://problem/11043589>


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152951 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-16 21:45:12 +00:00
Eric Christopher 167174518c Add support to mangle templated member function names with template
args.

Fixes rdar://11042577

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152691 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-14 00:25:46 +00:00
Eric Christopher 3b10cfe6b8 When adding member functions to a class add any specializations of
function templates as well.

A future commit will mangle the added name with the template args
like classes are mangled.

Fixes rdar://10986010

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152683 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-13 23:40:48 +00:00
James Molloy 9cda03ff7f Ensure that default arguments are handled correctly in sub scopes. For example:
void f () {
  int g (int a, int b=4);
  {
    int g(int a, int b=5);
  }
}

should compile.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152621 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-13 08:55:35 +00:00
Rafael Espindola 2f47c366bc The type of a definition should not increase its visibility. Fixes PR12221.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152493 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-10 13:01:40 +00:00
Douglas Gregor f52757d63f Only make a call to a copy constructor elidable if in fact we are
doing a copy. Fixes PR12139.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152485 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-10 06:53:13 +00:00
John McCall dd2ecee313 Unify the BlockDeclRefExpr and DeclRefExpr paths so that
we correctly emit loads of BlockDeclRefExprs even when they
don't qualify as ODR-uses.  I think I'm adequately convinced
that BlockDeclRefExpr can die.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152479 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-10 03:05:10 +00:00
Eli Friedman 540659e102 Make sure the accessors for overridden methods don't return inherited constructors. Fixes PR12219.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152470 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-10 01:39:01 +00:00
Richard Smith 36f5cfe4df Support for raw and template forms of numeric user-defined literals,
and lots of tidying up.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152392 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-09 08:00:36 +00:00
Eli Friedman 71cba34b6e Make sure we update the static local decl address map when we are forced to rebuild a global because of the initializer. <rdar://problem/10957867>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152372 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-09 03:27:46 +00:00
Eli Friedman 8b42ab718d Make sure constant emission handles initializer lists with strings correctly. Part of <rdar://problem/10957867>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152370 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-09 03:06:56 +00:00
Rafael Espindola 4fae2d9357 Also test pr12104 with pch.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152317 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-08 15:07:42 +00:00
Richard Smith b453ad3214 Add support for cooked forms of user-defined-integer-literal and
user-defined-floating-literal. Support for raw forms of these literals
to follow.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152302 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-08 08:45:32 +00:00
Richard Smith dd66be718f User-defined literal support for character literals.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152277 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-08 01:34:56 +00:00
Richard Smith 9fcce65e7e AST representation for user-defined literals, plus just enough of semantic
analysis to make the AST representation testable. They are represented by a
new UserDefinedLiteral AST node, which is a sugared CallExpr. All semantic
properties, including full CodeGen support, are achieved for free by this
representation.

UserDefinedLiterals can never be dependent, so no custom instantiation
behavior is required. They are mangled as if they were direct calls to the
underlying literal operator. This matches g++'s apparent behavior (but not its
actual mangling, which is broken for literal-operator-ids).

User-defined *string* literals are now fully-operational, but the semantic
analysis is quite hacky and needs more work. No other forms of user-defined
literal are created yet, but the AST support for them is present.

This patch committed after midnight because we had already hit the quota for
new kinds of literal yesterday.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152211 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-07 08:35:16 +00:00
Richard Smith 946e2726f9 Don't even try to directly emit the value of a DeclRefExpr if that declaration
is not usable in a constant expression. ~2.5% speedup on 403.gcc / combine.c.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152193 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-07 01:58:44 +00:00
Sebastian Redl 2835745a45 If the element type of an initializer list has a destructor, make sure we check it. Fixes PR12178.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152048 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-05 19:35:43 +00:00
Rafael Espindola 234fe654a3 Fix a small difference in sema and codegen views of what needs to be output.
In the included testcase, soma thinks that we already have a definition after we
see the out of line decl. Codegen puts it in a deferred list, to be output if
a use is seen. This would break when we saw an explicit template instantiation
definition, since codegen would not be notified.

This patch adds a method to the consumer interface so that soma can notify
codegen that this decl is now required.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152024 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-05 10:54:55 +00:00
James Molloy b3c312ce4d Fix a bug in the mangler where in 'namespace std { extern "C" {X;} }', X would not be seen to be in ::std::.
Migrate two other places where the same logic is used to use the helper function that already exists.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152022 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-05 09:59:43 +00:00
Richard Smith ec92bc7897 Add a pile of tests for unrestricted unions, and advertise support for them.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151992 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-03 23:51:05 +00:00
Richard Smith a3ca41f0c2 Reinstate r151879, r151880, reverted in r151922, along with a bugfix for
scalar emission of DeclRefExprs to const bools: emit scalar bools as i1,
not as i8.

In addition to the extra unit testing, this has successfully bootstrapped.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151955 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-02 23:27:11 +00:00
Daniel Dunbar c169e08f3a Revert r151879, r151880, "PR12145: Avoid emitting loads of constexpr variables in contexts where there" and "Fix buildbot: make this test less dependent on the value names in the produced IR."
They broke bootstrap.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151922 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-02 16:24:25 +00:00
Richard Smith 0524171a57 Fix buildbot: make this test less dependent on the value names in the produced IR.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151880 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-02 03:22:38 +00:00
Richard Smith a3cac5b76a PR12145: Avoid emitting loads of constexpr variables in contexts where there
is no odr-use of the variable. Go slightly beyond what the standard requires
for variables of reference type.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151879 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-02 03:16:32 +00:00
Eric Christopher 3d32bb0368 Update test for llvm assembly output change. Also add a fixme that this
shouldn't be relying on assembly emission.

For the record we should check the metadata output from the front
end and then check in the backend that such a thing emits a pubtypes
entry.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151851 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-01 22:49:10 +00:00
Eric Christopher ad8de5142a Reapply r151702 with a small fix for a failure to cut and paste
correctly.

Still rdar://10900684

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151838 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-01 21:36:52 +00:00
Daniel Dunbar 956ecbd2c8 Revert r151702, "Add support for handling captured variables in lambda debug
info.", which broke some -O0 -g tests.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151730 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-29 16:28:29 +00:00
Eric Christopher 0a0714ddd3 Add support for handling captured variables in lambda debug info.
This currently doesn't handle capturing the 'this' pointer for any
enclosing class.

Steal the lambda-expressions.cpp testcase and debugify it and try
to use more variables to proof it against random changes.

Part of rdar://10900684

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151702 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-29 03:25:30 +00:00
Eli Friedman c60ccf5b4f Make sure list-initialization of arrays works correctly in explicit type conversions. PR12121.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151674 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-29 00:00:28 +00:00
Sebastian Redl 062a82cdfa Hack in a loud error for PR12086. Better than a silent miscompile.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151586 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-27 23:20:01 +00:00
Eric Christopher ae93daaf42 Make this test a bit more robust for debug info changes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151518 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-27 08:22:57 +00:00
Richard Smith e653ba2f3b Special members which are defaulted or deleted on their first declaration are
trivial if the implicit declaration would be. Don't forget to set the Trivial
flag on the special member as well as on the class. It doesn't seem ideal that
we have two separate mechanisms for storing this information, but this patch
does not attempt to address that.

This leaves us in an interesting position where the has_trivial_X trait for a
class says 'yes' for a deleted but trivial X, but is_trivially_Xable says 'no'.
This seems to be what the standard requires.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151465 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-26 00:31:33 +00:00
Sebastian Redl faf4ef62b6 Richard Smith pointed out that there already is a proposal for init list mangling.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151462 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-25 22:59:28 +00:00
Sebastian Redl 19b1a6eb2c CodeGen support for global variables of type std::initializer_list<X>.
This emits a backing array with internal linkage and fills it with data,
then has the initializer_list point at the array. Dynamic initialization
and global destructors are correctly supported.

What doesn't work is nested initializer_lists. I have no idea how to
get them to work, either. However, these should be very rare, and so
I'll just call it a known bug and declare generalized initializers
DONE!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151457 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-25 20:51:20 +00:00
Sebastian Redl b76ffc5667 Better mangling for new-expressions. Also, although we can't mangle arbitrary initializer lists yet (we will need this), turn the crash into a controlled error.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151455 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-25 20:51:07 +00:00
Douglas Gregor a98a28534e For the purposes of building LLVM types, a forward-declared
enumeration type with a fixed underlying type is complete. Fixes
<rdar://problem/10916155>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151403 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-24 22:40:36 +00:00
Douglas Gregor ec79d877c1 Two minor, related fixes for template instantiation with blocks:
- Make sure that the block expression is instantiation-dependent if the
    block is in a dependent context
  - Make sure that the C++ 'this' expression gets captured even if we
  don't rebuild the AST node during template instantiation. This would
  also have manifested as a bug for lambdas.

Fixes <rdar://problem/10832617>.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151372 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-24 17:41:38 +00:00
Chad Rosier 577fb5b2c1 Reapply r151172 - Unwind path cleanup for array new list initializers - with a
test case that only runs on debug builds.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151311 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-24 00:13:55 +00:00
Richard Smith c22adbd40a PR12067: When emitting an evaluated constant structure in C++11 mode, don't
forget the vptrs.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151245 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-23 08:33:23 +00:00
Rafael Espindola 860097c4ee Two fixes to how we compute visibility:
* Handle some situations where we should never make a decl more visible,
  even when merging in an explicit visibility.

* Handle attributes in members of classes that are explicitly specialized.

Thanks Nico for the report and testing, Eric for the initial review, and dgregor
for the awesome test27 :-)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151236 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-23 04:17:32 +00:00
Chad Rosier 4d8b79786b Revert r151172: Unwind path cleanup for array new list initializers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151203 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-22 21:36:06 +00:00
Sebastian Redl 0f5a1930cc Unwind path cleanup for array new list initializers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151172 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-22 17:37:59 +00:00
Sebastian Redl 9203647221 CodeGen for array new list initializers. Doesn't correctly clean up in the face of exceptions yet.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151171 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-22 17:37:52 +00:00
NAKAMURA Takumi de40d3be58 test/CodeGenCXX/thiscall-struct-return.cpp: Relax expressions for -Asserts.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151126 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-22 03:36:54 +00:00
Aaron Ballman 6c60c8d746 Adding support for Microsoft's thiscall calling convention. Clang side of the patch.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151122 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-22 03:04:13 +00:00
Douglas Gregor 5878cbcfaa Implement non-internal linkage for lambda closure types that need a
stable mangling, since these lambdas can end up in multiple
translation units. Sema is responsible for deciding when this is the
case, because it's already responsible for choosing the mangling
number.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151029 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-21 04:17:39 +00:00
Douglas Gregor 552e29985a Implement name mangling for lambda expressions that occur within the
initializers of data members (both static and non-static).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151017 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-21 02:22:07 +00:00
Douglas Gregor ccc1b5eebc Implement name mangling for lambda expressions that occur within the
default arguments of function parameters. This simple-sounding task is
complicated greatly by two issues:

  (1) Default arguments aren't actually a real context, so we need to
  maintain extra state within lambda expressions to track when a
  lambda was actually in a default argument.
  (2) At the time that we parse a default argument, the FunctionDecl
  doesn't exist yet, so lambda closure types end up in the enclosing
  context. It's not clear that we ever want to change that, so instead
  we introduce the notion of the "effective" context of a declaration
  for the purposes of name mangling.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151011 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-21 00:37:24 +00:00
Nick Lewycky ef7844666b Emit the exact size for the invariant intrinsics.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151010 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-21 00:26:58 +00:00
Douglas Gregor fa07ab57eb Make sure that we set up the right declaration contexts when creating
and introducing the lambda closure type and its function call
operator. Previously, we assumed that the lambda closure type would
land directly in the current context, and not some parent context (as
occurs with linkage specifications). Thanks to Richard for the test case.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150987 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-20 20:47:06 +00:00
Douglas Gregor ee18803f16 When we resolve the type of an 'auto' variable, clear out the linkage
of that variable; it will need to be recomputed with the resolved
type.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150984 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-20 20:05:29 +00:00
Douglas Gregor 9e8c92a9c9 Basic support for name mangling of C++11 lambda expressions. Because
name mangling in the Itanium C++ ABI for lambda expressions is so
dependent on context, we encode the number used to encode each lambda
as part of the lambda closure type, and maintain this value within
Sema.

Note that there are a several pieces still missing:
  - We still get the linkage of lambda expressions wrong
  - We aren't properly numbering or mangling lambda expressions that
  occur in default function arguments or in data member initializers.
  - We aren't (de-)serializing the lambda numbering tables




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150982 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-20 19:44:39 +00:00
Eric Christopher 86211df4d2 Remove the type retaining from the clang frontend. This is now
handled by the caching and rauw. Also fix one cache that wasn't
being added to highlighted by this patch. Update all testcases
accordingly.

This should fix the deall failure.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150977 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-20 18:05:24 +00:00
Benjamin Kramer 4b45d7ff9c Harden test against for operator new(unsigned int).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150932 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-19 16:20:58 +00:00
Sebastian Redl 972edf0534 Make heap-allocation of std::initializer_list 'work'.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150931 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-19 16:03:09 +00:00
Sebastian Redl 924db71fc8 Make std::initializer_list member initializers 'work'.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150930 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-19 15:41:54 +00:00
Sebastian Redl af130fd782 Get recursive initializer lists to work and add a test. Codegen of std::initializer_list is now complete. Onward to array new.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150926 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-19 12:28:02 +00:00
Sebastian Redl bac5cf4110 Add a testcase for using objects with list-constructors, and fix a Sema crash by repeating an old hack.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150925 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-19 12:27:56 +00:00
Sebastian Redl 25e640a6e1 Add a testcase to show that temporaries from the initializer list are destroyed correctly.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150924 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-19 12:27:51 +00:00
Sebastian Redl b859d505f9 Add a testcase for start+end implementations of std::initializer_list.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150923 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-19 12:27:47 +00:00
Eric Christopher 7ff0c5d30d Add in a caching mechanism so that forward declarations are replaced
with full types if they exist.

rdar://10809898 and rdar://10209967 and rdar://10400981

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150858 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-18 00:50:17 +00:00
Richard Smith 00a8c3f6c9 Don't emit optimization-specific intrinsic at -O0.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150838 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-17 20:12:52 +00:00
Sebastian Redl 32cf1f27ae Basic code generation support for std::initializer_list.
We now generate temporary arrays to back std::initializer_list objects
initialized with braces. The initializer_list is then made to point at
the array. We support both ptr+size and start+end forms, although
the latter is untested.

Array lifetime is correct for temporary std::initializer_lists (e.g.
call arguments) and local variables. It is untested for new expressions
and member initializers.

Things left to do:
Massively increase the amount of testing. I need to write tests for
start+end init lists, temporary objects created as a side effect of
initializing init list objects, new expressions, member initialization,
creation of temporary objects (e.g. std::vector) for initializer lists,
and probably more.
Get lifetime "right" for member initializers and new expressions. Not
that either are very useful.
Implement list-initialization of array new expressions.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150803 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-17 08:42:25 +00:00
Richard Smith abb943284c The clang half of r150794: after the construction of a global or static const
variable ends, if the variable has a trivial destructor and no mutable
subobjects then emit an llvm.invariant.start call for it. globalopt knows to
make the variable const when evaluating this.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150798 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-17 07:31:37 +00:00
Richard Smith a9b21d22bb Bug fix: do not emit static const local variables with mutable members
as constants.

Refactor and simplify all the separate checks for whether a type can be
emitted as a constant.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150793 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-17 06:48:11 +00:00
Richard Smith e15c712362 When performing IRGen on a global, emit it as a constant if:
1) It has a const-qualified type, and
 2) It has no mutable members, and
 3) It has no dynamic initialization, and
 4) It has trivial destruction.
Remove the unnecessary requirement that the type be POD. This allows us to
mark all constexpr objects with no mutable members as 'constant'.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150792 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-17 04:54:50 +00:00
Richard Smith f3908f2ae1 Make sure all remaining parts of the constant evaluator are aware that an array
can be represented by an LValue, and use that to simplify the code a little.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150789 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-17 03:35:37 +00:00
Douglas Gregor 27dd7d962b Rework the Sema/AST/IRgen dance for the lambda closure type's
conversion to function pointer. Rather than having IRgen synthesize
the body of this function, we instead introduce a static member
function "__invoke" with the same signature as the lambda's
operator() in the AST. Sema then generates a body for the conversion
to function pointer which simply returns the address of __invoke. This
approach makes it easier to evaluate a call to the conversion function
as a constant, makes the linkage of the __invoke function follow the
normal rules for member functions, and may make life easier down the
road if we ever want to constexpr'ify some of lambdas.

Note that IR generation is responsible for filling in the body of
__invoke (Sema just adds a dummy body), because the body can't
generally be expressed in C++.

Eli, please review!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150783 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-17 03:02:34 +00:00
Richard Smith ce582fe2a7 PR12012: Fix a regression in r150419 where we would try (and fail) to
zero-initialize class types with virtual bases when constant-evaluating an
initializer.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150770 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-17 00:44:16 +00:00
Eric Christopher 9965deaad4 Reapply r150631:
"Add a completed/incomplete type difference. This allows us to have
    partial types for contexts and forward decls while allowing us to
    complete types later on for debug purposes.

    This piggy-backs on the metadata replacement and rauw changes
    for temporary nodes and takes advantage of the incremental
    support I added in earlier. This allows us to, if we decide,
    to limit adding methods and variables to structures in order
    to limit the amount of debug information output into a .o file.

    The caching is a bit complicated though so any thoughts on
    untangling that are welcome."

with a fix:

 - Remove all RAUW during type construction by adding stub versions
   of types that we later complete.

and some TODOs:

 - Add an RAUW cache for forward declared types so that we can replace
   them at the end of compilation.
 - Remove the code that updates on completed types because we no
   longer need to have that happen. We emit incomplete types on
   purpose and only want to know when we want to complete them.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150752 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-16 22:54:45 +00:00
Eli Friedman 22cfaf512e Elide copy construction in new expressions. PR11757.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150738 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-16 22:45:48 +00:00
Richard Smith b9c64d84ea C++11 allows unions to have static data members. Remove the corresponding
restriction and add some tests.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150721 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-16 20:41:22 +00:00
Eric Christopher 64a0430458 Revert "Add a completed/incomplete type difference. This allows us to have"
This reverts commit 9a68d4584a.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150637 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-15 23:51:20 +00:00
Eric Christopher 9a68d4584a Add a completed/incomplete type difference. This allows us to have
partial types for contexts and forward decls while allowing us to
complete types later on for debug purposes.

This piggy-backs on the metadata replacement and rauw changes
for temporary nodes and takes advantage of the incremental
support I added in earlier. This allows us to, if we decide,
to limit adding methods and variables to structures in order
to limit the amount of debug information output into a .o file.

The caching is a bit complicated though so any thoughts on
untangling that are welcome.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150631 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-15 23:25:18 +00:00
John McCall 4d4e5c1ae8 Split reinterpret_casts of member pointers out from CK_BitCast; this
is general goodness because representations of member pointers are
not always equivalent across member pointer types on all ABIs
(even though this isn't really standard-endorsed).

Take advantage of the new information to teach IR-generation how
to do these reinterprets in constant initializers.  Make sure this
works when intermingled with hierarchy conversions (although
this is not part of our motivating use case).  Doing this in the
constant-evaluator would probably have been better, but that would
require a *lot* of extra structure in the representation of
constant member pointers:  you'd really have to track an arbitrary
chain of hierarchy conversions and reinterpretations in order to
get this right.  Ultimately, this seems less complex.  I also
wasn't quite sure how to extend the constant evaluator to handle
foldings that we don't actually want to treat as extended
constant expressions.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150551 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-15 01:22:51 +00:00
Richard Smith 1d0c9a8d05 PR11650: Implement resolution of core issue 1301. Value initialization can't be
used to construct an object of union type with a deleted default constructor
(plus fixes for some related value-initialization corner cases).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150502 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-14 21:14:13 +00:00
Eli Friedman 8656855efb Add a coverage test for lambda expression IRGen.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150458 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-14 03:07:59 +00:00
Richard Smith 7ca4850a3e Deal with a horrible C++11 special case. If a non-literal type has a constexpr
constructor, and that constructor is used to initialize an object of static
storage duration such that all members and bases are initialized by constant
expressions, constant initialization is performed. In this case, the object
can still have a non-trivial destructor, and if it does, we must emit a dynamic
initializer which performs no initialization and instead simply registers that
destructor.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150419 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-13 22:16:19 +00:00
Eric Christopher a765b9fb05 Testcase for previous commit.
PR11970.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150389 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-13 15:04:15 +00:00
Eric Christopher 42e75daaef Temporarily walk back a few of my recent debug info limiting changes
while reworking how we handle wanting to emit only parts of structures.

Fixes PR11970.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150388 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-13 14:56:11 +00:00
Eric Christopher 3b8e197bbf Don't cache the artificial type for the this pointer, there's no
difference in the qual type. This is a workaround for the fact that
the type isn't artificial but the this decl is, however, we don't
have any way of representing it in the current metadata. For now,
however, just don't cache the full type.

Fixes rdar://10831526 and probably a couple of others.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150159 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-09 07:26:21 +00:00
Eric Christopher 531b1a91fb Whitespace.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150026 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-08 00:23:21 +00:00
Eric Christopher 2f764a9122 Use the new forward declaration scheme for records. Also add more
caching of results after we create them.

Fixes rdar://10809898

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150025 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-08 00:23:18 +00:00
Craig Topper 4cf96bb9df Test for r149855.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149862 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-06 08:31:19 +00:00
Richard Smith 41576d47d7 Implement name mangling for scalar value initialization. Reported on IRC by Xeo.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149854 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-06 02:54:51 +00:00