Commit Graph

30192 Commits

Author SHA1 Message Date
Anders Carlsson 9bd7d16440 When emitting the destructor for a class with a vtable, if we can determine
that the destructor body is trivial and that all member variables also have either
trivial destructors or trivial destructor bodies, we don't need to initialize the
vtable pointers since no virtual member functions will be called on the destructor.

Fixes PR9181.

llvm-svn: 131368
2011-05-14 23:26:09 +00:00
Nico Weber 1eace078a4 Let clang-check actually use the Directory entry in the json file.
llvm-svn: 131367
2011-05-14 21:20:23 +00:00
John McCall 5880fb8edf Only perform the null-initialization of an aggregate result of a message
send if the receiver is null.  Normally it's not worthwhile to check this,
but avoiding the null-initialization is nice, and this also avoids nasty
problems where the null-initialization is visible within the call because
we use an aliased result buffer.  rdar://problem/9402992

llvm-svn: 131366
2011-05-14 21:12:11 +00:00
Argyrios Kyrtzidis dd72aafffc Create proper Objective-C @encoding for C++ classes; fixes rdar://9357400.
Go through and expand the members of bases into the encoding string (and encode the VTable as well).
Unlike gcc which expands virtual bases as many times as they appear in the
hierarchy, clang will only expand them once at the end, to reflect the actual layout.

Note that there doesn't seem to be a way to indicate in the encoding that
packing/alignment of members is different that normal, in which case
the encoding will be out-of-sync with the real layout.
If the runtime switches to just consider the size of types without
taking into account alignment, we could easily make padding explicit in the
encoding (e.g. using arrays of chars). The encoding strings would be
longer then though.

Also encode a flexible array member as array of 0 size, like gcc, not as a pointer.

llvm-svn: 131365
2011-05-14 20:32:43 +00:00
Argyrios Kyrtzidis 7da04c6367 Emit an error when trying to @encode an incomplete type.
There are APIs, e.g. [NSValue valueWithBytes:objCType:], which use the encoding to find out
the size of an object pointed to by a pointer. Make things safer by making it illegal to @encode
incomplete types.

llvm-svn: 131364
2011-05-14 20:32:39 +00:00
Francois Pichet c2fac71c75 Revert 131347. It asserts if the specialization in within a class template:
template<class U> 
struct X1 {
  template<class T> void f(T*);
  template<> void f(int*) { } 
};

Won't be so simple. I need to think more about it.

llvm-svn: 131362
2011-05-14 19:17:07 +00:00
Alexis Hunt 22b5b13ce3 Make sure we actually generate defaulted copy constructors; caught by
Howard Hinnant. Thanks!

llvm-svn: 131349
2011-05-14 18:20:50 +00:00
Francois Pichet 6744e14d9c In Microsoft mode, allow template function explicit specialization at class scope.
Necessary to parse MFC and MSVC standard lib code.

Example:
struct X {
  template<class T> void f(T) { }
  template<> void f(int) { } 
}

llvm-svn: 131347
2011-05-14 17:46:46 +00:00
Richard Smith 0c4a34b1a0 PR9908: Fix the broken fix for PR9902 to get the template argument lists in the right order.
Also, don't reject alias templates in all ElaboratedTypes: some ElaboratedTypes do not correspond to elaborated-type-specifiers.

llvm-svn: 131342
2011-05-14 15:04:18 +00:00
Alexis Hunt c9a5573ef1 What I hope to be an implementation of defaulted copy assignment
operators.

llvm-svn: 131338
2011-05-14 05:23:28 +00:00
Alexis Hunt b2f2780a16 More progress towards defaulted copy assignment
llvm-svn: 131337
2011-05-14 05:23:24 +00:00
Alexis Hunt 119f365d31 Start implementing defaulted copy assignment
llvm-svn: 131336
2011-05-14 05:23:20 +00:00
John McCall 9e8bb000d8 Objective-C vtables are not taking the world by storm; call them
out as "v-table" message sends and stop calling normal messages "legacy"
message sends.

Also, fix some comments to reveal the true state of affairs.

llvm-svn: 131335
2011-05-14 03:10:52 +00:00
John McCall 234eac88ae Reorganize this method to avoid multiple calls for computing CGFunctionInfo
and to decrease the amount of effort in appending strings.

llvm-svn: 131323
2011-05-13 23:16:18 +00:00
Joerg Sonnenberger be7850dd8a Simplify
llvm-svn: 131321
2011-05-13 22:58:37 +00:00
Joerg Sonnenberger caf8ffd8e3 Bug 8765: Honor assembler labels for builtins. Ensure that the label is
mangled to avoid doing it twice for platforms that use prefixes like
Darwin.

llvm-svn: 131311
2011-05-13 21:12:10 +00:00
Joerg Sonnenberger b9c79ad333 Include assembler label for functions in the XML dump
llvm-svn: 131310
2011-05-13 21:10:39 +00:00
Alexis Hunt b5b14c8b8f Fix copy constructor deletion detection with array types.
This fixes PR9910

llvm-svn: 131309
2011-05-13 21:10:11 +00:00
Peter Collingbourne d5d410faa8 Introduce __has_extension macro
__has_extension is a function-like macro which takes the same set
of feature identifiers as __has_feature.  It evaluates to 1 if the
feature is supported by Clang in the current language (either as a
language extension or a standard language feature) or 0 if not.

At the same time, add support for the C1X feature identifiers
c_generic_selections (renamed from generic_selections) and
c_static_assert, and document them.

Patch by myself and Jean-Daniel Dupas.

llvm-svn: 131308
2011-05-13 20:54:45 +00:00
Bob Wilson 19c1b88c55 Define __ARM_NEON__ in both ARM and Thumb modes. Radar 9431992.
llvm-svn: 131301
2011-05-13 18:56:03 +00:00
Bill Wendling bb455154a1 Remove the 'unaligned load' builtins now that they're no longer used in the *mmintrin.h files.
llvm-svn: 131300
2011-05-13 18:52:28 +00:00
Fariborz Jahanian a52b1f72ef Produce UTF-8 strings with -fconstant-string-class
-fno-constant-cfstrings. Patch by Jonathan Schleifer.

llvm-svn: 131298
2011-05-13 18:13:10 +00:00
Fariborz Jahanian 7d62273c87 refactor CheckForwardProtocolDeclarationForCircularDependency returns
'true' on detecting protocol cycles. No functionality change.

llvm-svn: 131297
2011-05-13 18:02:08 +00:00
Douglas Gregor a8d0c774da Add c-index-test printing and tests for static and virtual method
query functions, from Erik Verbruggen!

llvm-svn: 131295
2011-05-13 15:54:42 +00:00
Douglas Gregor c586166fe3 Eliminate old, useless tutorial page
llvm-svn: 131292
2011-05-13 14:43:48 +00:00
Alexis Hunt 913820daf0 Defaulting copy constructors now works reasonably well.
One more special member to go

llvm-svn: 131287
2011-05-13 06:10:58 +00:00
Chris Lattner b4ccc2d09e some updates.
llvm-svn: 131286
2011-05-13 05:29:16 +00:00
Chris Lattner 935304e12e this never happened.
llvm-svn: 131285
2011-05-13 05:22:41 +00:00
Chris Lattner 98b9029d88 remove some old redirect pages. We're into our 3rd year of redirecting, the world should have adjusted by now :)
llvm-svn: 131284
2011-05-13 05:21:33 +00:00
Peter Collingbourne d12d712c84 Delete doxygen.cfg, and use cwd-relative paths in doxygen.cfg.in.
Now "make doxygen" works for clang.

llvm-svn: 131282
2011-05-13 03:29:06 +00:00
Peter Collingbourne e92006860d Refactoring of constant expression evaluator
This introduces a generic base class for the expression evaluator
classes, which handles a few common expression types which were
previously handled separately in each class.  Also, the expression
evaluator now uses ConstStmtVisitor.

llvm-svn: 131281
2011-05-13 03:29:01 +00:00
Peter Collingbourne 43bb6e23e5 Add a ConstStmtVisitor class
ConstStmtVisitor is a constness-preserving variant of StmtVisitor.
ConstStmtVisitor and StmtVisitor share an implementation using a common
base class, StmtVisitorBase, which uses a template template parameter
to build pointer types.

llvm-svn: 131280
2011-05-13 03:28:54 +00:00
Bill Wendling 03e7e430c3 Add 'may_alias' attribute. Noticed by Eli.
llvm-svn: 131278
2011-05-13 01:24:00 +00:00
Douglas Gregor 61226d3fcf When determining whether we can make a declaration into a global
constant, also consider whether it's a class type that has any mutable
fields. If so, it can't be a global constant.

llvm-svn: 131276
2011-05-13 01:05:07 +00:00
Alexis Hunt 94f9cbf998 Implement a few basic tests for defaulted and deleted functions.
More comprehensive testing once copy {constructors,assignment operators}
can be defaulted.

llvm-svn: 131275
2011-05-13 01:01:05 +00:00
Douglas Gregor a6a7e3c1f2 Teach the template parameter dependency checker used when matching
template parameter lists to scope specifiers for friend declarations
about injected class name types. Fixes the
g++.dg/template/memfriend5.C regression in the GCC testsuite.

llvm-svn: 131272
2011-05-13 00:34:01 +00:00
Alexis Hunt d9a5cc13cf Implement the __is_trivially_copyable type trait
llvm-svn: 131270
2011-05-13 00:31:07 +00:00
Bill Wendling 502931fad9 Represent the unaligned loads natively. These are converted into a call to the
correct unaligned load.

llvm-svn: 131268
2011-05-13 00:11:39 +00:00
Alexis Hunt 1f69a02fb9 Implement defaulting of destructors.
llvm-svn: 131260
2011-05-12 22:46:29 +00:00
Alexis Hunt f9172946be Hrm
llvm-svn: 131259
2011-05-12 22:46:25 +00:00
Nick Lewycky 2ce1630c92 Add a method to query whether or not a class has a default constructor declared.
llvm-svn: 131255
2011-05-12 22:11:21 +00:00
Fariborz Jahanian cadf7c57ad After issuing diagnostics on circular protocol list,
don't build circular AST in protocol's protocol list 
when user code has introduced it. Indexer and other   
clients may crash. // rdar://9221614

llvm-svn: 131254
2011-05-12 22:04:39 +00:00
Devang Patel e91b54cc56 Doug convinced me that DW_AT_APPLE_objc_complete_type is more appropriate name.
s/DW_AT_APPLE_objc_class_extension/DW_AT_APPLE_objc_complete_type/g

llvm-svn: 131245
2011-05-12 21:29:57 +00:00
Devang Patel 70d77d144b Do not add AT_APPLE_objc_class_extension attribute if @implementation is not seen.
llvm-svn: 131242
2011-05-12 21:14:54 +00:00
Howard Hinnant 2d3eadac9b enable __has_feature(is_standard_layout)
llvm-svn: 131240
2011-05-12 19:52:14 +00:00
Devang Patel 36882c8f24 Use DW_AT_APPLE_objc_class_extension attribute to identify interfaces that represent class extension.
Radar 9423077.

llvm-svn: 131239
2011-05-12 19:07:41 +00:00
Bill Wendling e106c34817 LLVM doesn't always optimize away the four loads from this:
(__m128){ p[0], p[1], p[2], p[3] }

which produces really bad code. This could be done in instcombine, but it's
probably better to do it in the front-end instead.
<rdar://problem/9424836>

llvm-svn: 131237
2011-05-12 19:02:15 +00:00
Douglas Gregor 9519d92ef6 Add clang_CXXMethod_isVirtual() to libclang, from Erik Verbruggen!
llvm-svn: 131230
2011-05-12 15:17:24 +00:00
Alexis Hunt 5a7fa250ab Properly parse the 'default' and 'delete' keywords.
They are actually grammatically considered definitions and parsed
accordingly.

This fixes the outstanding bugs regarding defaulting functions after
their declarations.

We now really nicely diagnose the following construct (try it!)

int foo() = delete, bar;

Still todo: Defaulted functions other than default constructors
            Test cases (including for the above construct)

llvm-svn: 131228
2011-05-12 06:15:49 +00:00
Alexis Hunt f92197cf96 Make it so that we actually generate definitions for explicitly
defaulted default constructors.

As it happens, making sure that we handle out-of-line defaulted
functions properly will involved making sure that we actually parse them
correctly, so that's coming after.

llvm-svn: 131224
2011-05-12 03:51:51 +00:00