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

1770 Коммитов

Автор SHA1 Сообщение Дата
Eli Friedman 859c65cdbe Fix an assertion failure with a C++ constructor initializing a
member of reference type in an anonymous struct.  PR13154.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161473 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-08 03:51:37 +00:00
Richard Smith 60b70388e4 Update documentation of HasSideEffects to match its callers' expectations, and
update implementation to match. An elidable, non-trivial constructor call is a
side-effect under this definition, but wasn't under the old one, because we are
not required to evaluate it even though it may have an effect.

Also rationalize checking for volatile reads: just look for lvalue-to-rvalue
conversions on volatile glvalues, and ignore whether a DeclRefExpr etc is for
a volatile variable.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161393 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-07 05:18:29 +00:00
Eric Christopher 387611eaf8 Fix the test RUN line for this better.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161390 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-07 05:04:19 +00:00
Richard Smith 8ae4ec2845 Teach Expr::HasSideEffects about all the Expr types, and fix a bug where it
was mistakenly classifying dynamic_casts which might throw as having no side
effects.

Switch it from a visitor to a switch, so it is kept up-to-date as future Expr
nodes are added. Move it from ExprConstant.cpp to Expr.cpp, since it's not
really related to constant expression evaluation.

Since we use HasSideEffect to determine whether to emit an unused global with
internal linkage, this has the effect of suppressing emission of globals in
some cases.

I've left many of the Objective-C cases conservatively assuming that the
expression has side-effects. I'll leave it to someone with better knowledge
of Objective-C than mine to improve them.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161388 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-07 04:16:51 +00:00
Eric Christopher c7fb748061 If we don't have a complete type for the array type yet either then
just let the alignment be zero.

PR13531

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161379 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-07 00:48:43 +00:00
Eric Christopher b3f46ec9a4 Specify a triple on this to make it easier to test.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161372 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-07 00:28:23 +00:00
Eric Christopher 363e5acfd9 Make sure when we get the replacement type for a template argument
that we attach the lost qualifiers.

Fixes rdar://11882155

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161368 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-07 00:14:25 +00:00
Benjamin Kramer c23aca4475 Flesh out test for defaulted key functions a bit more.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161243 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-03 15:43:22 +00:00
Benjamin Kramer f3fce80bb2 Fix failed to generate vtables in certain cases.
By C++ standard, the vtable should be generated if the first non-inline
virtual function is defined in the TU.  Current version of clang doesn't
generate vtable if the first virtual function is defaulted, because the
key function is regarded as the defaulted function.

Patch by Li Kan!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161236 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-03 08:39:58 +00:00
Eli Friedman ea66f9f9e1 Make sure we don't emit IR for unused EH cleanups. PR13359.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161148 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-02 00:10:24 +00:00
John McCall 7916c99712 When devirtualizing the conversion to a virtual base subobject,
don't explode if the offset we get is zero.  This can happen if
you have an empty virtual base class.

While I'm at it, remove an unnecessary block from the IR-generation
of the null-check, mark the eventual GEP as inbounds, and generally
prettify.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161100 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-01 05:04:58 +00:00
Rafael Espindola 98499013bd Consider the visibility of template template arguments. GCC doesn't, but it also
fails to consider the linkage, which we were already considering.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161070 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-31 19:02:02 +00:00
Rafael Espindola b48280ba17 Handle functions with struct arguments or return types and the regparm
attribute. It is a variation of the x86_64 ABI:

* A struct returned indirectly uses the first register argument to pass the
  pointer.
* Floats, Doubles and structs containing only one of them are not passed in
  registers.
* Other structs are split into registers if they fit on the remaining ones.
  Otherwise they are passed in memory.
* When a struct doesn't fit it still consumes the registers.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161022 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-31 02:44:24 +00:00
Rafael Espindola a78a640c5f Attributes preceding a function declaration are first applied to the return
type and then propagated to the function. This was failing for destructors,
constructors and constructors templates since they don't have a return type.

Fix that by directly calling processTypeAttrs on the dummy type we use as the
return type in these cases.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161020 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-31 01:54:04 +00:00
Richard Smith dd25e80a6d PR13479: If we see the definition of an out-of-line destructor in C++11, be
sure to update the exception specification on the declaration as well as the
definition. If we're building in -fno-exceptions mode, nothing else will
trigger it to be updated.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161008 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-30 23:48:14 +00:00
Rafael Espindola 6d4a40edb5 Add a missing testcase for merging the visibility of two declarations used
as arguments of a template.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160911 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-28 02:51:03 +00:00
Richard Smith b9d0b76e42 Final piece of core issue 1330: delay computing the exception specification of
a defaulted special member function until the exception specification is needed
(using the same criteria used for the delayed instantiation of exception
specifications for function temploids).

EST_Delayed is now EST_Unevaluated (using 1330's terminology), and, like
EST_Uninstantiated, carries a pointer to the FunctionDecl which will be used to
resolve the exception specification.

This is enabled for all C++ modes: it's a little faster in the case where the
exception specification isn't used, allows our C++11-in-C++98 extensions to
work, and is still correct for C++98, since in that mode the computation of the
exception specification can't fail.

The diagnostics here aren't great (in particular, we should include implicit
evaluation of exception specifications for defaulted special members in the
template instantiation backtraces), but they're not much worse than before.

Our approach to the problem of cycles between in-class initializers and the
exception specification for a defaulted default constructor is modified a
little by this change -- we now reject any odr-use of a defaulted default
constructor if that constructor uses an in-class initializer and the use is in
an in-class initialzer which is declared lexically earlier. This is a closer
approximation to the current draft solution in core issue 1351, but isn't an
exact match (but the current draft wording isn't reasonable, so that's to be
expected).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160847 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-27 04:22:15 +00:00
Timur Iskhodzhanov bae11d8f82 Remove an outdated comment; add one test to compare function pointer and block mangling
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160783 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-26 13:41:30 +00:00
Timur Iskhodzhanov f58d01a025 Add more tests for PR13207 (Mangling of template back references with -cxx-abi microsoft) now that PR13389 is fixed (mangling of return types)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160782 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-26 11:01:05 +00:00
Timur Iskhodzhanov dc6dabcabd Fix PR13389 (Wrong mangling of return type qualifiers with -cxx-abi microsoft)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160780 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-26 10:41:15 +00:00
Timur Iskhodzhanov f5e0b225b4 Fix PR13207 (Mangling of templates with back references when using -cxx-abi microsoft)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160667 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-24 09:37:54 +00:00
NAKAMURA Takumi 9a29d74fb7 clang/test/CodeGenCXX/debug-info-globalinit.cpp: Fix for -Asserts.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160660 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-24 02:03:39 +00:00
Nick Lewycky 78d1a10e13 Emit debug info for dynamic initializers. Permit __attribute__((nodebug)) on
variables that have static storage duration, it removes debug info on the
emitted initializer function but not all debug info about this variable.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160659 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-24 01:40:49 +00:00
Timur Iskhodzhanov 1cc9be04bd Follow-up: fix the quotes
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160626 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-23 09:43:03 +00:00
Timur Iskhodzhanov a5427447a3 Replace wrong CHECK array mangling expectations with correct CHECK-NOT+FIXME (PR13182)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160625 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-23 09:32:54 +00:00
Richard Smith adb1d4c18e PR12917: Remove incorrect assumption that lambda mangling information cannot
change once it's been assigned. It can change in two ways:
 1) In a template instantiation, the context declaration should be the
    instantiated declaration, not the declaration in the template.
 2) If a lambda appears in the pattern of a variadic pack expansion, the
    mangling number will depend on the pack length.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160614 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-22 23:45:10 +00:00
Rafael Espindola 71adc5b587 Merge visibility from previous decls before looking at visibility pragma. This
is a bit fuzzy, but matches gcc behavior and existing code bases seem to
depend on it.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160364 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-17 15:14:47 +00:00
Rafael Espindola becfc2325c Record visibility pragmas when we see a tag declaration. We might use it
to build a type before seeing the definition.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160339 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-17 04:22:25 +00:00
Rafael Espindola 6b60370ddb Apply visibility pragmas to class template declarations. This is needed because
we might use the declaration to build a type before seeing the definition.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160176 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-13 18:04:45 +00:00
Rafael Espindola b04b731220 Use -fvisibility-inlines-hidden in inline functions too. This matches gcc
behavior since gcc pr30066. Thanks to Benjamin Kramer for pointing it out.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160174 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-13 14:25:36 +00:00
Rafael Espindola d3d02dd0ae Fix a bug in my previous commit. The problem is not that we were not using the
canonical decl for the template, but that we were not merging attributes for
templates at all!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160157 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-13 01:19:08 +00:00
Rafael Espindola 23458208b2 Use the canonical template decl when trying to find if it has a visibility
attribute.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160139 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-12 20:05:04 +00:00
Timur Iskhodzhanov f9aed96537 [Windows] Split the back reference tests into two separate files as the templates are getting hairy
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160131 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-12 14:33:58 +00:00
Timur Iskhodzhanov 8f88a1dcc5 [Windows] Use thiscall as the default calling convention for class methods. PR12785
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160121 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-12 09:50:54 +00:00
Rafael Espindola 5e06529f3b Process #pragma visibility early in the parsing of class definitions. Fixes
pr13338.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160105 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-12 04:47:34 +00:00
Rafael Espindola f729ce0b23 Ignore visibility attributes after definitions. This matches newer (4.7) gcc's
behavior and is the first step in fixing pr13338.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160104 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-12 04:32:30 +00:00
Rafael Espindola 8d71918ec9 Handle #pragma visibility in explicit specializations and enums.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160057 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-11 18:14:09 +00:00
Rafael Espindola f2f15b3bc6 Don't process #pragma visibility during instantiation. The visibility of the
instantiation depends on the template, its arguments and parameters, but not
where it is instantiated.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160034 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-11 02:15:51 +00:00
Eric Christopher 81e5a936a5 FileCheck-ize.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160032 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-11 01:49:24 +00:00
Richard Smith de31aa7f0e PR13290: Constant-evaluation support for CXXConstructExprs which construct a
multidimensional array of class type. Also, preserve zero-initialization when
evaluating an initializer list for an array, in case the initializers refer to
later elements (which have preceding zero-initialization).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159904 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-07 22:48:24 +00:00
NAKAMURA Takumi 254a8fb01c clang/test/CodeGenCXX/cxx0x-initializer-constructors.cpp: Fixup for -Asserts.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159898 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-07 10:25:42 +00:00
Richard Smith 20599392a9 PR12670: Support for initializing an array of non-aggregate class type from an
initializer list. Patch by Olivier Goffart, with extra testcases by Meador Inge
and Daniel Lunow.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159896 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-07 08:35:56 +00:00
Richard Smith ff817f7070 When marking virtual functions as used for a class' vtable, mark all functions
which will appear in the vtable as used, not just those ones which were
declared within the class itself. Fixes an issue reported as comment#3 in
PR12763 -- we sometimes assert in codegen if we try to emit a reference to a
function declaration which we've not marked as referenced. This also matches
gcc's observed behavior.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159895 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-07 06:59:51 +00:00
Richard Smith f4bb8d06c4 PR13273: When performing list-initialization with an empty initializer list,
actually perform value initialization rather than trying to fake it with a call
to the default constructor. Fixes various bugs related to the previously-missing
zero-initialization in this case.

I've also moved this and the other list initialization 'special case' from
TryConstructorInitialization into TryListInitialization where they belong.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159733 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-05 08:39:21 +00:00
Eli Friedman b135f0f2d8 When we're looking for redeclarations which might provide a definition in CodeGen, make sure we examine all the redeclarations. PR13252.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159586 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-02 21:05:30 +00:00
Rafael Espindola 4a889e47bd Disable devirtualization when we have covariant returns. I will open a bug
for tracking this.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159351 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-28 15:11:39 +00:00
Rafael Espindola ea01d76617 Don't devirtualize calls when we don't have the correct type of the this pointer
handy. It can be done, but we would have to build a derived-to-base cast
during codegen to compute the correct this pointer.

I will handle covariant returns next.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159350 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-28 14:28:57 +00:00
Rafael Espindola 632fbaa22f Fix another issue with devirtualizing calls to final methods by passing them
the correct this pointer. There is some potential for sharing a bit more
code with canDevirtualizeMemberFunctionCalls, but that can be done in an
independent patch.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159326 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-28 01:56:38 +00:00
Timur Iskhodzhanov 8771872ab7 Two more tests for PR13207 - wrong mangling of templates with back references [-cxx-abi microsoft]
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159296 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-27 21:53:00 +00:00
Rafael Espindola 0713d993cd Fix a crash I introduced in r159212.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159279 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-27 17:44:39 +00:00