John McCall [Wed, 14 Jul 2010 04:38:21 +0000 (04:38 +0000)]
Remove a few mangling FIXMEs:
- TSTs whose template is a template template parameter already work
- we don't provide an imaginary type, so we can't mangle one
- we don't need a generic FIXME for vendor type qualifiers
John McCall [Wed, 14 Jul 2010 04:20:34 +0000 (04:20 +0000)]
Implement the standard mangling for array-subscript expressions, and implement
the current proposals from David Vandervoorde for new, delete, throw, typeid,
imaginary literals, string literals, and null literals.
John McCall [Tue, 13 Jul 2010 22:12:14 +0000 (22:12 +0000)]
Allow for the possibility that __cxa_end_catch might throw for a catch-all block
or a catch of a record type by value or reference. Also convert this to a
lazy cleanup.
John McCall [Tue, 13 Jul 2010 20:32:21 +0000 (20:32 +0000)]
Teach IR generation how to lazily emit cleanups. This has a lot of advantages,
mostly in avoiding unnecessary work at compile time but also in producing more
sensible block orderings.
Move the destructor cleanups for local variables over to use lazy cleanups.
Eventually all cleanups will do this; for now we have some awkward code
duplication.
Tell IR generation just to never produce landing pads in -fno-exceptions.
This is a much more comprehensive solution to a problem which previously was
half-solved by checks in most cleanup-generation spots.
Chris Lattner [Tue, 13 Jul 2010 19:41:32 +0000 (19:41 +0000)]
Add a warning to catch a bug recently caught by code review, like this:
t2.c:2:12: warning: use of logical && with constant operand; switch to bitwise &
or remove constant [-Wlogical-bitwise-confusion]
return x && 4;
^ ~
Douglas Gregor [Tue, 13 Jul 2010 18:40:04 +0000 (18:40 +0000)]
Whenever we're creating an expression that is typically an rvalue
(e.g., a call, cast, etc.), immediately adjust the expression's type
to strip cv-qualifiers off of all non-class types (in C++) or all
types (in C). This effectively extends my previous fix for PR7463,
which was restricted to calls, to other kinds of expressions within
similar characteristics. I've audited every use of
getNonReferenceType() in the code base, switching to the newly-renamed
getNonLValueExprType() where necessary.
Big thanks to Eli for pointing out just how incomplete my original fix
for PR7463 actually was. We've been handling cv-qualifiers on rvalues
wrong for a very, very long time. Fixes PR7463.
Douglas Gregor [Tue, 13 Jul 2010 15:54:32 +0000 (15:54 +0000)]
Downgrade the "when type is in parentheses, array cannot have dynamic
size" error for code like
new (int [size])
to a warning, add a Fix-It to remove the parentheses, and make this
diagnostic work properly when it occurs in a template
instantiation. <rdar://problem/8018245>.
Modify the pragma handlers to accept and use StringRefs instead of IdentifierInfos.
When loading the PCH, IdentifierInfos that are associated with pragmas cause declarations that use these identifiers to be deserialized (e.g. the "clang" pragma causes the "clang" namespace to be loaded).
We can avoid this if we just use StringRefs for the pragmas.
As a bonus, since we don't have to create and pass IdentifierInfos, the pragma interfaces get a bit more simplified.
Douglas Gregor [Tue, 13 Jul 2010 08:50:30 +0000 (08:50 +0000)]
Improve diagnostics for the "type qualifier on return type has no
effect warning" by printing the qualifiers we saw and correctly
pluralizing the message, e.g.,
test/SemaCXX/conditional-expr.cpp:295:3: warning: 'const volatile' type
qualifiers on return type have no effect
const volatile Enum g2() {
^~~~~ ~~~~~~~~
Douglas Gregor [Tue, 13 Jul 2010 08:37:11 +0000 (08:37 +0000)]
When computing the canonical profile of a DeclRefExpr or MemberExpr,
don't include the nested-name-specifier or template arguments: they
were only relevant when resolving the declaration. Fixes PR7460.
Douglas Gregor [Tue, 13 Jul 2010 08:18:22 +0000 (08:18 +0000)]
When forming a function call or message send expression, be sure to
strip cv-qualifiers from the expression's type when the language calls
for it: in C, that's all the time, while C++ only does it for
non-class types.
Centralized the computation of the call expression type in
QualType::getCallResultType() and some helper functions in other nodes
(FunctionDecl, ObjCMethodDecl, FunctionType), and updated all relevant
callers of getResultType() to getCallResultType().
Fixes PR7598 and PR7463, along with a bunch of getResultType() call
sites that weren't stripping references off the result type (nothing
stripped cv-qualifiers properly before this change).
Douglas Gregor [Tue, 13 Jul 2010 06:02:28 +0000 (06:02 +0000)]
Reinstate the optimization suppressing available_externally functions
at -O0. The only change from the previous patch is that we don't try
to generate virtual method thunks for an available_externally
function.
Douglas Gregor [Tue, 13 Jul 2010 00:10:04 +0000 (00:10 +0000)]
Provide a special diagnostic for attempts to explicitly specialize
class templates within class scope (which is ill-formed), and recover
by dropping the explicit specialization entirely. Fixes the infinite
loop in PR7622.
While collecting members for a class, always create delcaration entry for methods. Debug info for method definition will be generated while generating code for method body.
Tested by classes.exp in gdb testsuite.
Douglas Gregor [Mon, 12 Jul 2010 18:38:41 +0000 (18:38 +0000)]
Add a -code-completion-timing= mode to c-index-test, so that we can
test the performance of code-completion without testing the
performance of printf().
Douglas Gregor [Mon, 12 Jul 2010 17:24:55 +0000 (17:24 +0000)]
Do not generate LLVM IR for available_externally function bodies at
-O0, since we won't be using the definitions for anything anyway. For
lib/System/Path.o when built in Debug+Asserts mode, this leads to a 4%
improvement in compile time (and suppresses 440 function bodies).
Fix another aspect of PR7047, macro expansions. Previously, this was hacked
around by exempting enums from the check, but this doesn't handle a lot of
cases. A better approach is to directly check if the operator comes from
a macro expansion.
I've removed a reference to the rdar that originally led to the enum
suppression when removing it's overly contrived test case. Let me know if that
number or a more reasilistic test case involving enums is still needed.
Chris Lattner [Mon, 12 Jul 2010 04:25:32 +0000 (04:25 +0000)]
we do in fact have to cache the EOF token returned by the preprocessor.
In the case of backtracking, the cached token lexer will be the only
lexer on the stack, without this the token stack will be empty and EOF
won't be returned.
Chris Lattner [Mon, 12 Jul 2010 01:48:28 +0000 (01:48 +0000)]
revert a hunk of code that Argiris added in r106213, which is the
root cause of PR7481 and probably more, and has no apparent
testcases. I don't understand the logic here so I can't repair it.
Chris Lattner [Sun, 11 Jul 2010 22:42:07 +0000 (22:42 +0000)]
Fix PR7617 by not entering ParseFunctionDefinition when
a function prototype is followed by a declarator if we
aren't parsing a K&R style identifier list.
Also, avoid skipping randomly after a declaration if a
semicolon is missing. Before we'd get:
t.c:3:1: error: expected function body after function declarator
void bar();
^
Now we get:
t.c:1:11: error: invalid token after top level declarator
void foo()
^
;
Lay the ground work for resoving PR7047. This doesn't actually fix it because
default arguments to template parameters don't have a DeclContext when
instantiated, and so we can't detect that we're in an instantiation context as
opposed to the definition context. However, it fixes the more commonly-occuring
cases in TMP code that use devolve to this type of tautology after
substitution.
Sebastian Redl [Fri, 9 Jul 2010 21:00:24 +0000 (21:00 +0000)]
When given the -chained-pch option and a previous PCH file, have the PCHWriter emit a CHAINED_METADATA record instead of METADATA, and write a link to the previous file there.
Fix a crashing but trying to print a TemplateTemplateParmDecl
for code like this:
template<template<typename T> class U> class V {};
The problem is that the DeclPrinter assumed all TemplateDecls
have a getTemplatedClass(), but template template params don't
(so we got a NULL dereference). The solution is to detect if
we're a template template param, and construct the template
class name ('class U') specially in this case.
Rip out the floating point return type handling from the atomic builtin. It's
wrong, and we don't handle floating point value type arguments yet anyways.
Will add correct logic for both when I finish the patch.
Fix PR7600, and correctly convert the result of an atomic builtin to the
expected value type. This is necessary as the builtin is internally represented
as only operating on integral types.
Also, add a FIXME to add support for floating point value types.
Douglas Gregor [Fri, 9 Jul 2010 17:35:33 +0000 (17:35 +0000)]
Introduce -f{no-}spell-checking options to enable/disable
spell-checking. By default, spell-checking is enabled for Clang
(obviously) but disabled in CIndex for performance reasons.
Move traverseunqualifiedtypeloc over to the 'main' typeloc tree.
Note that this is a move -- we pretend that we were really looking
at the unqualified typeloc all along -- rather than a recursion, so
we don't follow the normal CRTP plan of going through
getDerived().TraverseTypeLoc. If we did, we'd be traversing twice
for the same type (once as a QualifiedTypeLoc version of the type,
once as an UnqualifiedTypeLoc version of the type), which in effect
means we'd call VisitTypeLoc twice with the 'same' type. This
solves that problem, at the cost of never seeing the qualified
version of the type (unless the client subclasses
TraverseQualifiedTypeLoc themselves). It's not a perfect solution.
A perfect solution probably requires making QualifiedTypeLoc a
wrapper around TypeLoc -- like QualType is a wrapper around Type*
-- rather than being its own class in the type hierarchy.
Sebastian Redl [Fri, 9 Jul 2010 00:00:58 +0000 (00:00 +0000)]
Add a frontend option -chained-pch and don't pass an active PCH reader to the PCH writer if it is not set, preventing creation of chained PCH files. Since the reader is so far unused, effectively no functionality change.
Douglas Gregor [Thu, 8 Jul 2010 23:20:03 +0000 (23:20 +0000)]
Introduce a new code-completion point prior to an identifier in the
selector of an Objective-C method declaration, e.g., given
- (int)first:(int)x second:(int)y;
this code completion point triggers at the location of "second". It
will provide completions that fill out the method declaration for any
known method, anywhere in the translation unit.
Douglas Gregor [Thu, 8 Jul 2010 20:55:51 +0000 (20:55 +0000)]
During code completion, give the "nil" and "NULL" macros the same
priority as other constants. And, if we're in a place where we prefer
a pointer type, consider "nil" and "NULL" to be close matches.
Douglas Gregor [Thu, 8 Jul 2010 18:37:38 +0000 (18:37 +0000)]
When performing substitution of template arguments within the body of
a template, be sure to include the template arguments from the
injected-class-name. Fixes PR7587.