Anders Carlsson [Sat, 29 Jan 2011 05:04:11 +0000 (05:04 +0000)]
When trying to get the most derived class, don't assume that we can ignore all casts. We can only ignore derived-to-base and no-op casts. Fixes selfhost.
Anders Carlsson [Sat, 29 Jan 2011 03:18:56 +0000 (03:18 +0000)]
When doing a derived-to-base class through a virtual class, we don't have to get the vbase offset from the vtable if the derived class is marked final.
John McCall [Fri, 28 Jan 2011 08:37:24 +0000 (08:37 +0000)]
Convert the exception-freeing cleanup over to the conditional cleanups code,
fixing a crash which probably nobody was ever going to see. In doing so,
fix a horrendous number of problems with the conditional-cleanups code.
Also, make conditional cleanups re-use the cleanup's activation variable,
which avoids some unfortunate repetitiveness.
Douglas Gregor [Fri, 28 Jan 2011 02:26:04 +0000 (02:26 +0000)]
Give OpaqueValueExpr a source location, because its source location
might be queried in places where we absolutely require a valid
location (e.g., for template instantiation). Fixes some major
brokenness in the use of __is_convertible_to.
Douglas Gregor [Thu, 27 Jan 2011 23:22:05 +0000 (23:22 +0000)]
When producing IR for a lvalue-to-rvalue cast *as an lvalue*, only
non-class prvalues actually require the realization of a
temporary. For everything else, we already have an lvalue (or class
prvalue) in the subexpression.
Note: we're missing some move elision in this case. I'll tackle that next.
Douglas Gregor [Thu, 27 Jan 2011 22:31:44 +0000 (22:31 +0000)]
Teach the evaluation of the __is_convertible_to trait to translate
access control errors into SFINAE errors, so that the trait provides
enough support to implement the C++0x std::is_convertible type trait.
To get there, the SFINAETrap now knows how to set up a SFINAE context
independent of any template instantiations or template argument
deduction steps, and (separately) can set a Sema flag to translate
access control errors into SFINAE errors. The latter can also be
useful if we decide that access control errors during template argument
deduction should cause substitution failure (rather than a hard error)
as has been proposed for C++0x.
Douglas Gregor [Thu, 27 Jan 2011 20:28:01 +0000 (20:28 +0000)]
Implement the Microsoft __is_convertible_to type trait, modeling the
semantics after the C++0x is_convertible type trait. This
implementation is not 100% complete, because it allows access errors
to be hard errors (rather than just evaluating false).
Douglas Gregor [Thu, 27 Jan 2011 18:02:58 +0000 (18:02 +0000)]
Teach ASTUnit to save the specified target features, since
TargetInfo::CreateTargetInfo() mangles the target options in a way
that is not idempotent. Fixes <rdar://problem/8807535>.
Axel Naumann [Thu, 27 Jan 2011 10:55:51 +0000 (10:55 +0000)]
TextDiagnosticPrinter.cpp: Show diagnostics as far as possible even with invalid PresomedLoc, instead of just silencing it.
FileManager.cpp: Allow virtual files in nonexistent directories.
FileManager.cpp: Close FileDescriptor for virtual files that correspond to actual files.
FileManager.cpp: Enable virtual files to be created even for files that were flagged as NON_EXISTENT_FILE, e.g. by a prior (unsuccessful) addFile().
ASTReader.cpp: Read a PCH even if the original source files cannot be found.
Add a test for reading a PCH of a file that has been removed and diagnostics referencing that file.
John McCall [Thu, 27 Jan 2011 09:37:56 +0000 (09:37 +0000)]
Do a proper recursive lookup when deciding whether a class's usual
deallocation function has a two-argument form. Store the result of this
check in new[] and delete[] nodes.
John McCall [Thu, 27 Jan 2011 08:17:49 +0000 (08:17 +0000)]
Provide Type::castAs<>, which is to getAs<> what cast<> is to dyn_cast<>.
Also provide a method to grab the base element type of a type without
stressing out over qualifiers (but give it a nice scary name).
Douglas Gregor [Thu, 27 Jan 2011 01:40:17 +0000 (01:40 +0000)]
When we run into a template parameter that should have a default
argument but doesn't (because previous template parameters had default
arguments), clear out all of the default arguments so that we maintain
the invariant that a template parameter has a default argument only if
subsequence template parameters also have default arguments.
Fixes a crash-on-invalid <rdar://problem/8913649>.
Douglas Gregor [Thu, 27 Jan 2011 00:58:17 +0000 (00:58 +0000)]
Fix a horrible bug in our handling of C-style casting, where a C-style
derived-to-base cast that also casts away constness (one of the cases
for static_cast followed by const_cast) would be treated as a bit-cast
rather than a derived-to-base class, causing miscompiles and
heartburn.
Douglas Gregor [Wed, 26 Jan 2011 21:20:37 +0000 (21:20 +0000)]
Implement the restriction that a function with a ref-qualifier cannot
overload a function without a ref-qualifier (C++0x
[over.load]p2). This, apparently, completes the implementation of
rvalue references for *this.
Douglas Gregor [Wed, 26 Jan 2011 20:35:32 +0000 (20:35 +0000)]
Improve the extension warning for the use of ref-qualifiers, to
distinguish them from rvalue references. Using the rvalue-references
warning was weird when the ref-qualifier was '&'.
Douglas Gregor [Wed, 26 Jan 2011 19:41:18 +0000 (19:41 +0000)]
Rvalue references for *this: explicitly keep track of whether a
reference binding is for the implicit object parameter of a member
function with a ref-qualifier. My previous comment, that we didn't
need to track this explicitly, was wrong: we do in fact get
rvalue-references-prefer-rvalues overloading with ref-qualifiers.
Douglas Gregor [Wed, 26 Jan 2011 19:30:28 +0000 (19:30 +0000)]
Rvalue references for *this: implement the implicit conversion rules
for the implicit object argument to a non-static member function with
a ref-qualifier (C++0x [over.match.funcs]p4).
Douglas Gregor [Wed, 26 Jan 2011 17:47:49 +0000 (17:47 +0000)]
Rvalue references for *this: allow functions to be overloaded based on
the presence and form of a ref-qualifier. Note that we do *not* yet
implement the restriction in C++0x [over.load]p2 that requires either
all non-static functions with a given parameter-type-list to have a
ref-qualifier or none of them to have a ref-qualifier.
Douglas Gregor [Wed, 26 Jan 2011 17:36:28 +0000 (17:36 +0000)]
Rvalue references for *this: add name mangling for ref-qualifiers,
using rules that I just made up this morning. This encoding has now
been proposed to the Itanium C++ ABI group for inclusion, but of
course it's still possible that the mangling will change.
Douglas Gregor [Wed, 26 Jan 2011 15:36:03 +0000 (15:36 +0000)]
Clean up the C++0x __has_feature tests. Specifically:
- Don't publicize a C++0x feature through __has_feature if we aren't
in C++0x mode (even if the feature is available only with a
warning).
- "auto" is not implemented well enough for its __has_feature to be
turned on.
- Fix the test of C++0x __has_feature to actually test what we're
trying to test. Searching for the substring "foo" when our options
are "foo" and "no_foo" doesn't work :)
Douglas Gregor [Wed, 26 Jan 2011 05:01:58 +0000 (05:01 +0000)]
Rvalue references for *this:
- Add ref-qualifiers to the type system; they are part of the
canonical type. Print & profile ref-qualifiers
- Translate the ref-qualifier from the Declarator chunk for
functions to the function type.
- Diagnose mis-uses of ref-qualifiers w.r.t. static member
functions, free functions, constructors, destructors, etc.
- Add serialization and deserialization of ref-qualifiers.
Ted Kremenek [Wed, 26 Jan 2011 04:49:52 +0000 (04:49 +0000)]
Teach -Wreturn-type that destructors can appear
after a 'return' in a CFGBlock. This accidentally
was working before, but the false assumption that
'return' always appeared at the end of the block
was uncovered by a recent change.
John McCall [Wed, 26 Jan 2011 04:00:11 +0000 (04:00 +0000)]
Better framework for conditional cleanups; untested as yet.
I'm separately committing this because it incidentally changes some
block orderings and minor IR issues, like using a phi instead of
an unnecessary alloca.
[analyzer] Enable the self-init checker under command-line option '-analyzer-check-objc-self-init' which by default
is enabled by the driver for '--analyze'.