John McCall [Tue, 9 Nov 2010 01:18:05 +0000 (01:18 +0000)]
When re-using a vtable slot for the nearest overridden method, just because
there's no return adjustment from the overridden to the overrider doesn't
mean there isn't a return adjustment from the overrider to the final
overrider. This matters if we're emitting a virtual this-adjustment thunk
because the overrider virtually inherits from the class providing the
nearest overridden method. Do the appropriate return adjustment in this case.
Nick Lewycky [Tue, 9 Nov 2010 00:19:31 +0000 (00:19 +0000)]
Fix warning about unused variable 'Fn' in no-asserts builds. Also reflow this
block so that it looks more like the rest of the file. No functional change.
Ted Kremenek [Mon, 8 Nov 2010 21:14:15 +0000 (21:14 +0000)]
Add CursorVisitor::VisitBinaryOperator() to explicitly handle the case where we can blow out the stack due
to deeply nested BinaryOperators. This is done by turning the explicit recursion into being data recursive.
Douglas Gregor [Mon, 8 Nov 2010 21:12:30 +0000 (21:12 +0000)]
If an instance method messages is sending to an expression of type Class,
and we statically can compute a bound on the actual type (e.g.,
because it's a send to the the magic "class" instance method), code
complete as if we were performing a class message send to that class.
John McCall [Mon, 8 Nov 2010 19:48:17 +0000 (19:48 +0000)]
Document Clang's support for attributes on individual enumerators and
tweak the documentation for deprecation-with-message. Provide __has_feature
tests for both. rdar://problem/8605692
Douglas Gregor [Mon, 8 Nov 2010 17:16:59 +0000 (17:16 +0000)]
Improve our handling of C++ [class.copy]p3, which specifies that a
constructor template will not be used to copy a class object to a
value of its own type. We were eliminating all constructor templates
whose specializations look like a copy constructor, which eliminated
important candidates. Fixes PR8182.
Douglas Gregor [Mon, 8 Nov 2010 15:20:28 +0000 (15:20 +0000)]
When attempting reference binding to an overloaded function, also
consider that we might be trying to bind a reference to a class type,
which involves a constructor call. Fixes PR7425.
Douglas Gregor [Sun, 7 Nov 2010 23:05:16 +0000 (23:05 +0000)]
Remove broken support for variadic templates, along with the various
abstractions (e.g., TemplateArgumentListBuilder) that were designed to
support variadic templates. Only a few remnants of variadic templates
remain, in the parser (parsing template type parameter packs), AST
(template type parameter pack bits and TemplateArgument::Pack), and
Sema; these are expected to be used in a future implementation of
variadic templates.
But don't get too excited about that happening now.
Use ld directly on linux. Changes from the previous try:
*) Try to detect as much as possible from the system itself, not the distro.
This should make it easier to port to a new distro and more likely to
work on a unknown one.
*) The distro enum now doesn't include the arch. Just use the existing
host detection support in LLVM.
*) Correctly handle --sysroot.
A small regression is that now clang will pass bitcode file to the linker.
This is necessary for the gold plugin support to work.
It might be better to detect this at configure/cmake time, but doing it in
c++ first is a lot easier.
John McCall [Sat, 6 Nov 2010 09:44:32 +0000 (09:44 +0000)]
Simplify the logic for emitting guard variables for template static
data members by delaying the emission of the initializer until after
linkage and visibility have been set on the global. Also, don't
emit a guard unless the variable actually ends up with vague linkage,
and don't use thread-safe statics in any case.
The callback info for #if/#elif is not great -- ideally it would give
us a list of tokens in the #if, or even better, a little parse tree.
But that's a lot more work. Instead, clients can retokenize using
Lexer::LexFromRawLexer().
When determining which template partial specialization is more specialized,
make sure to setup the instantiation stack. Fixes rdar://8620775 & http://llvm.org/PR8234
Douglas Gregor [Fri, 5 Nov 2010 23:22:45 +0000 (23:22 +0000)]
When searching for an instantiated declaration requires instantiation
of its parent context, be sure to update the parent-context pointer
after instantiation. Fixes two anonymous-union instantiation issues in
<rdar://problem/8635664>.
Douglas Gregor [Fri, 5 Nov 2010 22:21:31 +0000 (22:21 +0000)]
Check for an invalid field earlier in a constructor's initialization
of that field. Otherwise, we can end up building and later trying to
instantiate a dependent member initializer that will fail at
instantiation time.
Unfortunately, I've only managed to trigger this bug with very large
sources, so there's no test case :(
Douglas Gregor [Fri, 5 Nov 2010 21:11:19 +0000 (21:11 +0000)]
Teach clang_getCursorReferenced() that a
CXXConstructorExpr/CXXTemporaryObjectExpr references the constructor
it calls. Then, tweak clang_getCursor() to prefer such a call over a
type reference to the type being called.
Douglas Gregor [Thu, 4 Nov 2010 00:09:33 +0000 (00:09 +0000)]
When canonicalizing nested-name-specifiers involving dependent names
or dependent specializations, rip apart the dependent name/dependent
specialization to recanonicalize its pieces, because
nested-name-specifiers store "dependent-type::identifier" differently
than types do. Fixes PR7419.
When -working-directory is passed in command line, file paths are resolved relative to the specified directory.
This helps both when using libclang (where we can't require the user to actually change the working directory)
and to help reproduce test cases when the reproduction work comes along.
--FileSystemOptions is introduced which controls how file system operations are performed (currently it just contains
the working directory value if set).
--FileSystemOptions are passed around to various interfaces that perform file operations.
--Opening & reading the content of files should be done only through FileManager. This is useful in general since
file operations will be abstracted in the future for the reproduction mechanism.
FileSystemOptions is independent of FileManager so that we can have multiple translation units sharing the same
FileManager but with different FileSystemOptions.
Douglas Gregor [Wed, 3 Nov 2010 17:00:07 +0000 (17:00 +0000)]
When producing overload candidates for binary built-in operators, keep
the sets of available conversions for the first and second arguments
separate. This is apparently the indent of C++ [over.built], and
reduces the number of overload candidates generated, eliminating some
ambiguities. Fixes PR8477.
David Chisnall [Wed, 3 Nov 2010 14:12:26 +0000 (14:12 +0000)]
Added cursor visitor that takes a block as an argument. Tested compiling
libclang with both clang -fblocks and gcc (no blocks support). Only exposed in
the header to compilers that do have blocks support.
Added generating destructors for temporary objects. Two cases I know of, that are not handled properly:
1. For statement: const C& c = C(0) ?: C(1) destructors generated for condition will not differ from those generated for case without prolonged lifetime of temporary,
2. There will be no destructor for constant reference member bound to temporary at the exit from constructor.
Switch clang to run ld directly on linux. I tested this on all the linux
distros listed by running
gcc main.o -o main
g++ main.o -o main
gcc main.o -o main -static
g++ main.o -o main -static
gcc f.o -o f.so -shared
g++ f.o -o f.so -shared
and comparing the ld line with the one created by clang. I also added
-m32/m64 in distros that support it.
While I tested many distros, there will always be more. If you are hit by this
it should be somewhat easy to add your distro. If you are in a hurry, do
revert this, but please inform how to detect you distro and the ld command
lines produced by the above gcc invocations. Most distros have some patches
on gcc :-(
Douglas Gregor [Wed, 3 Nov 2010 00:35:38 +0000 (00:35 +0000)]
Improve source-location information for CXXConstructExpr nodes, by
ensuring that they cover all of their child nodes. There's still a
clang_getCursor()-related issue with CXXFunctionalCastExprs with
CXXConstructExprs as children (see FIXME in the test case); I'll look
at that separately.
Ted Kremenek [Tue, 2 Nov 2010 23:10:24 +0000 (23:10 +0000)]
Hack to workaround deficiency in ObjC ASTs. Functions and variables may be declared
within an @implementation, but we have no way to record that information in the AST.
This may cause CursorVisitor to miss these Decls when doing a AST walk.
John McCall [Tue, 2 Nov 2010 01:45:15 +0000 (01:45 +0000)]
Ignore attributes on classes when calculating visibility for members
with their own explicit visibility attributes. Basically we only want to
apply a single visibility attribute from any particular ancestry.
Douglas Gregor [Tue, 2 Nov 2010 00:02:34 +0000 (00:02 +0000)]
When performing template argument deduction against a template-id,
only keep deduction results for successful deductions, so that they
can be compared against each other. Fixes PR8462, from Richard Smith!