Douglas Gregor [Thu, 20 May 2010 02:24:22 +0000 (02:24 +0000)]
Various small fixes for construction/destruction of Objective-C++
instance variables:
- Use isRecordType() rather than isa<RecordType>(), so that we see
through typedefs in ivar types.
- Mark the destructor as referenced
- Perform C++ access control on the destructor
Chris Lattner [Thu, 20 May 2010 00:25:36 +0000 (00:25 +0000)]
switch TemplateArgumentListBuilder to hold its flat argument list in a smallvector
instead of new[]'d. This greatly reduces the number of new[]'s, and guess what,
they were all leaked.
where test/SemaTemplate/variadic-class-template-2.cpp is accessing the vector
out of range and NumPackArgs is negative. I assume variadic template args are
completely hosed.
Chris Lattner [Thu, 20 May 2010 00:19:09 +0000 (00:19 +0000)]
fix the TemplateArgumentList copy constructor to not
be a copy constructor (since it isn't one semantically)
and fix the ownership bits it sets to be correct!
Douglas Gregor [Wed, 19 May 2010 23:40:50 +0000 (23:40 +0000)]
When a conditional operator is an rvalue of class type, we need to
create a temporary copy of both the "true" and "false" results. Fixes
the Boost.Interprocess failures.
Daniel did all the hard work of tracking down the issue, I get to type
up the trivial fix for this horrible miscompile.
Daniel Dunbar [Wed, 19 May 2010 21:07:14 +0000 (21:07 +0000)]
Revert r104117, "Provide a naming class for UnresolvedLookupExprs, even when
occuring on..." which breaks some Objective-C code. Working on getting a test
case...
Douglas Gregor [Wed, 19 May 2010 18:39:18 +0000 (18:39 +0000)]
Cache the linkage of a type within its canonical type, eliminating
some seriously non-linear performance with deeply nested template
instantiations, as shown in PR6998.
Chandler Carruth [Wed, 19 May 2010 09:39:06 +0000 (09:39 +0000)]
Provide a naming class for UnresolvedLookupExprs, even when occuring on
template names. We were completely missing naming classes for many unqualified
lookups, but this didn't trigger code paths that need it. This removes part of
an optimization that re-uses the template name lookup done by the parser to
determine if explicit template arguments actually form a template-id.
Unfortunately the technique for avoiding the duplicate lookup lost needed data
such as the class context in which the lookup succeeded.
Douglas Gregor [Wed, 19 May 2010 04:13:23 +0000 (04:13 +0000)]
Profile type-dependent uses of overloaded operators in C++ the same
way regardless of whether some overloaded operator functions were
found by name lookup within the template. Fixes PR6851.
Chandler Carruth [Wed, 19 May 2010 02:12:56 +0000 (02:12 +0000)]
Fix a GCC warning about inline functions not being defined. Until r104081, only
the same .cpp file as provided the definitions referenced these functions,
hiding the issue. However, they are clearly no longer inline. Let me know if
there is a reason to move their definitions to the header and make them truly
inline.
Douglas Gregor [Tue, 18 May 2010 22:42:18 +0000 (22:42 +0000)]
Implement C++ support for vector and extended vector types. This
involves extending implicit conversion sequences to model vector
conversions and vector splats, along with teaching the C++ conditional
operator-checking code about vector types.
Ted Kremenek [Tue, 18 May 2010 22:32:15 +0000 (22:32 +0000)]
Add function 'clang_isTagDeclDefinition()' to allow clients of libclang to distinguish between
forward declarations and definitions of structs/classes/enums.
Ted Kremenek [Tue, 18 May 2010 21:09:07 +0000 (21:09 +0000)]
Teach CursorVisitor about duplicate ObjCPropertyDecls that can arise because of a current
design limitation in how we handle Objective-C class extensions. This was causing the CursorVisitor
to essentially visit an @property twice (once in the @interface, the other in the class extension).
Fixes <rdar://problem/7410145>.
Anders Carlsson [Tue, 18 May 2010 16:51:41 +0000 (16:51 +0000)]
Correctly initialize bases with member pointers. This should fix PR6441 but that test case is a bit weird and I'd like to investigate further before closing that bug.
Douglas Gregor [Tue, 18 May 2010 16:30:22 +0000 (16:30 +0000)]
Give a slight edge to the context-sensitive keyword 'super' over
non-function-local declarations with names similar to what the user
typed. For example, this allows us to correct 'supper' to 'super' in
an Objective-C message send, even though the C function 'isupper' has
the same edit distance.
Douglas Gregor [Tue, 18 May 2010 16:14:23 +0000 (16:14 +0000)]
Tweak typo-correction logic a bit regarding "super", so that we
consider "super" as a candidate whenever we're parsing an expression
within an Objective-C method in an interface that has a superclass. At
some point, we'd like to give "super" a little edge over non-local
names; that will come later.
Douglas Gregor [Tue, 18 May 2010 05:47:04 +0000 (05:47 +0000)]
"The attached patch allows clang to find the headers
for Visual Studio 2010. It also adds a registry search
for the Express edition,", from Steven Watanabe!
Douglas Gregor [Tue, 18 May 2010 05:45:02 +0000 (05:45 +0000)]
I hate this commit.
Revert much of the implementation of C++98/03 [temp.friend]p5 in
r103943 and its follow-ons r103948 and r103952. While our
implementation was technically correct, other compilers don't seem to
implement this paragraph (which forces the instantiation of friend
functions defined in a class template when a class template
specialization is instantiated), and doing so broke a bunch of Boost
libraries.
Since this behavior has changed in C++0x (which instantiates the
friend function definitions when they are used), we're going to skip
the nowhere-implemented C++98/03 semantics and go straight to the
C++0x semantics.
This commit is a band-aid to get Boost up and running again. It
doesn't really fix PR6952 (which this commit un-fixes), but it does
deal with the way Boost.Units abuses this particular paragraph.
Chandler Carruth [Mon, 17 May 2010 23:51:52 +0000 (23:51 +0000)]
Add a hack to silence warnings about failing to return from functions after
a temporary with a noreturn destructor has been created. Fixes PR6884 for now.
Ted Kremenek [Mon, 17 May 2010 23:03:33 +0000 (23:03 +0000)]
Clean up test case and remove XFAIL. This test can now distinguish between
cases where Clang can suggest and fix and suggest and not auto-fix (because of
current limitations).
Chris Lattner [Mon, 17 May 2010 20:27:25 +0000 (20:27 +0000)]
robustify the conflict marker stuff. Don't add 7 twice, which would
make it miss (invalid) things like:
<<<<<<<
>>>>>>>
and crash if
<<<<<<<
was at the end of the line. When we find a >>>>>>> that is not at the
end of the line, make sure to reset Pos so we don't crash on something
like:
<<<<<<< >>>>>>>
This isn't worth making testcases for, since each would require a new file.
Douglas Gregor [Mon, 17 May 2010 18:45:21 +0000 (18:45 +0000)]
Teach ASTContext::getUnqualifiedArrayType() how to look through
typedefs. As a drive-by, teach hit how to build VLA types, since those
will eventually be supported in C++.
Douglas Gregor [Mon, 17 May 2010 17:57:54 +0000 (17:57 +0000)]
Diagnose a redefinition error when there are two instantiations of friend
functions defined inside a class template. Fixes PR6952, the last
Boost.Units failure.
Douglas Gregor [Mon, 17 May 2010 17:34:56 +0000 (17:34 +0000)]
Determine when the instantiation of a friend function defined inside a
class template conflicts with an existing (non-template)
definition. This is another part of PR6952.
Douglas Gregor [Mon, 17 May 2010 16:38:00 +0000 (16:38 +0000)]
C++98/03 [temp.friend]p4 requires that inline function definitions
within class templates be instantiated along with each class template
specialization, even if the functions are not used. Do so, as a baby
step toward PR6952.
David Chisnall [Mon, 17 May 2010 13:49:20 +0000 (13:49 +0000)]
Pick the correct personality function based on the language. This prevents link failures when C/ObjC code uses __attribute__((cleanup())) (previously this was inserting references to two libstc++ symbols; the personality function and the __terminate() function).
This is still probably wrong for Objective-C++ and adds a couple of lines in CGException that should probably be in the CGObjCRuntime subclass. The personality function is now only looked up in one place in CGException though, so this should be easier to fix in the future.
Douglas Gregor [Sun, 16 May 2010 16:01:03 +0000 (16:01 +0000)]
When the type-id or new-type-id of a C++ "new" expression is a typedef
of an array type, use the outermost array bound as the number of
elements to allocate. Fixes PR7147.
Chandler Carruth [Sun, 16 May 2010 09:32:51 +0000 (09:32 +0000)]
When constant folding reference variables with an initializer to the
initializer, don't fold paramters. Their initializers are just default
arguments which can be overridden. This fixes some spectacular regressions due
to more things making it into the constant folding.
John McCall [Sun, 16 May 2010 02:09:32 +0000 (02:09 +0000)]
Avoid doing two switches in TypeLoc's initialize() loop. The optimizer
can probably do this for us, but it's actually somewhat nicer to write it
out here.
Douglas Gregor [Sun, 16 May 2010 01:24:12 +0000 (01:24 +0000)]
When initializing thread-safe statics, put the call to
__cxa_guard_abort along the exceptional edge into (in effect) a nested
"try" that rethrows after aborting. Fixes PR7144 and the remaining
Boost.ProgramOptions failures, along with the regressions that r103880
caused.
The crucial difference between this and r103880 is that we now follow
LLVM's little dance with the llvm.eh.exception and llvm.eh.selector
calls, then use _Unwind_Resume_or_Rethrow to rethrow.
Douglas Gregor [Sat, 15 May 2010 17:55:51 +0000 (17:55 +0000)]
When initializing thread-safe statics, put the call to
__cxa_guard_abort along the exceptional edge into (in effect) a nested
"try" that rethrows after aborting. Fixes PR7144 and the remaining
Boost.ProgramOptions failures.
Douglas Gregor [Sat, 15 May 2010 16:39:56 +0000 (16:39 +0000)]
When applying the named return value optimization, we still need to
destroy the variable along the exceptional edge; it's only during
normal execution that we avoid destroying this variable.
John McCall [Sat, 15 May 2010 11:32:37 +0000 (11:32 +0000)]
Substantially alter the design of the Objective C type AST by introducing
ObjCObjectType, which is basically just a pair of
one of {primitive-id, primitive-Class, user-defined @class}
with
a list of protocols.
An ObjCObjectPointerType is therefore just a pointer which always points to
one of these types (possibly sugared). ObjCInterfaceType is now just a kind
of ObjCObjectType which happens to not carry any protocols.
Alter a rather large number of use sites to use ObjCObjectType instead of
ObjCInterfaceType. Store an ObjCInterfaceType as a pointer on the decl rather
than hashing them in a FoldingSet. Remove some number of methods that are no
longer used, at least after this patch.
By simplifying ObjCObjectPointerType, we are now able to easily remove and apply
pointers to Objective-C types, which is crucial for a certain kind of ObjC++
metaprogramming common in WebKit.
Douglas Gregor [Sat, 15 May 2010 06:46:45 +0000 (06:46 +0000)]
Implement a simple form of the C++ named return value optimization for
return statements. We perform NRVO only when all of the return
statements in the function return the same variable. Fixes some link
failures in Boost.Interprocess (which is relying on NRVO), and
probably improves performance for some C++ applications.
Douglas Gregor [Sat, 15 May 2010 06:01:05 +0000 (06:01 +0000)]
Implement semantic analysis and an AST representation for the named
return value optimization. Sema marks return statements with their
NRVO candidates (which may or may not end up using the NRVO), then, at
the end of a function body, computes and marks those variables that
can be allocated into the return slot.
I've checked this locally with some debugging statements (not
committed), but there won't be any tests until CodeGen comes along.
Chris Lattner [Sat, 15 May 2010 05:53:53 +0000 (05:53 +0000)]
add type casts to _mm_shuffle_ps so the front-end applies
implicit conversions where needed. This fixes an error reported
on cfe-dev, not really worth a testcase though.
Douglas Gregor [Sat, 15 May 2010 00:13:29 +0000 (00:13 +0000)]
Recognize when the named return value optimization applies in a
"return" statement and mark the corresponding CXXConstructExpr as
elidable. Teach CodeGen that eliding a temporary is different from
eliding an object construction.