Daniel Dunbar [Tue, 13 Apr 2010 23:34:15 +0000 (23:34 +0000)]
IRgen: Move EmitLoadOfBitfieldLValue to use new CGBitfieldInfo::AccessInfo decomposition, instead of computing the access policy itself.
- This lets the method focus slightly more on emitting clean IR to honor the policy which has been selected. On 403.gcc's combine.c, x86_64, -O0, this reduces the number of lines in the .ll file (~= # of instructions) by 2.5%.
- No intended functionality change -- at -O3 this should produce equivalent if not identical output. On 403.gcc's combine.c, x86_64, -O3, this isn't quite true and some of the changes are regressions, but I'm not going to worry about that until we move to a new access policy.
- There is still some room for improvement in the generated IR, in particular we can usually fold the sign-extension of the bit-field into one of the component access. See the FIXME.
Daniel Dunbar [Tue, 13 Apr 2010 20:58:55 +0000 (20:58 +0000)]
IRgen: Enhance CGBitFieldInfo with enough information to fully describe the "policy" with which a bit-field should be accessed.
- For now, these policies are computed to match the current IRgen strategy, although the new information isn't being used yet (except in -fdump-record-layouts).
Chris Lattner [Tue, 13 Apr 2010 18:16:19 +0000 (18:16 +0000)]
Rework the ConstStructBuilder code to emit missing initializer
elements with explicit zero values instead of with tail padding.
On an example like this:
struct foo { int a; int b; };
struct foo fooarray[] = {
{1, 2},
{4},
};
We now lay this out as:
@fooarray = global [2 x %struct.foo] [%struct.foo { i32 1, i32 2 }, %struct.foo { i32 4, i32 0 }]
Chris Lattner [Tue, 13 Apr 2010 17:33:56 +0000 (17:33 +0000)]
make the rewriter add a #ifndef around the #define of __attribute__.
Without it, there is no reason for a compiler that supports it to
emit the dead static globals that the rewriter labels attribute(used).
Douglas Gregor [Tue, 13 Apr 2010 16:31:36 +0000 (16:31 +0000)]
Refactor and simplify the computation of implicit conversion sequences
for reference binding. The code attempted to handle both the
computation of the ICS and the actual conversion, but the latter is an
anachronism: we now use InitializationSequence for that.
Sema::CheckReferenceInit is now a static function TryReferenceInit
that's only use within overload resolution, and has been simplified
slightly. It still needs to be updated per C++ [over.ics.ref], by
eliminating more of the lvalue/rvalue checks.
Douglas Gregor [Tue, 13 Apr 2010 15:50:39 +0000 (15:50 +0000)]
When returning the result of a call to an object of class type, do not
return a NULL expression; return either an error or a proper
expression. Fixes PR6078.
Douglas Gregor [Tue, 13 Apr 2010 15:07:45 +0000 (15:07 +0000)]
During referencing binding, only consider conversion functions for
direct reference binding when the source and target types are not
reference-related. Fixes PR6066.
John McCall [Tue, 13 Apr 2010 01:44:10 +0000 (01:44 +0000)]
Don't try to find a scope corresponding to the search DC for an unfound
friend declaration; this used to be important but is now just a waste of time
plus an unreasonable assertion. Fixes PR6174.
Douglas Gregor [Mon, 12 Apr 2010 23:42:09 +0000 (23:42 +0000)]
Implement C++ [over.ics.user]p3, which restricts the final conversion
from a conversion function template specialization to one of exact
match rank. We only know how to test this in C++0x with default
function template arguments, but it's also in the C++03 spec. Fixes
PR6285.
Douglas Gregor [Mon, 12 Apr 2010 23:19:01 +0000 (23:19 +0000)]
Improve source-location information for C++ conversion functions, by
copying the type location information from the conversion-type-id into
the type location information for the function type. Do something
similar for constructors and destructors, by giving their "void"
return type source-location information.
In all of these cases, we previously left this type-source information
uninitialized, which led to various unfortunate crashes.
We still aren't tracking good source-location information for the
actual names. That's PR6357.
Chris Lattner [Mon, 12 Apr 2010 21:53:11 +0000 (21:53 +0000)]
fix PR6814 - Only print [-pedantic] on a diagnostic if -pedantic
actually turned it on. If a diag is produced by a warning which
is an extension but defaults to on, and has no warning group, don't
print any option info.
Add 'clang_getCursorLanguage' to return the "language" of the AST element (e.g., distinguish between C and Objective-C language features). Currently this only returns results for declarations.
Chris Lattner [Mon, 12 Apr 2010 21:10:05 +0000 (21:10 +0000)]
fix PR6660/6168: emit padding as zeros instead of undef. Because
trailing fields may not be represented in initializer lists, they
are being handled as padding and those fields *must* be zero
initialized.
Douglas Gregor [Mon, 12 Apr 2010 20:54:26 +0000 (20:54 +0000)]
Implement C++ [temp.local]p4, which specifies how we eliminate
name-lookup ambiguities when there are multiple base classes that are
all specializations of the same class template. This is part of a
general cleanup for ambiguities in template-name lookup. Fixes
PR6717.
Douglas Gregor [Mon, 12 Apr 2010 17:09:20 +0000 (17:09 +0000)]
When creating the implicitly-declared special member functions, be
sure to introduce them into the current Scope (when we have one) in
addition to the DeclContext for the class, so that they can be found
by name lookup for inline members of the class. Fixes PR6570.
Douglas Gregor [Mon, 12 Apr 2010 16:00:01 +0000 (16:00 +0000)]
Fix a crash-on-invalid involving name lookup of tag names, where we
ended up finding a function template that we didn't expect. Recover
more gracefully, and fix a similar issue for class templates.
Douglas Gregor [Mon, 12 Apr 2010 07:51:13 +0000 (07:51 +0000)]
Add another test case for r101029, which verifies that we now
correctly diagnose instantiation of a function parameter with Objective-C
class type (since Objective-C classes can't be passed by value).
Douglas Gregor [Mon, 12 Apr 2010 07:48:19 +0000 (07:48 +0000)]
Be sure to instantiate the parameters of a function, even when the
function's type is (strictly speaking) non-dependent. This ensures
that, e.g., default function arguments get instantiated properly.
And, since I couldn't resist, collapse the two implementations of
function-parameter instantiation into calls to a single, new function
(Sema::SubstParmVarDecl), since the two had nearly identical code (and
each had bugs the other didn't!). More importantly, factored out the
semantic analysis of a parameter declaration into
Sema::CheckParameter, which is called both by
Sema::ActOnParamDeclarator (when parameters are parsed) and when a
parameter is instantiated. Previously, we were missing some
Objective-C and address-space checks on instantiated function
parameters.
Augment clang_getCursorUSR() to not always expect that clang_getCursorDecl() does the right
thing if the cursor is not a decl (such as in the case of macros).
Chris Lattner [Sun, 11 Apr 2010 08:28:14 +0000 (08:28 +0000)]
fix PR6811 by not parsing 'super' as a magic expression in
LookupInObjCMethod. Doing so allows all sorts of invalid code
to slip through to codegen. This patch does not change the
AST representation of super, though that would now be a natural
thing to do since it can only be in the receiver position and
in the base of a ObjCPropertyRefExpr.
There are still several ugly areas handling super in the parser,
but this is definitely a step in the right direction.
Chris Lattner [Sun, 11 Apr 2010 07:51:10 +0000 (07:51 +0000)]
actually the interface grossness in the previous patch was due to
typo correction. However, now that the code has been factored out
of LookupMemberExpr, it can recurse to itself instead of to
LookupMemberExpr! Remove grossness.
Chris Lattner [Sun, 11 Apr 2010 07:45:24 +0000 (07:45 +0000)]
factor the code that handles "expr.field" when expr is a
pointer to an objc interface out to a method in SemaExprObjC.
This is *much* uglier than it should be due to grossness in
LookupMemberExpr :(