Daniel Dunbar [Thu, 23 Sep 2010 01:54:28 +0000 (01:54 +0000)]
IRgen/ABI/ARM: Trust the backend to pass vectors correctly for the given ABI.
- Therefore, we can lower out the NEON wrapper structs and pass the vectors
directly. This makes a huge difference in the cleanliness of the IR after
optimization.
- I will trust, but verify, via future ABITest testing (for APCS-GNU, at
least).
-Wpadded warns when undesired padding is introduced in a struct. (rdar://7469556)
-Wpacked warns if a struct is given the packed attribute, but the packed attribute has no effect
on the layout or the size of the struct. Such structs may be mis-aligned for little benefit.
The warnings are emitted at the point where layout is calculated, that is at RecordLayoutBuilder.
To avoid calculating the layouts of all structs regardless of whether they are needed or not,
I let the layouts be lazily constructed when needed. This has the disadvantage that the above warnings
will be emitted only when they are used for IR gen, and not e.g with -fsyntax-only:
$ cat t.c
struct S {
char c;
int i;
};
void f(struct S* s) {}
$ clang -fsyntax-only -Wpadded t.c
$ clang -c -Wpadded t.c -o t.o
t.c:3:7: warning: padding struct 'struct S' with 3 bytes to align 'i' [-Wpadded]
int i;
^
1 warning generated.
This is a good tradeoff between providing the warnings and not calculating layouts for all
structs in case the user has enabled a couple of rarely used warnings.
Correctly register the class extension as the lexical DeclContext for ObjC methods declared with @property in class extensions.
This matches the behavior for setters.
Also pass the class extension to ProcessPropertyDecl as the lexical DeclContext, even when not redeclaring the @property.
This fixes the remaining issues in <rdar://problem/7410145>.
For ObjCPropertyDecls in class extensions, use the class extension as the lexical DeclContext for newly created
ObjCMethodDecls. Further, use the location of the new property declaration as the location of new ObjCMethodDecls
(if they didn't previously exist).
This fixes more of the issues reported in <rdar://problem/7410145>.
Marcin Swiderski [Tue, 21 Sep 2010 05:58:15 +0000 (05:58 +0000)]
Added:
- definitions of interfaces for CFGInitializer and CFGAutomaticObjDtor,
- support for above classes to print_elem function (renamed print_stmt),
- support for VarDecls in StmtPrinterHelper.
Check for null ObjCInterfaceDecls returned from getClassInterface() when generating USRs. While I have no test case for this (could not create one), this shows up in crash reports. Tentatively fixes <rdar://problem/8452791>.
Bill Wendling [Tue, 21 Sep 2010 01:39:34 +0000 (01:39 +0000)]
Add a comment explaining why the MMX builtins are segregated and what we plan on
doing with them. It's a "FIXME" right now because this change hasn't been
implemented yet.
Douglas Gregor [Mon, 20 Sep 2010 23:34:21 +0000 (23:34 +0000)]
Refactor code completion for expressions that occur as arguments in
Objective-C message sends. There is no functionality change here; this
is prep work for using the parameter types to help guide the
expression results when code-completing the argument.
Douglas Gregor [Mon, 20 Sep 2010 23:11:55 +0000 (23:11 +0000)]
Code completion has no reason to prefer values over types, especially
at the statement level or in Objective-C message receivers. Therefore,
just give types and declarations the same basic priority, and adjust
from there.
Douglas Gregor [Mon, 20 Sep 2010 22:39:41 +0000 (22:39 +0000)]
Slight refactoring in code-completion results generation, placing the
various priority adjustments for preferences (based on selectors,
types) in a single function to make extension easier.
Douglas Gregor [Mon, 20 Sep 2010 21:25:19 +0000 (21:25 +0000)]
Get rid of the lame attempt to prioritize "void" functions at
statement context; it really isn't helpful in practice (remember
printf!) and we'll be doing other adjustments for statements very soon.
Douglas Gregor [Mon, 20 Sep 2010 21:11:48 +0000 (21:11 +0000)]
Tweak priorities for some types and macros:
- In Objective-C, we prefer BOOL to bool for historic reasons;
slightly penalize "bool".
- Treat Nil macro as a NULL pointer constant.
- Treat YES, NO, true, and false macros as constants.
- Treat the bool macro as a type.
Douglas Gregor [Mon, 20 Sep 2010 20:37:39 +0000 (20:37 +0000)]
Introduce a simple, substitution-based compression scheme for USRs, so
that redundant types don't result in super-long USRs. Fixes
<rdar://problem/8447875>.
Problem with gnu conditional extension with missing
LHS and when conditional expression is an array. Since
it will be decayed, saved expression must be saved with
decayed expression. This is necessary to preserve semantics
of this extension (and prevent an IRGen crash which expects
an array to always be decayed). I am sure there will be other
cases in c++ (aggregate conditionals for example) when saving of the
expression must happen after some transformation on conditional
expression has happened.
Doug, please review. Fixes // rdar://8446940
John McCall [Sat, 18 Sep 2010 05:25:11 +0000 (05:25 +0000)]
static local variables with destructors don't require a global destructor
unless we're on a platform without __cxa_atexit (or use thereof has been
disabled). This patch actually just disables the check completely for
static locals, but I've filed http://llvm.org/bugs/show_bug.cgi?id=8176 to
track the platform-specific fix.
John McCall [Sat, 18 Sep 2010 02:24:39 +0000 (02:24 +0000)]
Adjust a fixup's starting branch if it's being resolved because
it reached the outermost scope and it hasn't yet been forwarded
to a cleanup. Fixed PR8175.
Tom Care [Sat, 18 Sep 2010 00:06:34 +0000 (00:06 +0000)]
IdempotentOperationChecker no longer reports errors that are post-dominated by a sink. This fixes some false positives that were flagged because a path was incomplete (usually in a loop).
Douglas Gregor [Fri, 17 Sep 2010 22:25:06 +0000 (22:25 +0000)]
When we run into an error parsing or type-checking the left-hand side
of a binary expression, continue on and parse the right-hand side of
the binary expression anyway, but don't call the semantic actions to
type-check. Previously, we would see the error and then, effectively,
skip tokens until the end of the statement.
The result should be more useful recovery, both in the normal case
(we'll actually see errors beyond the first one in a statement), but
it also helps code completion do a much better job, because we do
"real" code completion on the right-hand side of an invalid binary
expression rather than completing with the recovery completion. For
example, given
x = p->y
if there is no variable named "x", we can still complete after the p->
as a member expression. Along the recovery path, we would have
completed after the "->" as if we were in an expression context, which
is mostly useless.
David Chisnall [Fri, 17 Sep 2010 18:29:54 +0000 (18:29 +0000)]
Add a -ftrapv-handler= option which allows a handler to invoke instead of simply aborting when a signed operation overflows. This mirrors the (GCC-incompatible) behaviour from clang 1.0 and 1.1 when -ftrapv was specified, but allows the handler to be defined for each compilation unit.
Use a temporary file for output which gets renamed after all the writing is finished.
This mainly prevents failures and/or crashes when multiple processes try to read/write the same PCH file. (rdar://8392711&8294781); suggestion & review by Daniel!
Patch to add IRgen support for Gnu's conditional operator
extension when missing LHS. This patch covers scalar
conditionals only. Others are wip.
(pr7726, radar 8353567).
Daniel Dunbar [Fri, 17 Sep 2010 08:22:12 +0000 (08:22 +0000)]
Driver/DarwinClang: Add GCC libexec paths so we can find the cc1 binaries if we
ever use fallback.
- Not necessary for clang as a compiler, but useful for testing purposes.
Daniel Dunbar [Fri, 17 Sep 2010 03:46:37 +0000 (03:46 +0000)]
Revert "Driver/Darwin: Time for another spin at switching to the DarwinClang
toolchain.", while I investigate the totally non-surprising ensuing breakage.
John McCall [Fri, 17 Sep 2010 02:31:44 +0000 (02:31 +0000)]
Currently we're initializing the vtable pointers of a class only after
the bases are completely initialized. This won't work --- base
initializer expressions can rely on the vtables having been set up.
Check for uses of 'this' in the initializers and force a vtable
initialization if found.
This might not be good enough; we might need to extend this to handle
the possibility of arbitrary code finding an external reference to this
(not yet completely-constructed!) object and accessing through it,
in which case we'll probably find ourselves doing a lot more unnecessary
stores.
Daniel Dunbar [Fri, 17 Sep 2010 01:16:06 +0000 (01:16 +0000)]
Driver/DarwinClang: The new toolchain definition is going to drop the -L inside
the GCC dir. Unfortunately, this breaks -lstdc++ on SnowLeopard, etc. because
the libstdc++ dylib was hiding there. Workaround this by providing the path to
the right -lstdc++.6 (the only version used in recent memory) if we can't see an
obvious -lstdc++, but can find = -lstdc++.6.
John McCall [Fri, 17 Sep 2010 00:50:28 +0000 (00:50 +0000)]
When emitting a new-expression inside a conditional expression,
the cleanup might not be dominated by the allocation code.
In this case, we have to store aside all the delete arguments
in case we need them later. There's room for optimization here
in cases where we end up not actually needing the cleanup in
different branches (or being able to pop it after the
initialization code).
Also make sure we only call this operator delete along the path
where we actually allocated something.
Daniel Dunbar [Fri, 17 Sep 2010 00:45:02 +0000 (00:45 +0000)]
Driver: Add magic handling for "reserved library names", starting with
-lstdc++. This is the best gross solution for a gross problem.
This issue is that historically, GCC has add -L options to its internally
library directories. This has allowed users and platforms to end up depending on
the layout of GCC's internal library directories.
We want to correct this mistake by eliminating that -L, but this means that
existing libraries which are in the GCC lib dir won't be found. We are going to
handle this by treating those -l names as "reserved", and requiring toolchains
to know how to add the right full path to the reserved library.
The immediately side effect of this is that users trying to use -L to find their
own -lstdc++ will need to start using -nostdlib (which is a good idea
anyway). Another side effect is that -stdlib=libc++ -lstdc++ will now do the
"right" thing, for curious definitions of right.
Douglas Gregor [Thu, 16 Sep 2010 23:58:57 +0000 (23:58 +0000)]
When dealing with an anonymous enumeration declared in function
prototype scope, temporarily set the context of the enumeration
declaration to the translation unit. We do the same thing for
parameters, until we have an actual function declaration on which to
hang them. Fixes <rdar://problem/8435682>.
There is more work to do in this area, since we have existing bugs
with tags being declared/defined in function parameter lists. This fix
is correct, and we'll end up extending it when we deal with those
existing bugs.
Daniel Dunbar [Thu, 16 Sep 2010 20:42:00 +0000 (20:42 +0000)]
IRgen/ABI/x86_32/Darwin: On Darwin, only structures with SSE vector types get passed
with a non-default-stack-ABI-alignment (of 16).
- This fixes the ABI convenient, but breaks codegen since we now have
underaligned arguments. Marginal improvement overall though, and will be
fixed in next commit.
Daniel Dunbar [Thu, 16 Sep 2010 20:41:56 +0000 (20:41 +0000)]
IRgen/x86_32/Linux: Linux seems to align all stack objects to 4 bytes, unlike
Darwin. Checked vs the handiest Linux llvm-gcc I had around, someone on Linux is
welcome to investigate more.