Douglas Gregor [Fri, 21 Jan 2011 22:46:35 +0000 (22:46 +0000)]
When throwing an elidable object, first try to treat the subexpression
as an rvalue per C++0x [class.copy]p33. If that fails, try again with
the original subexpression.
Ted Kremenek [Fri, 21 Jan 2011 19:41:41 +0000 (19:41 +0000)]
Enhance -Wuninitialized-experimental diagnostics
to issue the warning at an uninitialized variable's
declaration, but to issue notes at possible
uninitialized uses (which could be multiple).
Douglas Gregor [Fri, 21 Jan 2011 19:38:21 +0000 (19:38 +0000)]
Implement the preference for move-construction over copy-construction
when returning an NRVO candidate expression. For example, this
properly picks the move constructor when dealing with code such as
Douglas Gregor [Fri, 21 Jan 2011 18:05:27 +0000 (18:05 +0000)]
Promote the static getNRVOCandidate() function, which computed the
NRVO candidate for a return statement, to
Sema::getCopyElisionCandidate(), and teach it enough to also determine
the NRVO candidate for a throw expression. We still don't use the
latter information, however.
Along the way, implement core issue 1148, which eliminates copy
elision from catch parameters and clarifies that copy elision cannot
occur from function parameters (which we already implemented).
Douglas Gregor [Fri, 21 Jan 2011 16:48:38 +0000 (16:48 +0000)]
Add test for overload resolution's preference for binding an rvalue
reference to an rvalue rather than binding a const-qualified lvalue
reference to that rvalue.
Douglas Gregor [Fri, 21 Jan 2011 16:36:05 +0000 (16:36 +0000)]
Update the reference-binding implementation used for overload
resolution to match the latest C++0x working paper's semantics. The
implementation now matching up with the reference-binding
implementation used for initialization.
Douglas Gregor [Fri, 21 Jan 2011 05:18:22 +0000 (05:18 +0000)]
Implement the special template argument deduction rule for T&& in a
call (C++0x [temp.deduct.call]p3).
As part of this, start improving the reference-binding implementation
used in the computation of implicit conversion sequences (for overload
resolution) to reflect C++0x semantics. It still needs more work and
testing, of course.
Inheritable attributes on declarations may be inherited by any later
redeclaration at merge time. By contrast, a non-inheritable attribute
will not be inherited by later redeclarations. Non-inheritable
attributes may be semantically analysed early, allowing them to
influence the redeclaration/overloading process.
Before this change, the "overloadable" attribute received special
handling to be treated as non-inheritable, while all other attributes
were treated as inheritable. This patch generalises the concept,
while removing a FIXME. Some CUDA location attributes are also marked
as non-inheritable in order to support special overloading semantics
(to be introduced in a later patch).
The patch introduces a new Attr subclass, InheritableAttr, from
which all inheritable attributes derive. Non-inheritable attributes
simply derive from Attr.
N.B. I did not review every attribute to determine whether it should
be marked non-inheritable. This can be done later on an incremental
basis, as this change does not affect default functionality.
Douglas Gregor [Fri, 21 Jan 2011 00:52:42 +0000 (00:52 +0000)]
More work to bring reference binding up to the latest C++0x
specification. In particular, an rvalue reference can bind to an
initializer expression that is an lvalue if the referent type and the
initializer expression type are not reference-related. This is a newer
formulation to the previous "rvalue references can never bind to
lvalues" rule.
Douglas Gregor [Fri, 21 Jan 2011 00:27:08 +0000 (00:27 +0000)]
When performing reference binding via a conversion function, perform
type checking based on the actual reference type we're trying to bind
the result to, rather than stripping the reference.
Ted Kremenek [Thu, 20 Jan 2011 21:25:31 +0000 (21:25 +0000)]
Relax CFG assertions in UninitializedValuesV2 when
handling pseudo-path sensitivity, and instead
use those assertion conditions as dynamic checks.
These assertions would be violated when analyzing
a CFG where some branches where optimized away
during CFG construction because their branch
conditions could be trivially determined.
Ted Kremenek [Thu, 20 Jan 2011 19:45:14 +0000 (19:45 +0000)]
Add test case for <rdar://problem/8891119>. In
earlier revisions Clang was incorrectly warning
about an incomplete @implementation when a property
was getting synthesized. This got fixed somewhere
down the line.
Ted Kremenek [Thu, 20 Jan 2011 17:37:17 +0000 (17:37 +0000)]
Add rudimentary path-sensitivity to UnintializedValuesV2
analysis for short-circuited operations. For branch written like "if (x && y)",
we maintain two sets of dataflow values for the outgoing
branches. This suppresses some common false positives
for -Wuninitialized-experimental.
This change introduces some assertion failures
when running on the LLVM codebase. WIP.
Douglas Gregor [Thu, 20 Jan 2011 16:44:54 +0000 (16:44 +0000)]
Start refactoring reference binding to more closely match the C++0x
working paper's structure. The only functional change here is that we
now handling binding to array rvalues, which we would previously reject.
Douglas Gregor [Thu, 20 Jan 2011 16:08:06 +0000 (16:08 +0000)]
Add some tests for reference-collapsing and referencing binding
involving rvalue references, to start scoping out what is and what
isn't implemented. In the process, tweak some standards citations,
type desugaring, and teach the tentative parser about && in
ptr-operator.
Rafael Espindola [Thu, 20 Jan 2011 02:26:24 +0000 (02:26 +0000)]
Fix PR8884 by skipping transparent contexts. The test is for LikageSpec. I
failed to find a case where an enum context would make a difference, but
found PR9007 on the way.
Douglas Gregor [Thu, 20 Jan 2011 01:32:05 +0000 (01:32 +0000)]
When building a user-defined conversion sequence, keep track of the
declaration that name lookup actually found, so that we can use it for
access checking later on. Fixes <rdar://problem/8876150>.
Douglas Gregor [Thu, 20 Jan 2011 00:18:04 +0000 (00:18 +0000)]
Sema::BuildCXXMemberCallExpr() can fail due to access or ambiguities,
so allow it to propagate the failure outward. Fixes the crashing part
of <rdar://problem/8876150>.
Douglas Gregor [Wed, 19 Jan 2011 23:54:39 +0000 (23:54 +0000)]
Explicitly track the number of call arguments provided when performing
overload resolution, so that we only use that number of call arguments
for partial ordering. Fixes PR9006, a recent regression.
Douglas Gregor [Wed, 19 Jan 2011 21:59:15 +0000 (21:59 +0000)]
Downgrade the "variadic templates are a C++0x feature" error to an
ExtWarn. We want variadic templates to be usable in libc++/libstdc++
headers even when we're in C++98/03 mode, since it's the only clean
way to implement TR1 <functional>.
Douglas Gregor [Wed, 19 Jan 2011 21:52:31 +0000 (21:52 +0000)]
Refactor the dependence computation for DeclRefExpr so that we can
reuse it for BlockDeclRefExpr. Do so, fixing the dependence calculate
for BlockDeclRefExpr.
Douglas Gregor [Wed, 19 Jan 2011 21:32:01 +0000 (21:32 +0000)]
Implement basic support for the use of variadic templates and blocks
together. In particular:
- Handle the use of captured parameter pack names within blocks
(BlockDeclRefExpr understands parameter packs now)
- Handle the declaration and expansion of parameter packs within a block's
parameter list, e.g., ^(Args ...args) { ... })
- Handle instantiation of blocks where the return type was not
explicitly specified. (unrelated, but necessary for my tests).
Together, these fixes should make blocks and variadic templates work
reasonably well together. Note that BlockDeclRefExpr is still broken
w.r.t. its computation of type and value dependence, which will still
cause problems for blocks in templates.
This new implementation approach introduces the notion of an
"expanded" non-type template parameter pack, for which we have already
expanded the types of the parameter pack (to, say, "int*, float*",
for Outer<int*, float*>) but have not yet expanded the values. Aside
from creating these expanded non-type template parameter packs, this
patch updates template argument checking and non-type template
parameter pack instantiation to make use of the appropriate types in
the parameter pack.
John McCall [Wed, 19 Jan 2011 11:48:09 +0000 (11:48 +0000)]
When building the copy expression for a __block variable, make sure
there's a respectable point of instantiation. Also, make sure we do
this operation even when instantiating a dependently-typed variable.
John McCall [Wed, 19 Jan 2011 10:06:00 +0000 (10:06 +0000)]
Change the canonical representation of array types to store qualifiers on the
outermost array types and not on the element type. Move the CanonicalType
member from Type to ExtQualsTypeCommonBase; the canonical type on an ExtQuals
node includes the qualifiers on the ExtQuals. Assorted optimizations enabled
by this change.
getQualifiers(), hasQualifiers(), etc. should all now implicitly look through
array types.
Ted Kremenek [Tue, 18 Jan 2011 21:18:58 +0000 (21:18 +0000)]
Teach UninitializedValuesV2 to implicitly reason about C++
references by monitoring whether an access to
a variable is solely to compute it's lvalue or
to do an lvalue-to-rvalue conversion (i.e., a load).
John McCall [Tue, 18 Jan 2011 07:41:22 +0000 (07:41 +0000)]
Generalize some operations on qualifiers. QualType::getQualifiers() and
::getCVRQualifiers() now look through array types, like all the other
standard queries. Also, make a 'split' variant of getUnqualifiedType().