Sean Hunt [Wed, 28 Apr 2010 23:02:27 +0000 (23:02 +0000)]
Ensure that cv-qualifiers are correctly removed for post-inc/decrements
as well as pre- and post-inc/decrements in C (not that I think it
matters for any C code).
Douglas Gregor [Wed, 28 Apr 2010 22:16:22 +0000 (22:16 +0000)]
Completely reimplement __builtin_offsetof, based on a patch by Roberto
Amadini.
This change introduces a new expression node type, OffsetOfExpr, that
describes __builtin_offsetof. Previously, __builtin_offsetof was
implemented using a unary operator whose subexpression involved
various synthesized array-subscript and member-reference expressions,
which was ugly and made it very hard to instantiate as a
template. OffsetOfExpr represents the AST more faithfully, with proper
type source information and a more compact representation.
OffsetOfExpr also has support for dependent __builtin_offsetof
expressions; it can be value-dependent, but will never be
type-dependent (like sizeof or alignof). This commit introduces
template instantiation for __builtin_offsetof as well.
There are two major caveats to this patch:
1) CodeGen cannot handle the case where __builtin_offsetof is not a
constant expression, so it produces an error. So, to avoid
regressing in C, we retain the old UnaryOperator-based
__builtin_offsetof implementation in C while using the shiny new
OffsetOfExpr implementation in C++. The old implementation can go
away once we have proper CodeGen support for this case, which we
expect won't cause much trouble in C++.
2) __builtin_offsetof doesn't work well with non-POD class types,
particularly when the designated field is found within a base
class. I will address this in a subsequent patch.
Fixes PR5880 and a bunch of assertions when building Boost.Python
tests.
David Chisnall [Wed, 28 Apr 2010 19:33:36 +0000 (19:33 +0000)]
Changed signature of GenerateMessageSend() function to pass the ObjCInterfaceDecl for class messages and removed the boolean IsClassMessage argument, which wasn't used anywhere.
Emitted some metadata on message sends to allow a later pass to do some speculative inlining of class methods (GNU runtime). Speculative inlining of instance methods requires type feedback to be useful (work in progress), but for class methods it works quite nicely.
Daniel Dunbar [Wed, 28 Apr 2010 16:20:58 +0000 (16:20 +0000)]
Revert "Fix for PR6953: per gcc, regparm and noreturn affect the compatibility of", it is breaking the builds of quite a few projects (emacs, dovecot, gnutar, bison).
Douglas Gregor [Wed, 28 Apr 2010 07:04:26 +0000 (07:04 +0000)]
When the qualifier of a id-expression is non-dependent but not
complete, return an error rather than falling back to building a
dependent declaration reference, since we might not be in a dependent
context. Fixes a fiendish crash-on-invalid in Boost.FunctionTypes that
I wasn't able to reduce to anything useful.
Douglas Gregor [Wed, 28 Apr 2010 05:58:56 +0000 (05:58 +0000)]
Improve name mangling for dependent template names (e.g., typename
T::template apply<U>), handling a few cases where we previously failed
and performing substitutions on such dependent names. Fixes a crash in
Boost.PropertyTree.
Douglas Gregor [Wed, 28 Apr 2010 04:52:24 +0000 (04:52 +0000)]
When instantiating a function template specialization following
template argument deduction, use the lexical declaration context as
the owner for friend function templates. Fixes 2 failures in
Boost.Graph.
Douglas Gregor [Tue, 27 Apr 2010 20:36:09 +0000 (20:36 +0000)]
When explicitly building a temporary object (CXXTemporaryObjectExpr),
keep track of whether we need to zero-initialize storage prior to
calling its constructor. Previously, we were only tracking this when
implicitly constructing the object (a CXXConstructExpr).
Fixes Boost's value-initialization tests, which means that the
Boost.Config library now passes all of its tests.
Douglas Gregor [Tue, 27 Apr 2010 19:38:14 +0000 (19:38 +0000)]
Diagnose the use of abstract types as array element types. Previously,
we were relying on checking for abstract class types when an array
type was actually used to declare a variable, parameter, etc. However,
we need to check when the construct the array for, e.g., SFINAE
purposes (see DR337). Fixes problems with Boost's is_abstract type
trait.
Douglas Gregor [Tue, 27 Apr 2010 18:19:34 +0000 (18:19 +0000)]
During template instantiation, set the naming class of
UnresolvedLookupExpr and UnresolvedMemberExpr by substituting the
naming class we computed when building the expression in the
template...
... which we didn't always do correctly. Teach
UnresolvedMemberExpr::getNamingClass() all about the new
representation of injected-class-names in templates, so that it can
return a naming class that is the current instantiation.
Also, when decomposing a template-id into its template name and its
arguments, be sure to set the naming class on the LookupResult
structure.
Douglas Gregor [Tue, 27 Apr 2010 16:26:47 +0000 (16:26 +0000)]
When checking the redeclaration context of a typedef that refers to a
tag of the same name, compare the lookup contexts rather than the
actual contexts. Fixes PR6923.
Douglas Gregor [Tue, 27 Apr 2010 16:10:10 +0000 (16:10 +0000)]
When instantiating UnresolvedLookupExpr and UnresolvedMemberExpr
expressions, be sure to set the naming class of the LookupResult
structure. Fixes PR6947.
David Chisnall [Tue, 27 Apr 2010 15:08:48 +0000 (15:08 +0000)]
Ensure return from a message to nil is always 0 (GNU runtime).
This works around stack corruption / crashes resulting from PR6944, and also
works around people who expect 'what works on my machine' to work everywhere
(GCC crashes in a number of cases on SPARC that should now work correctly with
clang).
John McCall [Tue, 27 Apr 2010 00:57:59 +0000 (00:57 +0000)]
Make the InjectedClassNameType the canonical type of the current instantiation
of a class template or class template partial specialization. That is to
say, in
template <class T> class A { ... };
or
template <class T> class B<const T*> { ... };
make 'A<T>' and 'B<const T*>' sugar for the corresponding InjectedClassNameType
when written inside the appropriate context. This allows us to track the
current instantiation appropriately even inside AST routines. It also allows
us to compute a DeclContext for a type much more efficiently, at some extra
cost every time we write a template specialization (which can be optimized,
but I've left it simple in this patch).
Douglas Gregor [Mon, 26 Apr 2010 22:37:10 +0000 (22:37 +0000)]
Improve source-location information in a C++ typeid (type) expression
by using TypeSourceInfo, cleaning up the representation
somewhat. Teach getTypeOperand() to strip references and
cv-qualifiers, providing the semantic view of the type without
requiring any extra storage (the unmodified type remains within the
TypeSourceInfo). This fixes a bug found by Boost's call_traits test.
Finally, clean up semantic analysis, by splitting the ActOnCXXTypeid
routine into ActOnCXXTypeId (the parser action) and two BuildCXXTypeId
functions, which perform the semantic analysis for typeid(type) and
typeid(expression), respectively. We now perform less work at template
instantiation time (we don't look for std::type_info again) and can
give better diagnostics.
Chris Lattner [Mon, 26 Apr 2010 22:08:10 +0000 (22:08 +0000)]
fix PR6936: don't generate line marker directives when preprocessing
.S files. "# 123" is passed through as-is, not treated as a line
marker in this mode. No testcase, because it would be nasty and isn't
worth it.
Douglas Gregor [Mon, 26 Apr 2010 21:31:17 +0000 (21:31 +0000)]
Introduce Type::isStructureOrClassType(), which does the obvious
thing. Audit all uses of Type::isStructure(), changing those calls to
isStructureOrClassType() as needed (which is alsmost
everywhere). Fixes the remaining failure in Boost.Utility/Swap.
Douglas Gregor [Mon, 26 Apr 2010 21:04:54 +0000 (21:04 +0000)]
Implement template instantiation for implicit property references in
Objective-C++. This is the last bit of (non-blocks-related) template
instantiation logic for Objective-C++. Yay!
Douglas Gregor [Mon, 26 Apr 2010 20:11:03 +0000 (20:11 +0000)]
Implement template instantiation for value-dependent Objective-C ivar
references and isa expressions. Also, test template instantiation of
unresolved member references to Objective-C ivar references and isa
expressions.
Douglas Gregor [Mon, 26 Apr 2010 17:32:49 +0000 (17:32 +0000)]
Refactor Objective-C @catch parameter checking by detangling it from
function-parameter checking and splitting it into the normal
ActOn*/Build* pair in Sema. We now use VarDecl to represent the @catch
parameter rather than the ill-fitting ParmVarDecl.
Douglas Gregor [Mon, 26 Apr 2010 16:46:50 +0000 (16:46 +0000)]
Make the static type of the exception variable in an Objective-C
@catch a VarDecl. The dynamic type is still a ParmVarDecl, but that
will change soon. No effective functionality change.
Douglas Gregor [Sun, 25 Apr 2010 21:15:30 +0000 (21:15 +0000)]
When name lookup finds a single declaration that was imported via a
using declaration, look at its underlying declaration to determine the
lookup result kind (e.g., overloaded, unresolved). Fixes at least one
issue in Boost.Bimap.
Douglas Gregor [Sun, 25 Apr 2010 20:55:08 +0000 (20:55 +0000)]
Improve the diagnostic when we find something we did not expect in a
member expression (p-> or x.), by showing the type we looked into and
what we did actually find.
Daniel Dunbar [Sun, 25 Apr 2010 20:39:32 +0000 (20:39 +0000)]
IRgen/NeXT: Fix several alignment issues with Objective-C metadata symbols:
- Fix some places that had the alignment hard coded.
- Use ABI type alignment, not preferred type alignment -- neither of this is exactly right, as we really want the C type alignment as required by the runtime, but the ABI alignment is a more correct choice.
This should be equivalent for x86_64, but fixes the alignment for ARM.
Daniel Dunbar [Sun, 25 Apr 2010 20:39:01 +0000 (20:39 +0000)]
IRgen/NeXT: Reuse EmitImageInfo for both fragile and non-fragile ABI. This fixes Clang to correctly emit the "CorrectedSynthesize" bit when using the non-fragile ABI.
Douglas Gregor [Sun, 25 Apr 2010 00:55:24 +0000 (00:55 +0000)]
When copying a temporary object to initialize an entity for which the
temporary needs to be bound, bind the copy object. Otherwise, we won't
end up calling the destructor for the copy. Fixes Boost.Optional.
Douglas Gregor [Sat, 24 Apr 2010 23:45:46 +0000 (23:45 +0000)]
When we create a temporary of class type that we don't immediately
bind, check accessibility of the destructor and mark the declaration
as referenced. Fixes a bunch of Boost.Regex failures.
Anders Carlsson [Sat, 24 Apr 2010 22:25:18 +0000 (22:25 +0000)]
DefineImplicitCopyConstructor now uses SetBaseOrMemberInitializers to create implicit base initializers. (Member initializers are still handled by CodeGenFunction::SynthesizeCXXCopyConstructor for now).
Douglas Gregor [Sat, 24 Apr 2010 20:54:38 +0000 (20:54 +0000)]
When we are performing copy initialization of a class type via its
copy constructor, suppress user-defined conversions on the
argument. Otherwise, we can end up in a recursion loop where the
bind the argument of the copy constructor to another copy constructor call,
whose argument is then a copy constructor call...
Found by Boost.Regex which, alas, still isn't building.
Daniel Dunbar [Sat, 24 Apr 2010 20:32:12 +0000 (20:32 +0000)]
Headers: Hide intptr_t and uintptr_t definitions behind _INTPTR_T and _UINTPTR_T
defines, for increased compatibility with Darwin gcc.
- This is a bit of a hack, since platform compatibility issues don't belong
here, but I don't think this hurts anyone either.
Douglas Gregor [Sat, 24 Apr 2010 18:20:53 +0000 (18:20 +0000)]
When we take the address of a declaration to bind it to a non-type
template parameter, by sure to mark that declaration as
"referenced". The Boost.Iterator library now passes all tests.