Daniel Dunbar [Wed, 14 Apr 2010 04:08:03 +0000 (04:08 +0000)]
IRgen: Move EmitStoreThroughBitfieldLValue to use new CGBitfieldInfo::AccessInfo decomposition, instead of computing the access policy itself.
- Sadly, this doesn't seem to give any .ll size win so far. It is possible to make this routine significantly smarter & avoid various shifting, masking, and zext/sext, but I'm not really convinced it is worth it. It is tricky, and this is really instcombine's job.
- No intended functionality change; the test case is just to increase coverage & serves as a demo file, it worked before this commit.
Douglas Gregor [Wed, 14 Apr 2010 02:46:37 +0000 (02:46 +0000)]
Implement typo correction for Objective-C message sends when the
receiver is a mis-typed class name. Previously, we would give a non-specific
typo-correction diagnostic from the expression-parsing code, but there
was no fix-it because it was too late to recover. Now, we give a nice
diagnostic
honk.m:6:4: error: unknown receiver 'Hnk'; did you mean 'Honk'?
[Hnk method];
^~~
Honk
honk.m:1:1: note: 'Honk' declared here
@interface Honk
^
which includes a fix-it.
We still need to recover better from mis-typing "super".
Douglas Gregor [Wed, 14 Apr 2010 02:22:16 +0000 (02:22 +0000)]
Introduce a parsing action to distinguish between class, instance, and
super message sends in Objective-C. No actual functionality change
here, but it provides a hook so that Sema can typo-correct the
receiver in some cases.
John McCall [Wed, 14 Apr 2010 01:27:20 +0000 (01:27 +0000)]
Mark a function declaration invalid if any of its parameter declarations
are invalid. Prevents a crash-on-invalid during template instantiation.
I... really don't understand how this wasn't already present.
John McCall [Wed, 14 Apr 2010 00:24:33 +0000 (00:24 +0000)]
Parse friend template ids as types instead of ending up in
ActOnClassTemplateSpecialization and being very confused.
Fixes PR6514 (for non-templated-scope friends).
Use ASTVector instead of std::vector for the Exprs in InitListExpr. Performance
measurements of '-fsyntax-only' on combine.c (403.gcc) shows no real performance
change, but now the vector isn't leaked.
Introduce ASTVector, which is a std::vector-like class that allocates all memory
using the allocator associated with an ASTContext. This is largely copy-and-paste
from SmallVector, and should be refactored one day.
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).