John McCall [Tue, 14 Dec 2010 16:45:57 +0000 (16:45 +0000)]
Improve some comments, shrink FunctionType::ExtInfo, and fix a bug found
by valgrind where we were doing the wrong thing in the presence of invalid
exception specs.
John McCall [Tue, 14 Dec 2010 06:51:39 +0000 (06:51 +0000)]
Factor out most of the extra state in a FunctionProtoType into a separate
class to be passed around. The line between argument and return types and
everything else is kindof vague, but I think it's justifiable.
Douglas Gregor [Mon, 13 Dec 2010 22:49:22 +0000 (22:49 +0000)]
Variadic templates: extend Type, NestedNameSpecifier, TemplateName,
and TemplateArgument with an operation that determines whether there
are any unexpanded parameter packs within that construct. Use this
information to diagnose the appearance of the names of parameter packs
that have not been expanded (C++ [temp.variadic]p5). Since this
property is checked often (every declaration, ever expression
statement, etc.), we extend Type and Expr with a bit storing the
result of this computation, rather than walking the AST each time to
determine whether any unexpanded parameter packs occur.
This commit is deficient in several ways, which will be remedied with
future commits:
- Expr has a bit to store the presence of an unexpanded parameter
pack, but it is never set.
- The error messages don't point out where the unexpanded parameter
packs were named in the type/expression, but they should.
- We don't check for unexpanded parameter packs in all of the places
where we should.
- Testing is sparse, pending the resolution of the above three
issues.
Chandler Carruth [Mon, 13 Dec 2010 07:40:47 +0000 (07:40 +0000)]
Fix PR8774 by restricting when hasInit returns true. Previously, it
would return true if the initializer pointer union had *any* non-null
pointer in it, even if the pointer wasn't one that would actually be
returned via getInit(). This makes it more accurately model the logic of
'getInit() != NULL'.
This still isn't completely satisfying. From a principled stance,
I suspect we should make hasInit() and getInit() *always* return false
and NULL (resp.) for ParmVarDecl. We shouldn't at the API level treat
initializers and default arguments as the same thing.
Chandler Carruth [Mon, 13 Dec 2010 01:44:01 +0000 (01:44 +0000)]
Reduce the number of builtin operator overload candidates added in certain
cases. First, omit all builtin overloads when no non-record type is in the set
of candidate types. Second, avoid arithmetic type overloads for non-arithmetic
or enumeral types (counting vector types as arithmetic due to Clang
extensions). When heavily using constructs such as STL's '<<' based stream
logging, this can have a significant impact. One logging-heavy test case's
compile time dropped by 10% with this. Self-host shows 1-2% improvement in
compile time, but that's likely in the noise.
Chandler Carruth [Sun, 12 Dec 2010 21:36:11 +0000 (21:36 +0000)]
Move the functionality to mark all vtables of key functions as used within
a translation unit to the ActOnEndOfTranslationUnit function instead of doing
it at the start of DefineUsedVTables. The latter is now called *recursively*
during template instantiation, which causes an absolutely insane number of
walks of every record decl in the translation unit.
After this patch, an extremely template instantiation heavy test case's compile
time drops by 10x, and we see between 15% and 20% improvement in average
compile times across a project. This is just recovering a regression, it
doesn't make anything faster than it was several weeks ago.
Chandler Carruth [Sun, 12 Dec 2010 10:35:00 +0000 (10:35 +0000)]
Finish cleaning up the static utility code for adding builtin operator overload
candidates. They're now wrapped in nice APIs which hide the tables, etc. Also
removes some repetitive code from clients.
Chandler Carruth [Sun, 12 Dec 2010 09:59:53 +0000 (09:59 +0000)]
Clean up the helpers used to compute the usual arithmetic conversions' result
type. Localize all of the logic within a single function rather than spreading
it throughout the class.
Also fixes a buglet where we failed to check for a RHS arithmetic type wider
than the LHS and return its canonical type. I've yet to produce a test case
that breaks because of this, but it was spotted by inspection by folks on the
IRC channel and is obviously correct now.
Chandler Carruth [Sun, 12 Dec 2010 09:14:11 +0000 (09:14 +0000)]
Sink the logic to suppress builtin operator overloads in the presence of
user-defined operator overloads on the same enumeral types to the one place
where it is used.
In theory this removes wasted computation from several paths through this code,
but I'm not aware of a case where it actually matters. This is mostly for
cleanliness.
Chandler Carruth [Sun, 12 Dec 2010 08:51:33 +0000 (08:51 +0000)]
Reorder the cases in the switch to be more logically grouped (to my mind). If
others have another ordering they would prefer, I'm all ears, but this one made
it much easier for me to find the group of operators I'm interested in.
Chandler Carruth [Sun, 12 Dec 2010 08:11:30 +0000 (08:11 +0000)]
Begin the refactoring of how builtin operators are added to the overload
candidate set. This breaks apart a huge switch + goto system into distinct
methods on a class. It also places the current mess of tables and other static
state used in the process within that class.
This is still a work in progress. I did a few simplifications that jumped out
at me as I went, but I plan to iterate on this a bit before it's truly clean.
However, this is easily the most invasive chunk. I benchmarked it on
all-std-headers.cpp and an internal testcase that has a major hotspot in
overload resolution and saw no real performance impact.
Enhance my implementation of //rdar ://8747333 in r121597 to allow
for declaration of property setter/getter in forward
class extensions and also skip over
propeties which are @dynamic.
Any property declared in a class extension might have user
declared setter or getter in current class extension or one
of the other class extensions. Mark them as synthesized as
property will be synthesized when property with same name is
seen in the @implementation. This prevents bogus warning
about unimplemented methods to be issued for these methods.
Fixes // rdar://8747333
Bob Wilson [Fri, 10 Dec 2010 19:45:06 +0000 (19:45 +0000)]
Do not assert on shifts of Neon polynomial types.
Most Neon shift intrinsics do not have variants for polynomial types, but
vsri_n and vsli_n do support them, and we need to properly range-check the
shift immediates for them.
Douglas Gregor [Fri, 10 Dec 2010 17:19:40 +0000 (17:19 +0000)]
Replace two QualType::getTypePtrOrNull() calls with
QualType::getTypePtr(). It turns out that
cast_or_null/dyn_cast_or_null don't actually use simplify_type, so
they're guaranteed to operator on non-NULL QualType or CanQualType
objects.
Good for a 0.6% win on 403.gcc's combine.c with -emit-llvm.
Do not substitute template types if template has dependent context
We should not substitute template types if the template has a dependent
context because the template argument stack is not yet fully formed.
Instead, defer substitution until the template has a non-dependent
context (i.e. instantiation of an outer template).
Douglas Gregor [Fri, 10 Dec 2010 17:03:06 +0000 (17:03 +0000)]
Eliminate the branching in QualType::getTypePtr() by providing a
common base for ExtQuals and Type that stores the underlying type
pointer. This results in a 2% performance win for -emit-llvm on a
typical C file, with 1% memory growth in the AST.
Note that there is an API change in this optimization:
QualType::getTypePtr() can no longer be invoked on a NULL
QualType. If the QualType might be NULL, use
QualType::getTypePtrOrNull(). I've audited all uses of getTypePtr() in
the code base and changed the appropriate uses over to
getTypePtrOrNull().
A future optimization opportunity would be to distinguish between
cast/dyn_cast and cast_or_null/dyn_cast_or_null; for the former, we
could use getTypePtr() rather than getTypePtrOrNull(), to take another
branch out of the cast/dyn_cast implementation.
John McCall [Fri, 10 Dec 2010 11:01:00 +0000 (11:01 +0000)]
It's kindof silly that ExtQuals has an ASTContext&, and we can use that
space better. Remove this reference. To make that work, change some APIs
(most importantly, getDesugaredType()) to take an ASTContext& if they
need to return a QualType. Simultaneously, diminish the need to return a
QualType by introducing some useful APIs on SplitQualType, which is
just a std::pair<const Type *, Qualifiers>.
Douglas Gregor [Fri, 10 Dec 2010 08:57:38 +0000 (08:57 +0000)]
Move the "volatile" bit into QualType's "fast" qualifier set,
increasing the required type alignment from 8 to 16. This provides a
2.5% speedup for -fsyntax-only on a token-cached Cocoa.h, while only
increasing memory consumption in the ASTContext by 0.8%.
John McCall [Fri, 10 Dec 2010 02:59:44 +0000 (02:59 +0000)]
Treat visibility on an enclosing namespace as a non-explicit source of
visibility. Fixes PR8713.
I've disabled a test which was testing that you can #pragma pop visibility
to get out of a namespace's visibility attribute. We should probably just
diagnose that as an error unless it's instrumental to someone's system
headers.
Douglas Gregor [Thu, 9 Dec 2010 23:35:36 +0000 (23:35 +0000)]
Don't crash when code-completing after "#include <". It would be far
better to actually produce a decent set of completions by checking the
system include paths, but not today. Fixes PR8744.
Douglas Gregor [Thu, 9 Dec 2010 21:44:02 +0000 (21:44 +0000)]
Don't walk the translation unit context to produce protocol names when
global code completions are disabled (e.g., because they are
cached). Also, make sure that forward-declared protocols are visited
when we look for all visible names within a declaration context.
Previously, we would end up with duplicate completions for protocols.
Bob Wilson [Thu, 9 Dec 2010 18:58:31 +0000 (18:58 +0000)]
Fix type of last vector operand of Neon quad-register multiple-lane intrinsics.
The sensible thing would be to have these intrinsics take all quad-register
vector operands, but that's not what ARM did. They made the last vector
operand always be a double-register type. Since the lane number
must be a constant, the user can know which half of a quad-register contains
that lane, extract the high or low half of the vector, and adjust the lane
number accordingly. The only advantage I can see for this is that it works
better when you want to multiply a quad-register value by a lane from a
double-register value, but I wouldn't have expected that to be the common
case. Oh well -- at this point we just need to follow the spec.
Bob Wilson [Thu, 9 Dec 2010 18:31:16 +0000 (18:31 +0000)]
Fix the names of the v[r]addhn and v[r]subhn Neon intrinsics.
Their suffixes are supposed to reflect the source operand element type,
not the destination element type. Radar 8746481.
Douglas Gregor [Thu, 9 Dec 2010 16:59:22 +0000 (16:59 +0000)]
When an "inline" declaration was followed by a definition not marked
"inline", we weren't giving the definition weak linkage because the
"inline" bit wasn't propagated. This was a longstanding FIXME that,
somehow, hadn't triggered a bug in the wild. Fix this problem by
tracking whether any declaration was marked "inline", and clean up the
semantics of GNU's "extern inline" semantics calculation based on this
change.
Before determining the effect the alignment of base struct will have in the aligment of the sub-struct,
take into account if the sub-struct is packed and its maximum field alignment.
Douglas Gregor [Thu, 9 Dec 2010 00:06:27 +0000 (00:06 +0000)]
A typename specifier can end up referring to a unresolved using
declaration that is a value in ill-formed code. Instead of crashing,
treat this as a dependent typename specifier and suggest that the
using add "typename" into the using declaration. Fixes <rdar://problem/8740998>.
Bob Wilson [Wed, 8 Dec 2010 22:37:56 +0000 (22:37 +0000)]
Stop using builtins for the "_lane" variants of saturating multiply intrinsics.
Remove the "splat" parameter from the EmitNeonCall function, since it is no
longer needed.