Richard Smith [Wed, 22 Jan 2014 00:30:17 +0000 (00:30 +0000)]
Build an appropriate (albeit trivial) TypeSourceInfo for a destructor name, so
AST consumers can determine where the destructor name was written. Patch by
Olivier Goffart!
Richard Smith [Wed, 22 Jan 2014 00:27:42 +0000 (00:27 +0000)]
When formatting a C++-only declaration name, enable C++ mode in the formatter's
language options. This is not really ideal -- we should require the right
language options to be passed in, or not require language options to format a
name -- but it fixes a number of *obviously* wrong formattings. Patch by
Olivier Goffart!
Nico Rieck [Tue, 21 Jan 2014 23:54:36 +0000 (23:54 +0000)]
Delay attribute checking until auto types are deduced
Checking in ActOnVariableDeclarator computes and caches the linkage using
the non-deduced auto type which defaults to external linkage. Depending on
how the auto type is deduced linkage can change and conflict with the
cached linkage, hitting asserts.
Chandler Carruth [Tue, 21 Jan 2014 22:49:05 +0000 (22:49 +0000)]
Teach Clang to look in its installation libdir for libraries (such as
libc++) when the installation is within the system root.
This doesn't really help cross compiles much, but we don't (currently)
have a great story around libc++, cross compiles, and who is responsible
for building and/or installing the libraries. However, it handles the
very common case of non-cross builds in a way entirely consistent with
GCC, so I'm hopeful this won't really hose anyone.
This is the second patch that I think should be backported to 3.4 to
give folks an easy to checkout and install working Clang+libc++
toolchain.
Adrian Prantl [Tue, 21 Jan 2014 18:42:27 +0000 (18:42 +0000)]
Debug info: use the file a typedef is defined in as its decl_file instead
of the current compilation unit.
As a side effect this enables many more LTO uniquing opportunities.
Adrian Prantl [Tue, 21 Jan 2014 18:20:52 +0000 (18:20 +0000)]
Debug info: use the file a typedef is defined in as its decl_file instead
of the current compilation unit.
As a side effect this enables many more LTO uniquing opportunities.
Bob Wilson [Tue, 21 Jan 2014 00:17:10 +0000 (00:17 +0000)]
Stop linking with crt1.o etc. for the iOS simulator. <rdar://problem/11800973>
Recent versions of the iOS simulator no longer require linking with the
crt1.o, dylib1.o, or bundle1.o files. The relevant code is now included in
libSystem for the simulator.
Rafael Espindola [Mon, 20 Jan 2014 20:33:18 +0000 (20:33 +0000)]
Give explicit sections for string constants used in NSStrings.
Without them they can be merged with non unnamed_addr constants during LTO.
The resulting constant is not unnamed_addr and goes in a different section,
which causes ld64 to crash.
Alp Toker [Mon, 20 Jan 2014 20:26:09 +0000 (20:26 +0000)]
Rename FunctionProtoType accessors from 'arguments' to 'parameters'
Fix a perennial source of confusion in the clang type system: Declarations and
function prototypes have parameters to which arguments are supplied, so calling
these 'arguments' was a stretch even in C mode, let alone C++ where default
arguments, templates and overloading make the distinction important to get
right.
Readability win across the board, especially in the casting, ADL and
overloading implementations which make a lot more sense at a glance now.
Will keep an eye on the builders and update dependent projects shortly.
Aaron Ballman [Mon, 20 Jan 2014 18:07:09 +0000 (18:07 +0000)]
Exposed a declarative way to specify that an attribute can be duplicated when merging attributes on a declaration. This replaces some hard-coded functionality from Sema.
Aaron Ballman [Mon, 20 Jan 2014 17:18:35 +0000 (17:18 +0000)]
Remove some hard-coded specialness for thread-safety attributes from the parser, and made it more declarative. If an attribute is allowed to appear on a function definition when late parsed, it can now use the FunctionDefinition attribute subject. It's treated as a FunctionDecl for most purposes, except it also gets exposed on the AttributeList so that it can be used while parsing.
Aaron Ballman [Mon, 20 Jan 2014 14:18:40 +0000 (14:18 +0000)]
HasFunctionProto is a more strict version of FunctionLike. Since attribute subjects are inclusive (passing a single subject test means no subject-related diagnostic will fire), these two subjects should not be combined.
Chandler Carruth [Mon, 20 Jan 2014 09:42:24 +0000 (09:42 +0000)]
Make the Linux support for finding libc++ somewhat less braindead.
Now instead of just looking in the system root for it, we also look
relative to the clang binary's directory. This should "just work" in
almost all cases. I've added test cases accordingly.
This is probably *very* worthwhile to backport to the 3.4 branch so that
folks can check it out, build it, and use that as their host compiler
going forward.
Ted Kremenek [Mon, 20 Jan 2014 05:50:47 +0000 (05:50 +0000)]
Wire up basic parser/sema support for attribute 'returns_nonnull'.
This attribute is supported by GCC. More generally it should
probably be a type attribute, but this behavior matches 'nonnull'.
This patch does not include warning logic for checking if a null
value is returned from a function annotated with this attribute.
That will come in subsequent patches.
Alp Toker [Mon, 20 Jan 2014 00:23:47 +0000 (00:23 +0000)]
Fix nothrow trait with multiple default constructors
Check all default ctors, not just the first one we see. This brings
__has_nothrow_constructor() in line with the other unary type traits.
A C++ class can have multiple default constructors but clang was only checking
the first one written, presumably due to ambiguity in the GNU specification.
MSVC has the same bug, while g++ has the correct implementation which we now
match.
Alp Toker [Sat, 18 Jan 2014 21:49:02 +0000 (21:49 +0000)]
docs: clarify the role of compiler-builtin type trait primitives
Update the documentation to clarify the intent of clang's built-in type trait
facilities, their relation to user-facing C++ type traits and means to check
for availability.
Also explain that __has_feature() is not currently up to date and should not
generally be used in user code (there's a proposal to provide more consistent
checks via __has_builtin(), see cfe-dev).
David Blaikie [Sat, 18 Jan 2014 02:02:06 +0000 (02:02 +0000)]
Driver support for -fdebug-types-sections
Using backend-option like a few other debug codegen flags. I believe
Eric Christopher's working at porting those over to something nicer
such as an API level CodeGenOptions or the like, so this can be
improved along with that work.
Richard Smith [Fri, 17 Jan 2014 22:29:43 +0000 (22:29 +0000)]
PR12788: Remove unnecessary and incorrect special case for indirect fields.
This caused us to skip a step that was essential for correct access control.
Ismail Pazarbasi [Fri, 17 Jan 2014 21:08:52 +0000 (21:08 +0000)]
Fix string-literal to char* conversion in overload resolution for C++11
String literal to char* conversion is deprecated in C++03, and is removed in
C++11. We still accept this conversion in C++11 mode as an extension, if we find
it in the best viable function.
The checking logic in Sema is not as clean as I would like. Effectively
now we need to check both the FunctionDecl/ObjCMethodDecl and the parameters,
so the point of truth is spread in two places, but the logic isn't that
cumbersome.
Ted Kremenek [Fri, 17 Jan 2014 06:24:50 +0000 (06:24 +0000)]
Add ArrayRef<> interface to get the parameters of a FunctionDecl/ObjCMethodDecl.
This is an alternate interface to the separate iterator interfaces
provided by FunctionDecl and ObjCMethodDecl, which precede ArrayRef.
Providing this new interface is more convenient for some uses, and
likely the old interfaces should be removed. I have not undertaken
that effort in this change because this API introduction may
solicit commentary and that was a larger change than I wanted
to introduce all at once to serve a direct purpose.
Richard Smith [Fri, 17 Jan 2014 03:11:34 +0000 (03:11 +0000)]
PR18477: Create a function scope representing the constructor call when
handling C++11 default initializers. Without this, other parts of Sema (such as
lambda capture) would think the default initializer is part of the surrounding
function scope.
Richard Smith [Fri, 17 Jan 2014 02:09:33 +0000 (02:09 +0000)]
Issue a warning if a throwing operator new or operator new[] returns a null
pointer, since this invokes undefined behavior. Based on a patch by Artyom
Skrobov! Handling of dependent exception specifications and some additional
testcases by me.
Ben Langmuir [Fri, 17 Jan 2014 00:19:09 +0000 (00:19 +0000)]
Improve the error message when a PCH dependency is modified
Show the top-level pch file as the culprit, rather than the immediate
dependency when a pch file imports a pcm from a module. To clarify the
relationship, the pch import stack is printed as notes. The old behaviour was
misleading when a pch imported a pcm (from a module), since removing the pcm
would not fix the problem, whereas rebuilding the pch would.
Adrian Prantl [Fri, 17 Jan 2014 00:15:10 +0000 (00:15 +0000)]
Debug info: Refactor NoLocation and ArtificialLocation to use a common base
class and use it pervasively to restore debug locations.
Fixes an interaction between cleanup and EH that caused the location
to not be restored properly after emitting a landing pad.
rdar://problem/15208190
Richard Smith [Fri, 17 Jan 2014 00:11:48 +0000 (00:11 +0000)]
Move away from 'general' / 'generalized' as a way of identifying C++11
attribute syntax. There's nothing generalized about this; it's one of
several first-class attribute syntaxes we support, all of which are
more-or-less equally general.
As discussed on cfe-commits, we may want to revisit this if we start allowing
this syntax as an extension in C (or if C adopts the syntax), but hopefully
this diagnostic wording will be crystal clear to everyone in the mean time.