Add calling convention related attributes to related declaration. Mark attributes invalid on type related checking so to add them to declarations only when everything is ok.
John McCall [Fri, 30 Apr 2010 07:10:06 +0000 (07:10 +0000)]
An edge from a call expression to the exit block is only an abnormal edge
if *none* of the successors of the call expression is the exit block.
This matters when a call of bool type is the condition of (say) a while
loop in a function with no statements after the loop. This *can* happen
in C, but it's much more common in C++ because of overloaded operators.
Suppresses some substantial number of spurious -Wmissing-noreturn warnings.
Douglas Gregor [Fri, 30 Apr 2010 05:56:50 +0000 (05:56 +0000)]
Introduce a sequence number into class template partial
specializations, which keeps track of the order in which they were
originally declared. We use this number so that we can always walk the
list of partial specializations in a predictable order during matching
or template instantiation. This also fixes a failure in Boost.Proto,
where SourceManager::isBeforeInTranslationUnit was behaving
poorly in inconsistent ways.
John McCall [Fri, 30 Apr 2010 05:56:45 +0000 (05:56 +0000)]
Account for the VTT argument when making an implicit copy constructor for
a class with virtual bases. Just a patch until Sema starts (correctly) doing
most of this analysis.
Douglas Gregor [Fri, 30 Apr 2010 04:39:27 +0000 (04:39 +0000)]
When we start the definition of a class template, set the
InjectedClassNameType's Decl to point at the definition. It's a little
messy, but we do the same thing with classes and their record types,
since much of Clang expects that the TagDecl* one gets out of a type
is the definition. Fixes several Boost.Proto failures.
Refactor the AnalysisConsumer to analyze functions after the whole
translation unit is parsed. This enables us to inline some calls when still
analyzing one function at a time.
Actions are classified into Function, CXXMethod, ObjCMethod,
ObjCImplementation.
This does not hurt performance much. The analysis time for sqlite3.c:
before:
real 17m52.440s
user 17m49.460s
sys 0m2.010s
after:
real 18m0.500s
user 17m56.900s
sys 0m2.330s
DisplayProgress option is broken now. -inine-call action is removed. It
will be reenabled in another form, perhaps as an indenpendant option.
John McCall [Thu, 29 Apr 2010 23:50:39 +0000 (23:50 +0000)]
Rebuild the nested name specifiers in member-pointer declarator chunks when
entering the current instantiation. Set up a little to preserve type location
information for typename types while we're in there.
Do not enable '-analyze-check-security-syntactic' by default when using '--analyze'. There
are several known issues to address for it should be turned on by default.
Douglas Gregor [Thu, 29 Apr 2010 18:24:40 +0000 (18:24 +0000)]
When determining a standard conversion sequence involves resolving the
address of an overloaded function (or function template), perform that
resolution prior to determining the implicit conversion
sequence. This resolution is not part of the implicit conversion
sequence itself.
Previously, we would always consider this resolution to be a
function pointer decay, which was a lie: there might be an explicit &
in the expression, in which case decay should not occur. This caused
the CodeGen assertion in PR6973 (where we created a
pointer to a pointer to a function when we should have had a pointer
to a function), but it's likely that there are corner cases of
overload resolution where this would have failed.
Cleaned up the code involved in determining the type that will
produced afer resolving the overloaded function reference, and added
an assertion to make sure the result is correct. Fixes PR6973.
Use clang::VarDecl name instead of llvm::GlobalVariable name.
llvm::GLobalVariable name may not match user visibile name for function static variables.
Add USR support for 'static inline' functions (which can be declared in header files).
Add USR support for 'static' functions and local variables, which can be handy for resolving named variables within a translation unit.
Douglas Gregor [Thu, 29 Apr 2010 06:31:36 +0000 (06:31 +0000)]
When performing partial ordering of class template partial
specializations, substitute the deduced template arguments and check
the resulting substitution before concluding that template argument
deduction succeeds. This marvelous little fix makes a bunch of
Boost.Spirit tests start working.
Douglas Gregor [Thu, 29 Apr 2010 06:21:43 +0000 (06:21 +0000)]
For template argument deduction from class template partial
specializations, separate out the deduction part from the checking and
substitution of the deduced arguments.
Mon P Wang [Thu, 29 Apr 2010 05:53:29 +0000 (05:53 +0000)]
A not equal for an unordered relation should return true as specified in IEEE-754, e.g.,
NAN != NAN ? 1 : 0 should return 1. Also fix the case for complex.
Douglas Gregor [Thu, 29 Apr 2010 04:55:13 +0000 (04:55 +0000)]
It turns out that we *can* end up having to display template argument
bindings when the template argument is still an expression; it happens
while checking the template arguments of a class template partial
specializations. Fixes PR6964.
John McCall [Thu, 29 Apr 2010 00:35:03 +0000 (00:35 +0000)]
Properly switch into the declaring scope of a template when performing
template argument deduction or (more importantly) the final substitution
required by such deduction. Makes access control magically work in these
cases.
Douglas Gregor [Thu, 29 Apr 2010 00:18:15 +0000 (00:18 +0000)]
Teach __builtin_offsetof to compute the offsets of members of base
classes, since we only warn (not error) on offsetof() for non-POD
types. We store the base path within the OffsetOfExpr itself, then
evaluate the offsets within the constant evaluator.
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.