Douglas Gregor [Wed, 26 May 2010 07:10:06 +0000 (07:10 +0000)]
When transforming a C++ "new" expression's constructor arguments, drop
any arguments that are default-argument expressions. The can show up
when we have a new expression whose constructor arguments are not
type-dependent and whose allocated type is not dependent and has a
constructor with default arguments. Fixes PR7202.
Douglas Gregor [Wed, 26 May 2010 05:35:51 +0000 (05:35 +0000)]
Tell the string literal parser when it's not permitted to emit
diagnostics. That would be while we're parsing string literals for the
sole purpose of producing a diagnostic about them. Fixes
<rdar://problem/8026030>.
Anders Carlsson [Wed, 26 May 2010 04:56:53 +0000 (04:56 +0000)]
Move the relevant ASTContext member functions that deal with ASTRecordLayoutBuilder into RecordLayoutBuilder.cpp. This matches the way we interact with other builder classes (CGRecordLayoutBuilder, VTableBuilder and VTTBuilder) and it also allows for making ASTRecordLayoutBuilder a private class without a header file.
Ted Kremenek [Tue, 25 May 2010 20:43:29 +0000 (20:43 +0000)]
Allocate the contents of TemplateArgumentList using ASTContext's allocator. This fixes
a massive memory leak when using a BumpPtrAllocator in ASTContext.
Added a FIXME, as the Destroy method for TemplateArgumentList isn't getting called.
This means we will instead leak when using the MallocAllocator.
Charles Davis [Tue, 25 May 2010 19:52:27 +0000 (19:52 +0000)]
IRgen: Add a stub class for generating ABI-specific C++ code.
This class only supports name mangling (which is apparently used during C/ObjC
codegen). For now only the Itanium C++ ABI is supported. Patches to add a
second C++ ABI are forthcoming.
Douglas Gregor [Tue, 25 May 2010 17:04:15 +0000 (17:04 +0000)]
Improve name mangling for blocks and support mangling of static local
variables within blocks. We loosely follow GCC's mangling, but since
these are always internal symbols the names don't really matter. I
intend to revisit block mangling later, because GCC's mangling is
rather verbose. <rdar://problem/8015719>.
Douglas Gregor [Tue, 25 May 2010 05:58:43 +0000 (05:58 +0000)]
Improve code completion in failure cases in two ways:
1) Suppress diagnostics as soon as we form the code-completion
token, so we don't get any error/warning spew from the early
end-of-file.
2) If we consume a code-completion token when we weren't expecting
one, go into a code-completion recovery path that produces the best
results it can based on the context that the parser is in.
Zhongxing Xu [Tue, 25 May 2010 04:59:19 +0000 (04:59 +0000)]
CastSizeChecker checks when casting a malloc'ed symbolic region to type T,
whether the size of the symbolic region is a multiple of the size of T.
Fixes PR6123 and PR7217.
John McCall [Tue, 25 May 2010 04:30:21 +0000 (04:30 +0000)]
If a function definition has any sort of weak linkage, its static local
variables should have that linkage. Otherwise, its static local
variables should have internal linkage. To avoid computing this excessively,
set a function's linkage before we emit code for it.
Previously we were assigning weak linkage to the static variables of
static inline functions in C++, with predictably terrible results. This
fixes that and also gives better linkage than 'weak' when merging is required.
Daniel Dunbar [Tue, 25 May 2010 00:33:13 +0000 (00:33 +0000)]
IRgen/C++: When mark vtables used, make sure to still append to the VTableUse array if we promote a vtable from being just used to having its definition required. This ensures that we properly inform the consumer about whether the vtable is required or not, previously we could fail to do so when the vtable was in the VTableUses array before the decl which marked it as required.
- I think this can be cleaned up, since this means we may notify the consumer about the vtable twice, but I didn't see an easy fix for this without more substantial refactoring.
- Doug, please review!
Chris Lattner [Mon, 24 May 2010 22:31:37 +0000 (22:31 +0000)]
improve the fixit for the missing : error when parsing ?:. When
there are already two spaces before the token where the : was expected,
put the : in between the spaces. This means we get it right in both
of these cases:
t.c:2:17: error: expected ':'
return a ? b c;
^
:
t.c:3:16: error: expected ':'
return a ? b c;
^
:
In the later case, the diagnostic says to insert ": ", in the former
case it says to insert ":" between the spaces. This fixes rdar://8007231
Chris Lattner [Mon, 24 May 2010 21:35:18 +0000 (21:35 +0000)]
push categories forward a bit more: document them, add some
major buckets to catch parser and sema issues, add inline asm
category, and make diag groups take precedence over the
sweeping categories just added.
Douglas Gregor [Mon, 24 May 2010 17:01:56 +0000 (17:01 +0000)]
Downgrade deletion of a void* from an error (which is should be) to an
extension warning (which other compilers seem to use). Works around a
known bug in Xalan.
Douglas Gregor [Sun, 23 May 2010 19:57:01 +0000 (19:57 +0000)]
It turns out that people love using VLAs in templates, too. Weaken our
VLA restrictions so that one can use VLAs in templates (even
accidentally), but not as part of a non-type template parameter (which
would be very bad).
Douglas Gregor [Sun, 23 May 2010 18:57:34 +0000 (18:57 +0000)]
Provide the overloaded functions for UnresolvedLookupExpr and
UnresolvedMemberExpr in their constructors, rather than adding them
after the fact. No functionality change.
Douglas Gregor [Sun, 23 May 2010 18:26:36 +0000 (18:26 +0000)]
Keep track of all of the class and function template's "common"
pointers in the ASTContext, so that the folding sets stored inside
them will be deallocated when the ASTContext is destroyed (under
-disable-free). <rdar://problem/7998824>.
John McCall [Sat, 22 May 2010 22:13:32 +0000 (22:13 +0000)]
Re-teach IR gen to perform GC moves on rvalues resulting from various ObjC
expressions. Essentially, GC breaks a certain form of the return-value
optimization.
Douglas Gregor [Sat, 22 May 2010 16:17:30 +0000 (16:17 +0000)]
Implement support for variable length arrays in C++. VLAs are limited
in several important ways:
- VLAs of non-POD types are not permitted.
- VLAs cannot be used in conjunction with C++ templates.
These restrictions are intended to keep VLAs out of the parts of the
C++ type system where they cause the most trouble. Fixes PR5678 and
<rdar://problem/8013618>.
Douglas Gregor [Sat, 22 May 2010 05:17:18 +0000 (05:17 +0000)]
Improve our handling of reference binding for subobjects of
temporaries. There are actually several interrelated fixes here:
- When converting an object to a base class, it's only an lvalue
cast when the original object was an lvalue and we aren't casting
pointer-to-derived to pointer-to-base. Previously, we were
misclassifying derived-to-base casts of class rvalues as lvalues,
causing various oddities (including problems with reference binding
not extending the lifetimes of some temporaries).
- Teach the code for emitting a reference binding how to look
through no-op casts and parentheses directly, since
Expr::IgnoreParenNoOpCasts is just plain wrong for this. Also, make
sure that we properly look through multiple levels of indirection
from the temporary object, but destroy the actual temporary object;
this fixes the reference-binding issue mentioned above.
- Teach Objective-C message sends to bind the result as a temporary
when needed. This is actually John's change, but it triggered the
reference-binding problem above, so it's included here. Now John
can actually test his return-slot improvements.
Chandler Carruth [Sat, 22 May 2010 02:21:53 +0000 (02:21 +0000)]
Daniel re-educated me about what Alias does and does not do. Turn that off for
'-fasm' and explicitly map from that flag to -fgnu-keywords in the driver. Turn
off the driver in the lexer test for this madness and add a test to the driver
that the translation actually works.
John McCall [Sat, 22 May 2010 01:48:05 +0000 (01:48 +0000)]
Push a return-value slot throughout ObjC message-send codegen. Will be
critical for ObjC++ correctness; hard to test independently of various
required Sema changes, though.
Daniel Dunbar [Sat, 22 May 2010 00:37:20 +0000 (00:37 +0000)]
Driver: When printing a "command was signalled" type of diagnostic, use the
short name of the tool in use, instead of the name of the action that created
the command. The practical impact is we now get:
clang: error: clang frontend command failed due to signal 6 (use -v to see invocation)
instead of:
clang: error: assembler command failed due to signal 6 (use -v to see invocation)
when clang crashes on a job that uses the integrated assembler.
Douglas Gregor [Fri, 21 May 2010 23:43:39 +0000 (23:43 +0000)]
Improve recovery when we see a dependent template name that is missing
the required "template" keyword, using the same heuristics we do for
dependent template names in member access expressions, e.g.,
test/SemaTemplate/dependent-template-recover.cpp:11:8: error: use 'template'
keyword to treat 'getAs' as a dependent template name
T::getAs<U>();
^
template
Douglas Gregor [Fri, 21 May 2010 23:18:07 +0000 (23:18 +0000)]
Improve parser recovery when we encounter a dependent template name
that is missing the 'template' keyword, e.g.,
t->getAs<T>()
where getAs is a member of an unknown specialization. C++ requires
that we treat "getAs" as a value, but that would fail to parse since T
is the name of a type. We would then fail at the '>', since a type
cannot be followed by a '>'.
This is a very common error for C++ programmers to make, especially
since GCC occasionally allows it when it shouldn't (as does Visual
C++). So, when we are in this case, we use tentative parsing to see if
the tokens starting at "<" can only be parsed as a template argument
list. If so, we produce a diagnostic with a fix-it that states that
the 'template' keyword is needed:
test/SemaTemplate/dependent-template-recover.cpp:5:8: error: 'template' keyword
is required to treat 'getAs' as a dependent template name
t->getAs<T>();
^
template
This is just a start of this patch; I'd like to apply the same
approach to everywhere that a template-id with dependent template name
can be parsed.
Nick Lewycky [Fri, 21 May 2010 23:14:51 +0000 (23:14 +0000)]
Outdent this file by 2 spaces per the coding standards, and also clean up
whitespace at the end of lines since I'm already touching the whole file
anyways.