we know whether the function is virtual. But check it as soon as we do know;
in some cases we don't need to wait for an instantiation.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161316 91177308-0d34-0410-b5e6-96231b3b80d8
a defaulted special member function until the exception specification is needed
(using the same criteria used for the delayed instantiation of exception
specifications for function temploids).
EST_Delayed is now EST_Unevaluated (using 1330's terminology), and, like
EST_Uninstantiated, carries a pointer to the FunctionDecl which will be used to
resolve the exception specification.
This is enabled for all C++ modes: it's a little faster in the case where the
exception specification isn't used, allows our C++11-in-C++98 extensions to
work, and is still correct for C++98, since in that mode the computation of the
exception specification can't fail.
The diagnostics here aren't great (in particular, we should include implicit
evaluation of exception specifications for defaulted special members in the
template instantiation backtraces), but they're not much worse than before.
Our approach to the problem of cycles between in-class initializers and the
exception specification for a defaulted default constructor is modified a
little by this change -- we now reject any odr-use of a defaulted default
constructor if that constructor uses an in-class initializer and the use is in
an in-class initialzer which is declared lexically earlier. This is a closer
approximation to the current draft solution in core issue 1351, but isn't an
exact match (but the current draft wording isn't reasonable, so that's to be
expected).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160847 91177308-0d34-0410-b5e6-96231b3b80d8
Rather than adding a ContainsUnexpandedParameterPack bit to essentially every
AST node, we tunnel the bit directly up to the surrounding lambda expression
when we reach a context where an unexpanded pack can not normally appear.
Thus any statement or declaration within a lambda can now potentially contain
an unexpanded parameter pack.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160705 91177308-0d34-0410-b5e6-96231b3b80d8
be defined as deleted, take cv-qualifiers on class members into account when
looking up the copy or move constructor or assignment operator which will be
used for them.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160418 91177308-0d34-0410-b5e6-96231b3b80d8
and a function template instantiation, if there's a parameter pack in the
declaration and one at the same place in the instantiation, don't assume that
the pack wasn't expanded -- it may have expanded to nothing. Instead, go ahead
and check whether the parameter pack was expandable. We can do this as a
side-effect of the work we'd need to do anyway, to find how many parameters
were produced.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160416 91177308-0d34-0410-b5e6-96231b3b80d8
Update the two function overloads
void TemplateSpecializationType::PrintTemplateArgumentList(raw_ostream &OS,....
to behave like
std::string TemplateSpecializationType::PrintTemplateArgumentList(const TemplateArgument *Args,...
hence making sure that clang consistently adds a space between two '>' at the end of nested template arguments.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159412 91177308-0d34-0410-b5e6-96231b3b80d8
literal helper functions. All helper functions (global
and locals) use block_invoke as their prefix. Local literal
helper names are prefixed by their enclosing mangled function
names. Blocks in non-local initializers (e.g. a global variable
or a C++11 field) are prefixed by their mangled variable name.
The descriminator number added to end of the name starts off
with blank (for first block) and _<N> (for the N+2-th block).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159206 91177308-0d34-0410-b5e6-96231b3b80d8
This works around a quirk in the way that explicit template specializations are
handled in Clang. We generate an implicit declaration from the original
template which the explicit specialization is considered to redeclare. This
trips up the explicit delete logic.
This change only works around that strange representation. At some point it'd
be nice to remove those extra declarations to make the AST more accurately
reflect the C++ semantics.
Review by Doug Gregor.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159167 91177308-0d34-0410-b5e6-96231b3b80d8
because it expects a reference and receives a non-l-value.
For example, given:
int foo(int &);
template<int x> void b() { foo(x); }
clang will now print "expects an l-value for 1st argument" instead of
"no known conversion from 'int' to 'int &' for 1st argument". The change
in wording (and associated code to detect the case) was prompted by
comment #5 in PR3104, and should be the last bit of work needed for the
bug.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158691 91177308-0d34-0410-b5e6-96231b3b80d8
an explicitly-defaulted default constructor would be constexpr. This is
necessary in weird (but well-formed) cases where a class has more than one copy
or move constructor.
Cleanup of now-unused parts of CXXRecordDecl to follow.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158289 91177308-0d34-0410-b5e6-96231b3b80d8
constexpr until we get to the end of the class definition. When that happens,
be sure to remember that the class actually does have a constexpr constructor.
This is a stopgap solution, which still doesn't cover the case of a class with
multiple copy constructors (only some of which are constexpr). We should be
performing constructor lookup when implicitly defining a constructor in order
to determine whether all constructors it invokes are constexpr.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158228 91177308-0d34-0410-b5e6-96231b3b80d8
are otherwise too short to try to correct.
The TODOs added to two of the tests are for existing deficiencies in the
typo correction code that could be exposed by using longer identifiers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158109 91177308-0d34-0410-b5e6-96231b3b80d8
This comes up in the begin/end calls of a range-for (see the included test
case). Other suggestions are welcome, though this seems to do the trick without
regressing anything.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157553 91177308-0d34-0410-b5e6-96231b3b80d8
Disambiguate past such a potential problem, and use the absence of 'typename'
to break ties in favor of a parenthesized thingy being an initializer, if
nothing else in the declaration disambiguates it as declaring a function.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156963 91177308-0d34-0410-b5e6-96231b3b80d8
lambda as referring to a local in an enclosing scope if we're in the
enclosing scope of the lambda (not it's function call operator). Also,
turn the test into an IR generation test, since that's where the
crashes occurred. Really fixes PR12746 / <rdar://problem/11465120>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156926 91177308-0d34-0410-b5e6-96231b3b80d8
blocks and lambdas, based heavily on a patch from Meador Inge. Fixes
PR12746 / <rdar://problem/11465120>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156925 91177308-0d34-0410-b5e6-96231b3b80d8
Moves the bool bail-out down a little in SemaChecking - so now
-Wnull-conversion and -Wliteral-conversion can fire when the target type is
bool.
Also improve the wording/details in the -Wliteral-conversion warning to match
the -Wconstant-conversion.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156826 91177308-0d34-0410-b5e6-96231b3b80d8
into one. These were all performing almost identical checks, with different bugs
in each of them.
This fixes PR12806 (we weren't setting the exception specification for an
explicitly-defaulted, non-user-provided default constructor) and enforces
8.4.2/2's rule that an in-class defaulted member must exactly match the implicit
parameter type.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156802 91177308-0d34-0410-b5e6-96231b3b80d8
parser, and use it to emit better diagnostics in cases where an identifer
can't be looked up as a type name.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156508 91177308-0d34-0410-b5e6-96231b3b80d8
so that we actually accumulate all the delayed diagnostics. Do
this so that we can restore those diagnostics to good standing
if it turns out that we were wrong to suppress, e.g. if the
tag specifier is actually an elaborated type specifier and not
a declaration.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156291 91177308-0d34-0410-b5e6-96231b3b80d8
in-class initializer for one of its fields. Value-initialization of such
a type should use the in-class initializer!
The former was just a bug, the latter is a (reported) standard defect.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156274 91177308-0d34-0410-b5e6-96231b3b80d8
the parsing of such things appears to be a conforming extension, but it breaks
libstdc++4.7's std::pair.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155975 91177308-0d34-0410-b5e6-96231b3b80d8
victim. Don't crash if we have a delay-parsed exception specification for a
class member which is invalid in a way which precludes building a FunctionDecl.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155788 91177308-0d34-0410-b5e6-96231b3b80d8
Don't try to query whether an incomplete type has a trivial copy constructor
when determining whether a move constructor should be declared.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155575 91177308-0d34-0410-b5e6-96231b3b80d8