• Home
  • History
  • Annotate
  • only in /external/clang/test/SemaTemplate/
History log of /external/clang/test/SemaTemplate/
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
ef8225444452a1486bd721f3285301fe84643b00 21-Jul-2014 Stephen Hines <srhines@google.com> Update Clang for rebase to r212749.

This also fixes a small issue with arm_neon.h not being generated always.

Includes a cherry-pick of:
r213450 - fixes mac-specific header issue
r213126 - removes a default -Bsymbolic on Android

Change-Id: I2a790a0f5d3b2aab11de596fc3a74e7cbc99081d
ependent-names.cpp
nstantiate-default-assignment-operator.cpp
s-delayed-default-template-args.cpp
s-lookup-template-base-classes.cpp
s-sizeof-missing-typename.cpp
ack-deduction.cpp
ypename-specifier.cpp
6bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89 29-May-2014 Stephen Hines <srhines@google.com> Update Clang for 3.5 rebase (r209713).

Change-Id: I8c9133b0f8f776dc915f270b60f94962e771bc83
onstexpr-instantiate.cpp
xplicit-specialization-member.cpp
s-class-specialization-duplicate.cpp
651f13cea278ec967336033dd032faef0e9fc2ec 24-Apr-2014 Stephen Hines <srhines@google.com> Updated to Clang 3.5a.

Change-Id: I8127eb568f674c2e72635b639a3295381fe8af82
ttributes.cpp
lass-template-decl.cpp
lass-template-spec.cpp
ependent-expr.cpp
ependent-names.cpp
ependent-type-identity.cpp
xplicit-instantiation.cpp
nject-templated-friend-post.cpp
nject-templated-friend.cpp
nstantiate-complete.cpp
nstantiate-enum.cpp
nstantiate-exception-spec-cxx11.cpp
nstantiate-exception-spec.cpp
nstantiate-function-2.cpp
nstantiate-function-params.cpp
nstantiate-local-class.cpp
nstantiate-method.cpp
nstantiate-var-template.cpp
nstantiation-backtrace.cpp
nstantiation-depth-subst-2.cpp
nstantiation-depth-subst.cpp
nstantiation-order.cpp
s-function-specialization-class-scope.cpp
s-if-exists.cpp
s-lookup-template-base-classes.cpp
perator-template.cpp
esolve-single-template-id.cpp
emp_arg_nontype.cpp
ypename-specifier.cpp
irtual-member-functions.cpp
b3617be53923ac3e5885ff5001aa748bd0223102 14-Dec-2013 Bill Wendling <isanbard@gmail.com> Merging r197298:
------------------------------------------------------------------------
r197298 | rsmith | 2013-12-13 17:04:22 -0800 (Fri, 13 Dec 2013) | 3 lines

PR18232: implement instantiation for class-scope explicit specializations of
class templates (a Microsoft extension).

------------------------------------------------------------------------


git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_34@197320 91177308-0d34-0410-b5e6-96231b3b80d8
s-class-specialization-class-scope.cpp
461b1b961cd83c1322c3bf402b3601954bc7757b 14-Dec-2013 Bill Wendling <isanbard@gmail.com> Merging r197305:
------------------------------------------------------------------------
r197305 | rsmith | 2013-12-13 19:18:05 -0800 (Fri, 13 Dec 2013) | 7 lines

PR18246: When performing template argument deduction to decide which template
is specialized by an explicit specialization, start from the first declaration
in case we've got a member of a class template (redeclarations might not number
the template parameters the same way).

Our recover here is still far from ideal.

------------------------------------------------------------------------


git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_34@197319 91177308-0d34-0410-b5e6-96231b3b80d8
xplicit-specialization-member.cpp
2b3c4937d643743717b13bd8a374a72bc0eb7542 10-Dec-2013 Bill Wendling <isanbard@gmail.com> Merging r196852:
------------------------------------------------------------------------
r196852 | majnemer | 2013-12-09 16:40:58 -0800 (Mon, 09 Dec 2013) | 10 lines

Sema: Enforce C++11 pointer-to-member template arguments should rules

The standard is pretty clear on what it allows inside of template
arguments for non-type template parameters of pointer-to-member.

They must be of the form &qualified-id and cannot come from sources like
constexpr VarDecls or things of that nature.

This fixes PR18192.

------------------------------------------------------------------------


git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_34@196885 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-member-pointers.cpp
367e84601aef9f63f7afab663bff3c00bf5a96f3 01-Dec-2013 Bill Wendling <isanbard@gmail.com> Merging r195897:
------------------------------------------------------------------------
r195897 | rikka | 2013-11-27 16:13:38 -0800 (Wed, 27 Nov 2013) | 1 line

Add a return statement to the func with an int return type.
------------------------------------------------------------------------


git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_34@195989 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-local-class.cpp
65173e04eacb68ff89a58fbff14979eb318896c9 28-Nov-2013 Bill Wendling <isanbard@gmail.com> Merging r195887:
------------------------------------------------------------------------
r195887 | majnemer | 2013-11-27 14:57:44 -0800 (Wed, 27 Nov 2013) | 9 lines

Sema: Instantiation of variable definitions weren't local enough

We wouldn't properly save and restore the pending local instantiations
we had built up prior to instantiation of a variable definition. This
would lead to us instantiating too much causing crashes and other
general badness.

This fixes PR14374.

------------------------------------------------------------------------


git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_34@195901 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-local-class.cpp
57907e56191adea0fa870c052054eb0fe0c4681f 28-Nov-2013 Bill Wendling <isanbard@gmail.com> Merging r195827:
------------------------------------------------------------------------
r195827 | majnemer | 2013-11-27 00:20:38 -0800 (Wed, 27 Nov 2013) | 9 lines

Sema: Instantiate local class and their members appropriately

We would fail to instantiate them when the surrounding function was
instantiated. Instantiate the class and add it's members to the list of
pending instantiations, they should be resolved when we are finished
with the function's body.

This fixes PR9685.

------------------------------------------------------------------------


git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_34@195900 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-local-class.cpp
45c2eed19c012d8b5e686aedb28cdbb36347fee5 27-Nov-2013 Bill Wendling <isanbard@gmail.com> Merging r195303:
------------------------------------------------------------------------
r195303 | rsmith | 2013-11-20 17:53:02 -0800 (Wed, 20 Nov 2013) | 4 lines

PR10837: Warn if a null pointer constant is formed by a zero integer constant
expression that is not a zero literal, in C. This is a different, and more
targeted, approach than that in r194540.

------------------------------------------------------------------------


git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_34@195815 91177308-0d34-0410-b5e6-96231b3b80d8
ependent-expr.cpp
1997bbf292f7372240eec9da749a1f16b277efa1 12-Nov-2013 Richard Smith <richard-llvm@metafoo.co.uk> Extra test for r194444.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194445 91177308-0d34-0410-b5e6-96231b3b80d8
xtension-sfinae.cpp
ce6426feda94ca716ee7743b71961850740eb08d 08-Nov-2013 Richard Smith <richard-llvm@metafoo.co.uk> Issue a diagnostic if we see a templated friend declaration that we do not
support.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194273 91177308-0d34-0410-b5e6-96231b3b80d8
riend-template.cpp
d7b485599cf23605e0e7e9846a7c5df11783b9f7 26-Oct-2013 David Majnemer <david.majnemer@gmail.com> Sema: Correctly build pointer-to-member arguments from a template argument with an IndirectFieldDecl

We only considered FieldDecl and CXXMethodDecl as appropriate which
would cause us to believe the IndirectFieldDecl corresponded to an
argument of it's field type instead of a pointer-to-member type.

This fixes PR17696.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193461 91177308-0d34-0410-b5e6-96231b3b80d8
emp_arg_nontype.cpp
255ca71082810ac8d3084f43727675e02a384683 22-Oct-2013 David Majnemer <david.majnemer@gmail.com> Sema: Allow IndirectFieldDecl to appear in a non-type template argument

We would not identify pointer-to-member construction in a non-type
template argument if it was either a FieldDecl or a CXXMethodDecl.
However, this would incorrectly reject declarations that were injected
via an IndirectFieldDecl (e.g. a field inside of an anonymous union).

This fixes PR17657.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193203 91177308-0d34-0410-b5e6-96231b3b80d8
emp_arg_nontype.cpp
588a51a471b4cb23613e8183e05d2d193d2ab813 22-Oct-2013 David Majnemer <david.majnemer@gmail.com> Sema: Do not allow template declarations inside local classes

Summary:
Enforce the rule in C++11 [temp.mem]p2 that local classes cannot have
member templates.

This fixes PR16947.

N.B. C++14 has slightly different wording to afford generic lambdas
declared inside of functions.

Fun fact: Some formulations of local classes with member templates
would cause clang to crash during Itanium mangling, such as the
following:

void outer_mem() {
struct Inner {
template <typename = void>
struct InnerTemplateClass {
static void itc_mem() {}
};
};
Inner::InnerTemplateClass<>::itc_mem();
}

Reviewers: eli.friedman, rsmith, doug.gregor, faisalv

Reviewed By: doug.gregor

CC: cfe-commits, ygao

Differential Revision: http://llvm-reviews.chandlerc.com/D1866

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193144 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-exception-spec-cxx11.cpp
ocal-member-templates.cpp
b5c7768a74936d4e2c7a484570a638cb74702d8b 19-Oct-2013 Kaelyn Uhrain <rikka@google.com> Allow CorrectTypo to replace CXXScopeSpecifiers that refer to classes.

Now that CorrectTypo knows how to correctly search classes for typo
correction candidates, there is no good reason to only replace an
existing CXXScopeSpecifier if it refers to a namespace. While the actual
enablement was a matter of changing a single comparison, the fallout
from enabling the functionality required a lot more code changes
(including my two previous commits).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193020 91177308-0d34-0410-b5e6-96231b3b80d8
emp_arg_nontype.cpp
08235661cf457978ba4645ec8e22697aebabe4fa 18-Oct-2013 Alp Toker <alp@nuanti.com> Fix missed exception spec checks and crashes

Delayed exception specification checking for defaulted members and virtual
destructors are both susceptible to mutation during iteration so we need to
swap and process the worklists.

This resolves both accepts-invalid and rejects-valid issues and moreover fixes
potential invalid memory access as the contents of the vectors change during
iteration and recursive template instantiation.

Checking can be further delayed where parent classes aren't yet fully defined.
This patch adds two assertions at end of TU to ensure no specs are left
unchecked as was happenning before the fix, plus a test case from Marshall Clow
for the defaulted member crash extracted from the libcxx headers.

Reviewed by Richard Smith.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192947 91177308-0d34-0410-b5e6-96231b3b80d8
xception-spec-crash.cpp
682a56b15ae01cc8154d4800d29498da93911981 17-Oct-2013 Alp Toker <alp@nuanti.com> Revert "Fix missed exception spec checks and crashes"

The changes caused the sanitizer bot to hang:
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/2311

Needs investigation.

This reverts commit r192914.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192921 91177308-0d34-0410-b5e6-96231b3b80d8
xception-spec-crash.cpp
bb81f880aa77cfd09dedfc72a9b87262889ae75c 17-Oct-2013 Alp Toker <alp@nuanti.com> Fix missed exception spec checks and crashes

Delayed exception specification checking for defaulted members and virtual
destructors are both susceptible to mutation during iteration so we need to
process the worklists fully.

This resolves both accepts-invalid and rejects-valid issues and moreover fixes
potential invalid memory access as the contents of the vectors change during
iteration and recursive template instantiation.

This patch also adds two assertions at end of TU to ensure no specs are left
unchecked as was happenning before the fix, plus a test case from Marshall Clow
for the defaulted member crash extracted from the libcxx headers.

Reviewed by Richard Smith.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192914 91177308-0d34-0410-b5e6-96231b3b80d8
xception-spec-crash.cpp
8690cee218a59d3f6eaca17b9c25d03a52ebacaa 15-Oct-2013 Reid Kleckner <reid@kleckner.net> ms-compat: Fix taking the address of a member of a dependent base

If unqualified id lookup fails while parsing a class template with a
dependent base, clang with -fms-compatibility will pretend the user
prefixed the name with 'this->' in order to delay the lookup. However,
if there was a unary ampersand, Sema::ActOnDependentIdExpression() will
create a DependentDeclRefExpr, which is not what we wanted at all. Fix
this by building the CXXDependentScopeMemberExpr directly instead.

In order to be fully MSVC compatible, we would have to defer all
attempts at name lookup to instantiation time. However, until we have
real problems with system headers that can't be parsed, we'll put off
implementing that.

Fixes PR16014.

Reviewers: rsmith

Differential Revision: http://llvm-reviews.chandlerc.com/D1892

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192727 91177308-0d34-0410-b5e6-96231b3b80d8
s-lookup-template-base-classes.cpp
b79b17b67f2c0de8fd343fdd070e5ccbfe20d602 15-Oct-2013 Richard Smith <richard-llvm@metafoo.co.uk> PR17567: Improve diagnostic for a mistyped constructor name. If we see something
that looks like a function declaration, except that it's missing a return type,
try typo-correcting it to the relevant constructor name.

In passing, fix a bug where the missing-type-specifier recovery codepath would
drop a preceding scope specifier on the floor, leading to follow-on diagnostics
and incorrect recovery for the auto-in-c++98 hack.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192644 91177308-0d34-0410-b5e6-96231b3b80d8
lias-nested-nontag.cpp
d0629eb137d06bf6d46a430abdb7fa044909298b 27-Sep-2013 Richard Smith <richard-llvm@metafoo.co.uk> Variable templates: handle instantiation of static data member templates
appropriately, especially when they appear within class templates.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191548 91177308-0d34-0410-b5e6-96231b3b80d8
xplicit-instantiation.cpp
e688ddf351d5d77d18cd01727e672e4b69706b23 26-Sep-2013 Richard Smith <richard-llvm@metafoo.co.uk> If a partial specialization of a member template is declared within a class
template and defined outside it, don't instantiate it twice when instantiating
the surrounding class template specialization. That would cause us to reject
the code because we think two partial specializations instantiated to produce
the same signature.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191418 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-partial-spec.cpp
09ab088dc196863e4027b98916acb98013afb10f 20-Sep-2013 Reid Kleckner <reid@kleckner.net> Use -fms-compatibility to trigger lookup into dep. bases

Update the docs for -fms-extensions and -fms-compatibility to try to
clarify the difference between the two.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191095 91177308-0d34-0410-b5e6-96231b3b80d8
ookup-dependent-bases.cpp
f91e86c9462006e819ff0d02df564d9b715c047e 19-Sep-2013 Eli Friedman <eli.friedman@gmail.com> Fix crash with cast of value-dependent expr.

We don't really need to perform semantic analysis on the dependent expression
anyway, so just call the cast dependent.

<rdar://problem/15012610>

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190981 91177308-0d34-0410-b5e6-96231b3b80d8
ependent-expr.cpp
313a9f46ac8cfae224ccfb2a5ffc88630189d24c 11-Sep-2013 Serge Pavlov <sepavloff@gmail.com> Added regression tests.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190531 91177308-0d34-0410-b5e6-96231b3b80d8
xplicit-instantiation.cpp
e8bcd4c8e5a867c52bef3837731e44b88eba6a36 11-Sep-2013 Reid Kleckner <reid@kleckner.net> Ignore noreturn when checking function template specializations

As requested when applying the same logic to calling conventions.

Reviewers: rsmith

Differential Revision: http://llvm-reviews.chandlerc.com/D1634

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190441 91177308-0d34-0410-b5e6-96231b3b80d8
unction-template-specialization-noreturn.cpp
9d57b8dea3b139dc2e2976ffccef50c74ac03873 29-Aug-2013 David Majnemer <david.majnemer@gmail.com> Sema: Subst type default template args earlier

Summary:
We would not perform substitution at an appropriate point, allowing strange
results to appear. We would accepts things that we shouldn't or mangle things incorrectly. Note that this hasn't fixed the other cases like
template-template parameters or non-type template parameters.

Reviewers: doug.gregor, rjmccall, rsmith

Reviewed By: rsmith

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D1507

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189540 91177308-0d34-0410-b5e6-96231b3b80d8
efault-arguments-cxx0x.cpp
efault-arguments.cpp
a2f9036b7e46166361b612c7fc66544d5529dc67 28-Aug-2013 David Majnemer <david.majnemer@gmail.com> Richard makes a good point, clean up this test.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189444 91177308-0d34-0410-b5e6-96231b3b80d8
emp_arg_template.cpp
c8940019b971070910bbaeada22f0d1f0d5f34ba 28-Aug-2013 David Majnemer <david.majnemer@gmail.com> Some of this test doesn't want -std=c++11

Sorry for the churn.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189429 91177308-0d34-0410-b5e6-96231b3b80d8
emp_arg_template.cpp
65442a558e61bba5b27b20cd6e9f0d6b7872a20e 28-Aug-2013 David Majnemer <david.majnemer@gmail.com> This test now needs C++11


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189425 91177308-0d34-0410-b5e6-96231b3b80d8
emp_arg_template.cpp
97ed61f5b6fc096725b65c2b1c1bf58eb16c9611 28-Aug-2013 David Majnemer <david.majnemer@gmail.com> AST: Don't treat a TemplateExpansion as a Template

Summary:
Instead of calling getAsTemplate(), call
getAsTemplateOrTemplatePattern() because it handles the
TemplateExpansion case too.

This fixes PR16997.

Reviewers: doug.gregor, rsmith

Reviewed By: rsmith

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D1512

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189422 91177308-0d34-0410-b5e6-96231b3b80d8
emp_arg_template.cpp
13b572c9e84729b4bd5f00d0f1452a4b93211cde 20-Aug-2013 Eli Friedman <eli.friedman@gmail.com> Fix name lookup with dependent using decls.

We previously mishandled UnresolvedUsingValueDecls in
NamedDecl::declarationReplaces, which caused us to forget decls
when there are multiple dependent using decls for the same name.

Fixes PR16936.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188737 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-using-decl.cpp
5a428206903750157e57a8006f1593435ec2f147 16-Aug-2013 Eli Friedman <eli.friedman@gmail.com> Fix for dependent contexts in alias templates.

When we are parsing a type for an alias template, we are not entering
the context, so we can't look into dependent classes. Make sure the
parser handles this correctly.

PR16904.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188510 91177308-0d34-0410-b5e6-96231b3b80d8
lias-templates.cpp
cdd4b78583120222b82148626119b3e80ae1d291 16-Aug-2013 Eli Friedman <eli.friedman@gmail.com> Properly track l-paren of a CXXFucntionalCastExpr.

In addition to storing more useful information in the AST, this
fixes a semantic check in template instantiation which checks whether
the l-paren location is valid.

Fixes PR16903.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188495 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-init.cpp
c99b90edb85ea0a5be6ce567a8c0147b76534e15 14-Aug-2013 Eli Friedman <eli.friedman@gmail.com> sizeof(void) etc. should be a hard error in C++.

PR16872.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188324 91177308-0d34-0410-b5e6-96231b3b80d8
onstexpr-instantiate.cpp
esolve-single-template-id.cpp
29a46e63490176608efe13f13b293a6ce9862059 10-Aug-2013 Serge Pavlov <sepavloff@gmail.com> Fix to PR16225 (Assert-on-invalid: isa<LabelDecl>(D) && "declaration not instantiated in this scope")

Differential Revision: http://llvm-reviews.chandlerc.com/D920


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188137 91177308-0d34-0410-b5e6-96231b3b80d8
ecovery-crash.cpp
ee138f6478e62f77e90418fd133ba8d637a9248a 10-Aug-2013 Eli Friedman <eli.friedman@gmail.com> Correctly profile CXXPseudoDestructorExprs.

CXXPseudoDestructorExprs may not contain a type. PR16852.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188123 91177308-0d34-0410-b5e6-96231b3b80d8
estructor-template.cpp
ef4579cda09b73e3d4d98af48201da25adc29326 06-Aug-2013 Larisse Voufo <lvoufo@google.com> Started implementing variable templates. Top level declarations should be fully supported, up to some limitations documented as FIXMEs or TODO. Static data member templates work very partially. Static data member templates of class templates need particular attention...

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187762 91177308-0d34-0410-b5e6-96231b3b80d8
lass-template-decl.cpp
c66e7e99d5acc560de5cea50909fcea22ef12ca5 31-Jul-2013 Reid Kleckner <reid@kleckner.net> Fix declaring class template methods with an attributed typedef

This change unifies the logic for template instantiation of methods and
functions declared with typedefs.

It ensures that SubstFunctionType() always fills the Params out param
with non-null ParmVarDecls or returns null.

Reviewers: rsmith

Differential Revision: http://llvm-reviews.chandlerc.com/D1135

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187528 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-function-params.cpp
10ed9819769e66f52cc6e22a74c2d96e601d7d26 22-Jul-2013 Richard Smith <richard-llvm@metafoo.co.uk> Add testcase for PR16134, which no longer crashes with ToT.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186849 91177308-0d34-0410-b5e6-96231b3b80d8
ecovery-crash.cpp
03c55be552d224c787c3dd2e981b47a23b05cc2d 22-Jul-2013 Richard Smith <richard-llvm@metafoo.co.uk> PR16288: A template is only missing a default template argument if it provides
any default template arguments, not if it inherits some.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186804 91177308-0d34-0410-b5e6-96231b3b80d8
efault-arguments.cpp
4384712b3a0aedd7c68d6abdb0407850f7b46c8b 20-Jul-2013 Larisse Voufo <lvoufo@google.com> FIXME fix: improving diagnostics for template arguments deduction of class templates and explicit specializations
This patch essentially removes all the FIXMEs following calls to DeduceTemplateArguments() that want to keep track of deduction failure info.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186730 91177308-0d34-0410-b5e6-96231b3b80d8
lias-templates.cpp
xplicit-instantiation.cpp
unction-template-specialization.cpp
8c5d4078bb40642847164e7613828262d32db973 20-Jul-2013 Larisse Voufo <lvoufo@google.com> Revert "Use function overloading instead of template specialization for diagnosis of bad template argument deductions."

This reverts commit a730f548325756d050d4caaa28fcbffdae8dfe95.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186729 91177308-0d34-0410-b5e6-96231b3b80d8
xplicit-instantiation.cpp
unction-template-specialization.cpp
ba037f2a0cd9bc5614813c3c9293e4e01436e4dd 20-Jul-2013 Eli Friedman <eli.friedman@gmail.com> Fix pack instantiation with function types.

Make sure we correctly expand packs which expand to another
pack in a function type.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186728 91177308-0d34-0410-b5e6-96231b3b80d8
lias-templates.cpp
a730f548325756d050d4caaa28fcbffdae8dfe95 20-Jul-2013 Larisse Voufo <lvoufo@google.com> Use function overloading instead of template specialization for diagnosis of bad template argument deductions.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186727 91177308-0d34-0410-b5e6-96231b3b80d8
xplicit-instantiation.cpp
unction-template-specialization.cpp
c6274ce3587e95453f4d4386fab4a77c9d56e18b 19-Jul-2013 Reid Kleckner <reid@kleckner.net> Use an i686 triple for this test now that it uses stdcall

There seems to be a crash here if we have a calling convention attribute
that gets ignored and then we instantiate templates.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186719 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-function-params.cpp
5b92696c8f1f8ef943ad87397b95c031b5787305 19-Jul-2013 Reid Kleckner <reid@kleckner.net> Create calling convention AttributedType sugar nodes

Canonical types are unchanged. The type printer had to be changed to
avoid printing any non-default implicit calling convention as well as
the calling convention attribute.

Reviewers: rjmccall

Differential Revision: http://llvm-reviews.chandlerc.com/D1132

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186714 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-function-params.cpp
10ec0e4935e5d2efab4ee2731ccb350330dc5b34 19-Jul-2013 Eli Friedman <eli.friedman@gmail.com> Fix for template substitution with packs.

When we see a pack, and replace it with a template argument which is
also a pack, we want to use the pack pattern, not the expanded pack.
The caller should take care of expanding the pack afterwards.

Fixes PR16646.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186713 91177308-0d34-0410-b5e6-96231b3b80d8
lias-templates.cpp
bcd0650c1e50a2e73b11717731e074a1ac2ac5ba 08-Jul-2013 David Majnemer <david.majnemer@gmail.com> Sema: Do not merge new decls with invalid, old decls

Sema::MergeFunctionDecl attempts merging two decls even if the old decl
is invalid. This can lead to interesting circumstances where we
successfully merge the decls but the result makes no sense.

Take the following for example:

template <typename T>
int main(void);

int main(void);

Sema will not consider these to be overloads of the same name because
main can't be overloaded, which means that this must be a redeclaration.

In this case the templated decl is compatible with the non-templated
decl allowing the Sema::CheckFunctionDeclaration machinery to move on
and do bizarre things like setting the previous decl of a non-templated
decl to a templated decl!

The way I see it, we should just bail from MergeFunctionDecl if the old
decl is invalid.

This fixes PR16531.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185779 91177308-0d34-0410-b5e6-96231b3b80d8
anonical-expr-type.cpp
96e7813f08c6adf1d8657b0da86741b54e850fd7 04-Jul-2013 Rafael Espindola <rafael.espindola@gmail.com> Add 'not' to commands that are expected to fail.

This is at least good documentation, but also opens the possibility of
using pipefail.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185652 91177308-0d34-0410-b5e6-96231b3b80d8
eduction-crash.cpp
305e5b4268685aa97d6338fe4362d1b73246cbe9 04-Jul-2013 Richard Smith <richard-llvm@metafoo.co.uk> Part of PR15673: If a function template has a default argument in which
substitution failed, report that as a substitution failure rather than
pretending that there was no default argument.

The test cases in PR15673 have exposed some pre-existing poor diagnostics here.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185604 91177308-0d34-0410-b5e6-96231b3b80d8
verload-candidates.cpp
21383febfcc27c3aead61ecb74be6641cc7c0a04 02-Jul-2013 Richard Smith <richard-llvm@metafoo.co.uk> Add regression test for PR12331.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185453 91177308-0d34-0410-b5e6-96231b3b80d8
xplicit-specialization-member.cpp
e36c7281258a714a2b9116b9cb3d9361f12fd3c9 29-Jun-2013 Argyrios Kyrtzidis <akyrtzi@gmail.com> [test] Add test case for rdar://14183893.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185244 91177308-0d34-0410-b5e6-96231b3b80d8
erived.cpp
33b90b34990a7738adebae30ef7ebf9d578ce9ae 27-Jun-2013 Eli Friedman <eli.friedman@gmail.com> Handle all TemplateArguments in trivial TypeLocs.

Armed with a much better understanding of what
TemplateSpecializationTypeLoc::initializeArgLocs actually does, I now
understand that it's fine to just use an empty TemplateArgumentLocInfo
for Integral, Declaration, and NullPtr TemplateArguments.

Fixes PR14281. (The testcases are actually derived from libcxx_test in
deduction-crash.cpp because the original testcase was impossible to reduce.)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185038 91177308-0d34-0410-b5e6-96231b3b80d8
eduction-crash.cpp
538fccb44c521f5f26e7aa4cebf6a55284e28b3d 21-Jun-2013 Matt Beaumont-Gay <matthewbg@google.com> Propagate the invalid bit from bases to derived template classes.

Fixes PR16292.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184581 91177308-0d34-0410-b5e6-96231b3b80d8
erived.cpp
c1826a52ea0e22c521795c4d4a0c2d486825a239 20-Jun-2013 Eli Friedman <eli.friedman@gmail.com> Add test.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184465 91177308-0d34-0410-b5e6-96231b3b80d8
ested-template.cpp
d7abe109df5b169fe36d78915b5c0a5a4e6c2650 20-Jun-2013 Eli Friedman <eli.friedman@gmail.com> One more cast test.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184393 91177308-0d34-0410-b5e6-96231b3b80d8
irtual-member-functions.cpp
6698be8a6930730df5e61c941197e72682196187 13-Jun-2013 Richard Smith <richard-llvm@metafoo.co.uk> Fix some confusing diagnostic wording. s/implicit default/implicit/ if we're
not actually talking about a default constructor.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183885 91177308-0d34-0410-b5e6-96231b3b80d8
irtual-member-functions.cpp
d3ff325a8d95a58783a3ea2675e2d59a393bd637 13-Jun-2013 Richard Smith <richard-llvm@metafoo.co.uk> Don't suggest putting 'operator new' or 'operator delete' in a namespace to fix a two-phase lookup issue. That's not permitted.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183874 91177308-0d34-0410-b5e6-96231b3b80d8
ependent-names.cpp
01e0b1f24af250da37faf953cd82626b360622f6 11-Jun-2013 David Majnemer <david.majnemer@gmail.com> Implement DR61: Address of ambiguous bound methods should be disallowed

DR61 affirms that expressions containing unresolved member access should
be disallowed when performing "address of" operations.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183723 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-overload-candidates.cpp
2ec2b8459392f3f2f00d816b40e73113d444d838 11-Jun-2013 David Majnemer <david.majnemer@gmail.com> Implement DR85: Redeclaration of member is forbidden

Disallow the existence of a declaration of a member class that isn't a
forward declaration before it's definition.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183722 91177308-0d34-0410-b5e6-96231b3b80d8
ependent-names.cpp
nstantiate-member-class.cpp
688f9866c7d35725c947b080fb17055446912390 08-Jun-2013 Faisal Vali <faisalv@yahoo.com> Fix the parser's updating of the template depth when parsing local templates and late-parsed templates.
This is a slight tweak of r180708; It avoids incrementing depth when non-template local classes nested within member templates of local classes are encountered.
This patch was LGTM'd by Doug http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20130506/079656.html and passed the regression tests that normally pass (i.e. excluding many Module and Index tests on Windows that fail regardless)


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183620 91177308-0d34-0410-b5e6-96231b3b80d8
ocal-member-templates.cpp
65efd10a5f54e4ffa23996d3779fd9318f01c4b7 08-Jun-2013 Faisal Vali <faisalv@yahoo.com> Revert r183618.
I ran clang-format on my patch but it seemed to have wreaked havoc with new lines - might have to do with using it on windows :( will resubmit once i've cleaned this issue up. sorry.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183619 91177308-0d34-0410-b5e6-96231b3b80d8
ocal-member-templates.cpp
22bf46a9a30aaad965762cc2d4f0192eb85f685b 08-Jun-2013 Faisal Vali <faisalv@yahoo.com> Fix the parser's updating of the template depth when parsing local templates and late-parsed templates. This is a slight tweak of r180708; It avoids incrementing depth when non-template local classes nested within member templates of local classes are encountered.
This patch was LGTM'd by Doug http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20130506/079656.html and passed the regression tests that normally pass (i.e. excluding many Module and Index tests on Windows that fail regardless)


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183618 91177308-0d34-0410-b5e6-96231b3b80d8
ocal-member-templates.cpp
73b417f363a67439b30b3167ef8d9fb32e37191b 06-Jun-2013 Anna Zaks <ganna@apple.com> [analyzer] Fix a crash that occurs when processing an rvalue array.

When processing ArrayToPointerDecay, we expect the array to be a location, not a LazyCompoundVal.
Special case the rvalue arrays by using a location to represent them. This case is handled similarly
elsewhere in the code.

Fixes PR16206.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183359 91177308-0d34-0410-b5e6-96231b3b80d8
rray-to-pointer-decay.cpp
c2fe81898b1b3b948791ca4ababd3d495601f22a 04-Jun-2013 David Blaikie <dblaikie@gmail.com> Bound member function diagnostic - suggest no-args calls and note overload candidates

Still missing cases for templates, but this is a step in the right
direction. Also omits suggestions that would be ambiguous (eg: void
func(int = 0); + void func(float = 0); func;)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183173 91177308-0d34-0410-b5e6-96231b3b80d8
esolve-single-template-id.cpp
82b0001f79568199c7e5aa564f7ca9d43cc89d86 22-May-2013 Richard Smith <richard-llvm@metafoo.co.uk> Fix crash-on-invalid: only use TransformAddressOfOperand when transforming the
operand of a unary address-of expression, not for *all* expressions!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182436 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-5.cpp
62ab010d5acb3752475bf0caf918406c470f7063 16-May-2013 Richard Trieu <rtrieu@google.com> Check a pointer is not null before attempting to use it. This prevents a
crash on an explicit specialization of a member function in a class scope.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181971 91177308-0d34-0410-b5e6-96231b3b80d8
unction-template-specialization.cpp
79bef7aea4419b75e2cca0f121c6e1a4232bb03c 04-May-2013 Douglas Gregor <dgregor@apple.com> <rdar://problem/13806270> A template argument list is a constant-evaluated context.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181076 91177308-0d34-0410-b5e6-96231b3b80d8
emp_arg_nontype.cpp
92eb7d847cb1273a63d5e3b7dc98a7c97a81b703 03-May-2013 Douglas Gregor <dgregor@apple.com> Use attribute argument information to determine when to parse attribute arguments as expressions.

This change partly addresses a heinous problem we have with the
parsing of attribute arguments that are a lone identifier. Previously,
we would end up parsing the 'align' attribute of this as an expression
"(Align)":

template<unsigned Size, unsigned Align>
class my_aligned_storage
{
__attribute__((align((Align)))) char storage[Size];
};

while this would parse as a "parameter name" 'Align':

template<unsigned Size, unsigned Align>
class my_aligned_storage
{
__attribute__((align(Align))) char storage[Size];
};

The code that handles the alignment attribute would completely ignore
the parameter name, so the while the first of these would do what's
expected, the second would silently be equivalent to

template<unsigned Size, unsigned Align>
class my_aligned_storage
{
__attribute__((align)) char storage[Size];
};

i.e., use the maximal alignment rather than the specified alignment.

Address this by sniffing the "Args" provided in the TableGen
description of attributes. If the first argument is "obviously"
something that should be treated as an expression (rather than an
identifier to be matched later), parse it as an expression.

Fixes <rdar://problem/13700933>.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180973 91177308-0d34-0410-b5e6-96231b3b80d8
ttributes.cpp
fa5f03052bc39d9c8f2fa8b4002597a8219760a4 03-May-2013 Douglas Gregor <dgregor@apple.com> Revert r180970; it's causing breakage.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180972 91177308-0d34-0410-b5e6-96231b3b80d8
ttributes.cpp
3796d1539a39b999fd50bed7aea726ef6f845e17 03-May-2013 Douglas Gregor <dgregor@apple.com> Use attribute argument information to determine when to parse attribute arguments as expressions.

This change partly addresses a heinous problem we have with the
parsing of attribute arguments that are a lone identifier. Previously,
we would end up parsing the 'align' attribute of this as an expression
"(Align)":

template<unsigned Size, unsigned Align>
class my_aligned_storage
{
__attribute__((align((Align)))) char storage[Size];
};

while this would parse as a "parameter name" 'Align':

template<unsigned Size, unsigned Align>
class my_aligned_storage
{
__attribute__((align(Align))) char storage[Size];
};

The code that handles the alignment attribute would completely ignore
the parameter name, so the while the first of these would do what's
expected, the second would silently be equivalent to

template<unsigned Size, unsigned Align>
class my_aligned_storage
{
__attribute__((align)) char storage[Size];
};

i.e., use the maximal alignment rather than the specified alignment.

Address this by sniffing the "Args" provided in the TableGen
description of attributes. If the first argument is "obviously"
something that should be treated as an expression (rather than an
identifier to be matched later), parse it as an expression.

Fixes <rdar://problem/13700933>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180970 91177308-0d34-0410-b5e6-96231b3b80d8
ttributes.cpp
dc7a4f5d7a7e3b60d4dc4a80338d7a2728540998 30-Apr-2013 Richard Smith <richard-llvm@metafoo.co.uk> Don't treat a non-deduced 'auto' type as being type-dependent. Instead, there
are now two distinct canonical 'AutoType's: one is the undeduced 'auto'
placeholder type, and the other is a deduced-but-dependent type. All
deduced-to-a-non-dependent-type cases are still non-canonical.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180789 91177308-0d34-0410-b5e6-96231b3b80d8
ependent-names.cpp
098b8140c082e5a69b18ca83ef2eb3091939d54f 29-Apr-2013 Richard Smith <richard-llvm@metafoo.co.uk> Keep the parser's template depth up to date when parsing local templates and
late-parsed templates. Patch by Faisal Vali!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180708 91177308-0d34-0410-b5e6-96231b3b80d8
ocal-member-templates.cpp
fed844d8676db8daece6144340284b09f901323d 29-Apr-2013 Richard Smith <richard-llvm@metafoo.co.uk> Properly reenter multiple contexts when parsing a late-parsed function template
within a dependent context. Patch by Will Wilson (+clang-format)!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180702 91177308-0d34-0410-b5e6-96231b3b80d8
s-function-specialization-class-scope.cpp
97aea95f46f27ff0927faa72baa7fe2b0bce1d2d 29-Apr-2013 Richard Smith <richard-llvm@metafoo.co.uk> Fix an assertion failure / accepts-invalid in -fms-extensions mode. Don't build
a dependent-scope id expression when a templated member function of a
non-templated class references an unknown identifier, since instantiation won't
rebuild it (and we can tell at parse time that it'll never work). Based on a
patch by Faisal Vali!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180701 91177308-0d34-0410-b5e6-96231b3b80d8
s-lookup-template-base-classes.cpp
e68cb08bd97c916edc907e59ca5ccdc5706a2b46 24-Apr-2013 Jyotsna Verma <jverma@codeaurora.org> Removing example-dynarray.cpp test since it's of no value.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180208 91177308-0d34-0410-b5e6-96231b3b80d8
xample-dynarray.cpp
eef35f8b9a935d14c2070dd83aa12ae04c701514 08-Apr-2013 Richard Trieu <rtrieu@google.com> Fix PR15634, better error message for template deduction failure.

When two template decls with the same name are used in this diagnostic,
force them to print their qualified names. This changes the bad message of:

candidate template ignored: could not match 'array' against 'array'

to the better message of:

candidate template ignored: could not match 'NS2::array' against 'NS1::array'


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179056 91177308-0d34-0410-b5e6-96231b3b80d8
verload-candidates.cpp
8cfa0babc06cd7c220c78e05c9ad9dd2c74b4e2a 04-Apr-2013 Jyotsna Verma <jverma@codeaurora.org> XFAIL example-dynarray.cpp test for Hexagon as some of the header files
are unavailable on Hexagon.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178791 91177308-0d34-0410-b5e6-96231b3b80d8
xample-dynarray.cpp
93d6b07cd79d74e343d81c0e8fb5365376a33097 28-Mar-2013 Richard Smith <richard-llvm@metafoo.co.uk> Fold together the two implementations of 6.7.3p2 in SemaType. Fix two bugs, each of which was only present in one version:
* Give the right diagnostic for 'restrict' applied to a non-pointer, non-reference type.
* Don't reject 'restrict' applied indirectly to an Objective-C object pointer type (eg, through template instantiation).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178200 91177308-0d34-0410-b5e6-96231b3b80d8
un-template-def.cpp
9807a2e0ddb1eafb8725dbf0247271a4a694037b 28-Mar-2013 Richard Smith <richard-llvm@metafoo.co.uk> Don't reject __restrict applied to a dependent type; it might instantiate to a pointer or reference type.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178198 91177308-0d34-0410-b5e6-96231b3b80d8
un-template-def.cpp
0162c1ce296fc48fbe03a31a2ae00b939eef86a8 27-Mar-2013 Douglas Gregor <dgregor@apple.com> <rdar://problem/13267210> Ensure that Sema::CompareReferenceRelationship returns consistent results with invalid types.

When Sema::RequireCompleteType() is given a class template
specialization type that then fails to instantiate, it returns
'true'. On subsequent invocations, it can return false. Make sure that
this difference doesn't change the result of
Sema::CompareReferenceRelationship, which is expected to remain stable
while we're checking an initialization sequence.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178088 91177308-0d34-0410-b5e6-96231b3b80d8
erived.cpp
e34db6b3e772e9832e1f6de1f23457076ffbec88 14-Mar-2013 John McCall <rjmccall@apple.com> Flag that friend function definitions are "late parsed" so that
template instantiation will still consider them to be definitions
if we instantiate the containing class before we get around
to parsing the friend.

This seems like a legitimate use of "late template parsed" to me,
but I'd appreciate it if someone responsible for the MS feature
would look over this.

This file already appears to access AST nodes directly, which
is arguably not kosher in the parser, but the performance of this
path matters enough that perpetuating the sin is justifiable.
Probably we ought to reconsider this policy for very simple
manipulations like this.

The reason this entire thing is necessary is that
function template instantiation plays some very gross games
in order to not associate an instantiated function template
with the class it came from unless it's a definition, and
the reason *that's* necessary is that the AST currently
cannot represent the instantiation history of individual
function template declarations, but instead tracks it in
common for the entire function template. That probably
prevents us from correctly reporting ill-formed calls to
ambiguously instantiated friend function templates.

rdar://12350696

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177003 91177308-0d34-0410-b5e6-96231b3b80d8
riend-template.cpp
c61361b102fcb9be7b64cc493fb797ea551eb8e7 08-Mar-2013 Douglas Gregor <dgregor@apple.com> <rdar://problem/13094134> Don't try to wire up typedef names for invalid anonymous tag declarations encountered during template instantiation.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176727 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-type.cpp
303b96f255d61ae3dff913d777d3f40332786257 08-Mar-2013 Douglas Gregor <dgregor@apple.com> <rdar://problem/13140795> Transform the scope type of a pseudo-destructor expression within the object scope.

We were transforming the scope type of a pseudo-destructor expression
(e.g., the first T in x->T::~T()) as a freestanding type, which meant
that dependent template specialization types here would stay dependent
even when no template parameters were named. This would eventually
mean that a dependent expression would end up in what should be
fully-instantiated ASTs, causing IRgen to assert.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176723 91177308-0d34-0410-b5e6-96231b3b80d8
estructor-template.cpp
4b02dff7aebb98d2d60b2ff4d3fc86109213128c 05-Mar-2013 David Blaikie <dblaikie@gmail.com> Add quotation marks to template names in diagnostics.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176474 91177308-0d34-0410-b5e6-96231b3b80d8
lass-template-id.cpp
emp_arg.cpp
emp_arg_type.cpp
c0cedbe537e4b25eeb8d61d0c30a2ac31a7fddab 27-Feb-2013 David Blaikie <dblaikie@gmail.com> PR15360: nullptr as a non-type template argument to a function type non-type template parameter

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176216 91177308-0d34-0410-b5e6-96231b3b80d8
emp_arg_nontype_cxx11.cpp
98b879af5bfb50123a668dc1de6dd86feb9991c5 27-Feb-2013 David Blaikie <dblaikie@gmail.com> Add test coverage for array to pointer decay in non-type template parameters.

Functionality committed in r172585 but tested the function case without the
array case.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176215 91177308-0d34-0410-b5e6-96231b3b80d8
emp_arg_nontype.cpp
f6565a9f7318b1ca6ea9510003dde7b89696daab 22-Feb-2013 Richard Smith <richard-llvm@metafoo.co.uk> Handle alignas(foo...) pack expansions.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175875 91177308-0d34-0410-b5e6-96231b3b80d8
lignas.cpp
3fa3feab35096b608f1d79bb541798b37a55e7b9 02-Feb-2013 Richard Smith <richard-llvm@metafoo.co.uk> PR15132: Replace "address expression must be an lvalue or a function
designator" diagnostic with more correct and more human-friendly "cannot take
address of rvalue of type 'T'".

For the case of & &T::f, provide a custom diagnostic, rather than unhelpfully
saying "cannot take address of rvalue of type '<overloaded function type>'".

For the case of &array_temporary, treat it just like a class temporary
(including allowing it as an extension); the existing diagnostic wording
for the class temporary case works fine.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174262 91177308-0d34-0410-b5e6-96231b3b80d8
emp_arg_nontype.cpp
29805ca6d278b4d9563adfee67f2478f0fecdcfc 31-Jan-2013 Richard Smith <richard-llvm@metafoo.co.uk> Improve 'failed template argument deduction' diagnostic for the case where we
have a direct mismatch between some component of the template and some
component of the argument. The diagnostic now says what the mismatch was, but
doesn't yet say which part of the template doesn't match.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174039 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-init.cpp
perator-template.cpp
ecursive-template-instantiation.cpp
b9df75f1b83d36be7bfbafc2f25d9fcf768874a3 16-Jan-2013 Douglas Gregor <dgregor@apple.com> Apply adjustment to function- and array-typed non-type template
parameters (per C++ [temp.param]p8) when computing the type of a
reference to a non-type template parameter. Fixes <rdar://problem/13000548>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172585 91177308-0d34-0410-b5e6-96231b3b80d8
emp_arg_nontype.cpp
19e0d959171860e207205d31af223b27c925fbec 22-Dec-2012 Richard Smith <richard-llvm@metafoo.co.uk> PR14695: Fix assert from bad cast<>. Not every namespace is a NamespaceDecl; it might instead be a TranslationUnitDecl.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170976 91177308-0d34-0410-b5e6-96231b3b80d8
ependent-names.cpp
5cf1589db395371975bd3315b9126eb5c9be6701 21-Dec-2012 Richard Smith <richard-llvm@metafoo.co.uk> Fix regression in r170489: when instantiating a direct initializer which is a
CXXScalarValueInitExpr (or an ImplicitValueInitExpr), strip it back down to an
empty pair of parentheses so that the initialization code can tell that we're
performing value-initialization.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170867 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-member-initializers.cpp
d538ed9b2a617239d5bd56357663de62f6f9224c 20-Dec-2012 Alexander Kornienko <alexfh@google.com> Implement AST dumper for Decls.
http://llvm-reviews.chandlerc.com/D52

Patch by Philip Craig!



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170634 91177308-0d34-0410-b5e6-96231b3b80d8
efault-expr-arguments-2.cpp
4b6ebe390fb0e38f6871d32db15cac29d22eb752 19-Dec-2012 Richard Smith <richard-llvm@metafoo.co.uk> Attempt to clarify a vexing-parse diagnostic.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170492 91177308-0d34-0410-b5e6-96231b3b80d8
emp_arg_nontype.cpp
cd6d5f43908cb4c2cbd644c35b6f21e9ade9a697 19-Dec-2012 Richard Smith <richard-llvm@metafoo.co.uk> Fix assertion failure in self-host (and probably bogus template instantiation
too). When instantiating a direct-initializer, if we find it has zero
arguments, produce an empty ParenListExpr rather than returning a null
expression.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170490 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-member-initializers.cpp
6febf1265b5a5c3025752193caa9714ed523b12d 13-Dec-2012 Eli Friedman <eli.friedman@gmail.com> Using CanQualType::getAs<ArrayType> is unsafe; fix the code currently using it,
and make sure additional uses don't get introduced. <rdar://problem/12858424>.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170081 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-init.cpp
f641166066c7053300cada4ca5c9e69ad1cd2358 28-Nov-2012 Richard Smith <richard-llvm@metafoo.co.uk> PR13098: If we're instantiating an overloaded binary operator and we could
determine which member function would be the callee from within the template
definition, don't pass that function as a "non-member function" to
CreateOverloadedBinOp. Instead, just rely on it to select the member function
for itself.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168818 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-overload-candidates.cpp
73ed67cc36b06a380ddc3658beb7a84328c19ff6 26-Nov-2012 Richard Smith <richard-llvm@metafoo.co.uk> PR14428: When instantiating a 'new' expression, if we had a non-dependent
initialization, don't rebuild it. Remove a couple of hacks which were trying to
work around this. Fix the special case for one-argument CXXConstructExprs to
not apply if the one argument is a default argument.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168582 91177308-0d34-0410-b5e6-96231b3b80d8
efault-expr-arguments.cpp
63b6ebe4e732f20fa24ea0666ed438dd5004cc20 23-Nov-2012 Benjamin Kramer <benny.kra@googlemail.com> Sema: Provide a valid source location when instantiating templates based on a CXXDefaultArgExpr.

Fixes PR13758.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168521 91177308-0d34-0410-b5e6-96231b3b80d8
efault-expr-arguments.cpp
4a030228d1bfa0cab89114a18d6b50b44eb3a1a8 14-Nov-2012 Richard Smith <richard-llvm@metafoo.co.uk> When we have a MemberExpr referring to an overloaded static member function,
and we resolve it to a specific function based on the type which it's used as,
don't forget to mark it as referenced.

Fixes a regression introduced in r167514.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167918 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-overload-candidates.cpp
d05df512cd6dfa32a696bcdd3dced825efe94bc4 13-Nov-2012 Nick Lewycky <nicholas@mxc.ca> When filtering the list of associated namespaces so that we don't suggest people
add functions to namespace 'std', also filter out namespaces with '__' anywhere
in the name.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167786 91177308-0d34-0410-b5e6-96231b3b80d8
ependent-names.cpp
229d47aef27e6f65fe4dc3beb22f622dd81104ad 10-Nov-2012 Douglas Gregor <dgregor@apple.com> Rework my implementation of circular-reference finding to not use
CXXRecordDecl::forallBases, which does *not* do what I need. Fixes the
failure introduced in r167651.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167668 91177308-0d34-0410-b5e6-96231b3b80d8
ependent-names.cpp
d777e2845110469182809e4efc577899395805f7 10-Nov-2012 Douglas Gregor <dgregor@apple.com> Diagnostic circular inheritance involving dependent base classes. We
would have diagnosed this at instantiation time anyway, if only we
didn't hang on all of these test cases. Fixes <rdar://problem/12629723>


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167651 91177308-0d34-0410-b5e6-96231b3b80d8
ependent-names.cpp
a67d503aa19700ff849fc590039b6bb8ced4ebf0 10-Nov-2012 Richard Smith <richard-llvm@metafoo.co.uk> PR13788: Don't perform checks on the initializer of a dependently-typed
variable. Previously we didn't notice the type was dependent if the only
dependence came from an array bound.

Patch by Brian Brooks!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167642 91177308-0d34-0410-b5e6-96231b3b80d8
ependent-sized_array.cpp
910515bc02872bd680e422f75079534d00093bc5 07-Nov-2012 Richard Trieu <rtrieu@google.com> When template deduction fails on a derived class, try a template deduction on
the base class. If the base class deduction succeeds, use those results. If
it fails, keep using the results from the derived class template deduction.

This prevents an assertion later where the type of deduction failure doesn't
match up with the template deduction info.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167550 91177308-0d34-0410-b5e6-96231b3b80d8
erived.cpp
ce2661f9ccb85de1aacaa7c3ea414a757f5986f6 07-Nov-2012 Richard Smith <richard-llvm@metafoo.co.uk> PR11851 (and duplicates): Whenever a constexpr function is referenced,
instantiate it if it can be instantiated and implicitly define it if it can be
implicitly defined. This matches g++'s approach. Remove some cases from
SemaOverload which were marking functions as referenced when just planning how
overload resolution would proceed; such cases are not actually references.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167514 91177308-0d34-0410-b5e6-96231b3b80d8
onstexpr-instantiate.cpp
b68ec6b7ff4f8d7795b11cd361fec46725d57e4e 07-Nov-2012 Eli Friedman <eli.friedman@gmail.com> Add missing check to warning for packed attribute. PR14259.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167510 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-attr.cpp
713c287caf70922f93cfd9292540bad274c4a82f 23-Oct-2012 Richard Smith <richard-llvm@metafoo.co.uk> When rebuilding a DependentScopeDeclRefExpr, perform a lookup into the scope
even if it's dependent, in case it now names a member of the current instantiation.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166496 91177308-0d34-0410-b5e6-96231b3b80d8
urrent-instantiation.cpp
efeeccfb5efa94b6b4198298a80ad9a699bebcce 21-Oct-2012 Richard Smith <richard-llvm@metafoo.co.uk> Unrevert r166268, reverted in r166272, with a fix for the issue which Nick
found: if an overloaded operator& is present before a template definition,
the expression &T::foo is represented as a CXXOperatorCallExpr, not as a
UnaryOperator, so we didn't notice that it's permitted to reference a non-static
data member of an unrelated class.

While investigating this, I discovered another problem in this area: we are
treating template default arguments as unevaluated contexts during substitution,
resulting in performing incorrect checks for uses of non-static data members in
C++11. That is not fixed by this patch (I'll look into this soon; it's related
to the failure to correctly instantiate constexpr function templates), but was
resulting in this bug not firing in C++11 mode (except with -Wc++98-compat).

Original message:

PR14124: When performing template instantiation of a qualified-id outside of a
class, diagnose if the qualified-id instantiates to a non-static class member.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166385 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-member-expr.cpp
8e8fb3be5bd78f0564444eca02b404566a5f3b5d 19-Oct-2012 Andy Gibbs <andyg1001@hotmail.co.uk> Prior to adding the new "expected-no-diagnostics" directive to VerifyDiagnosticConsumer, make the necessary adjustment to 580 test-cases which will henceforth require this new directive.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166280 91177308-0d34-0410-b5e6-96231b3b80d8
ckermann.cpp
lias-church-numerals.cpp
lias-template-template-param.cpp
rray-to-pointer-decay.cpp
tomics.cpp
efault-arguments-cxx0x.cpp
ependent-base-member-init.cpp
ependent-expr.cpp
num-argument.cpp
xample-typelist.cpp
nstantiate-array.cpp
nstantiate-attr.cpp
nstantiate-decl-init.cpp
nstantiate-declref-ice.cpp
nstantiate-deeply.cpp
nstantiate-dependent-nested-name.cpp
nstantiate-elab-type-specifier.cpp
nstantiate-enum-2.cpp
nstantiate-friend-class.cpp
nstantiate-local-class.cpp
nstantiate-non-type-template-parameter.cpp
nstantiate-overloaded-arrow.cpp
nstantiate-sizeof.cpp
nstantiation-default-3.cpp
ssue150.cpp
ookup-dependent-bases.cpp
ember-initializers.cpp
ested-linkage.cpp
perator-function-id-template.cpp
verload-uneval.cpp
ragma-ms_struct.cpp
emp_class_spec_blocks.cpp
emplate-class-traits.cpp
ypo-dependent-name.cpp
nresolved-construct.cpp
79cf161f178e36ce6d8aeea2a247e367b8d0fc34 19-Oct-2012 Nick Lewycky <nicholas@mxc.ca> Revert r166268, this fix for a crash-on-invalid introduced a rejects-valid.
Richard has an unreduced testcase to work with.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166272 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-member-expr.cpp
80ddc31c5379df78a007eaf08d531efdbcd9b161 19-Oct-2012 Richard Smith <richard-llvm@metafoo.co.uk> PR14124: When performing template instantiation of a qualified-id outside of a
class, diagnose if the qualified-id instantiates to a non-static class member.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166268 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-member-expr.cpp
919a2d7a63eec8f6e1e95e85306e0dc21ef91883 28-Sep-2012 Eli Friedman <eli.friedman@gmail.com> Fix a regression from r164656.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164804 91177308-0d34-0410-b5e6-96231b3b80d8
eduction-crash.cpp
54b3ba8cf2eb4886a88cdb8adedb15f43333ff1d 25-Sep-2012 Richard Smith <richard-llvm@metafoo.co.uk> Don't produce diagnostics for missing ctor-initializers during template
instantiations if we encountered errors parsing some of the initializers.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164578 91177308-0d34-0410-b5e6-96231b3b80d8
lass-template-ctor-initializer.cpp
5d99a252c63a7745bcd71231ca5240d2a65e4f1d 22-Sep-2012 Richard Smith <richard-llvm@metafoo.co.uk> Fix bug which sometimes resulted in further diagnostics being produced after a
fatal error. Previously, if a fatal error was followed by a diagnostic which
was suppressed due to a SFINAETrap, we'd forget that we'd seen a fatal error.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164437 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-exception-spec-cxx11.cpp
nstantiation-depth-exception-spec.cpp
nstantiation-depth-subst-2.cpp
nstantiation-depth-subst.cpp
ae19fbba559d8199d1f2b7154863180b0ae22ac7 13-Sep-2012 Douglas Gregor <dgregor@apple.com> Don't perform template argument deduction against invalid templates;
it's likely to lead to a crash later on. Fixes PR12933 /
<rdar://problem/11525335>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163838 91177308-0d34-0410-b5e6-96231b3b80d8
eduction-crash.cpp
cddbc1d5872c96cd8c3ad3ddededa304757270d7 06-Sep-2012 Richard Smith <richard-llvm@metafoo.co.uk> Don't try to check override control for invalid member functions. Fixes a crash in a corner case. Patch by Olivier Goffart!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163337 91177308-0d34-0410-b5e6-96231b3b80d8
ested-template.cpp
50f88b99c60c2ed31b339cd8bd484766cc9e916b 30-Aug-2012 Nico Weber <nicolasweber@gmx.de> Reland r160052: Default to -std=c++11 on Windows.

Also update the tests that rely on c++98 to explicitly mention that.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162890 91177308-0d34-0410-b5e6-96231b3b80d8
nject-templated-friend-post.cpp
0576681bac125be07f77f66b02a3dba2c3a24557 18-Aug-2012 Richard Smith <richard-llvm@metafoo.co.uk> PR41111, PR5925, PR13210: Teach tentative parsing to annotate identifiers and
nested names as id-expressions, using the annot_primary_expr annotation, where
possible. This removes some redundant lookups, and also allows us to
typo-correct within tentative parsing, and to carry on disambiguating past an
identifier which we can determine will fail lookup as both a type and as a
non-type, allowing us to disambiguate more declarations (and thus offer
improved error recovery for such cases).

This also introduces to the parser the notion of a tentatively-declared name,
which is an identifier which we *might* have seen a declaration for in a
tentative parse (but only if we end up disambiguating the tokens as a
declaration). This is necessary to correctly disambiguate cases where a
variable is used within its own initializer.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162159 91177308-0d34-0410-b5e6-96231b3b80d8
lass-template-id.cpp
ember-access-ambig.cpp
50800fc551ac6b8a95cca662223e7f061bbd169a 08-Aug-2012 David Blaikie <dblaikie@gmail.com> Implement warning for integral null pointer constants other than the literal 0.

This is effectively a warning for code that violates core issue 903 & thus will
become standard error in the future, hopefully. It catches strange null
pointers such as: '\0', 1 - 1, const int null = 0; etc...

There's currently a flaw in this warning (& the warning for 'false' as a null
pointer literal as well) where it doesn't trigger on comparisons (ptr == '\0'
for example). Fix to come in a future patch.

Also, due to this only being a warning, not an error, it triggers quite
frequently on gtest code which tests expressions for null-pointer-ness in a
SFINAE context (so it wouldn't be a problem if this was an error as in an
actual implementation of core issue 903). To workaround this for now, the
diagnostic does not fire in unevaluated contexts.

Review by Sean Silva and Richard Smith.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161501 91177308-0d34-0410-b5e6-96231b3b80d8
xplicit-instantiation.cpp
nstantiate-member-class.cpp
b9c6261d02f688d0a9a36b736ad5956fbc737854 30-Jul-2012 Richard Smith <richard-llvm@metafoo.co.uk> Improvements to vexing-parse warnings. Make the no-parameters case more
accurate by asking the parser whether there was an ambiguity rather than trying
to reverse-engineer it from the DeclSpec. Make the with-parameters case have
better diagnostics by using semantic information to drive the warning,
improving the diagnostics and adding a fixit.

Patch by Nikola Smiljanic. Some minor changes by me to suppress diagnostics for
declarations of the form 'T (*x)(...)', which seem to have a very high false
positive rate, and to reduce indentation in 'warnAboutAmbiguousFunction'.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160998 91177308-0d34-0410-b5e6-96231b3b80d8
ypename-specifier.cpp
b9d0b76e42fd2d4cdfd135220302458d03ad09fe 27-Jul-2012 Richard Smith <richard-llvm@metafoo.co.uk> Final piece of core issue 1330: delay computing the exception specification of
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
nstantiation-depth.cpp
aa488ea287c219565b5169d50142947d1b63a6ca 16-Jul-2012 Richard Smith <richard-llvm@metafoo.co.uk> More for PR11848: a pack expansion type isn't necessarily type-dependent (its
pattern might be an alias template which doesn't use its arguments). It's always
instantiation-dependent, though.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160246 91177308-0d34-0410-b5e6-96231b3b80d8
lias-templates.cpp
7e54fb5fcc7d7b8e843501652cf7c19cea6c4c57 16-Jul-2012 Richard Smith <richard-llvm@metafoo.co.uk> PR13365: Fix code which was trying to treat an array of DeducedTemplateArgument
as an array of its base class TemplateArgument. Switch the const
TemplateArgument* parameters of InstantiatingTemplate's constructors to
ArrayRef<TemplateArgument> to prevent this from happening again in the future.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160245 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiation-backtrace.cpp
d8672ef2d343a0dbfe838724fb2d9fb4efea6041 16-Jul-2012 Richard Smith <richard-llvm@metafoo.co.uk> Related to PR11848 and core-21989: switch ContainsUnexpandedParameterPack from
being a property of a canonical type to being a property of the fully-sugared
type. This should only make a difference in the case where an alias template
ignores one of its parameters, and that parameter is an unexpanded parameter
pack.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160244 91177308-0d34-0410-b5e6-96231b3b80d8
lias-templates.cpp
f5baeb4af53b79a0d92a4ab7b7eba19bd721f344 16-Jul-2012 Richard Smith <richard-llvm@metafoo.co.uk> PR13368: Halve the instantiation depth of this test again. Apparently, FreeBSD
has a much lower default stack limit than the systems I have access to.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160240 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiation-depth-defarg.cpp
838925dc841f0968ac5daf941aed5d2331775a59 13-Jul-2012 Richard Smith <richard-llvm@metafoo.co.uk> Provide a special-case diagnostic when two class member functions instantiate
to the same signature. Fix a bug in the type printer which would cause this
diagnostic to print wonderful types like 'const const int *'.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160161 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-method.cpp
6098381c29c2693832aa81ef046cf21a49729436 09-Jul-2012 Richard Smith <richard-llvm@metafoo.co.uk> PR13136:

* When substituting a reference to a non-type template parameter pack where the
corresponding argument is a pack expansion, transform into an expression
which contains an unexpanded parameter pack rather than into an expression
which contains a pack expansion. This causes the SubstNonTypeTemplateParmExpr
to be inside the PackExpansionExpr, rather than outside, so the expression
still looks like a pack expansion and can be deduced.

* Teach MarkUsedTemplateParameters that we can deduce a reference to a template
parameter if it's wrapped in a SubstNonTypeTemplateParmExpr (such nodes are
added during alias template substitution).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159922 91177308-0d34-0410-b5e6-96231b3b80d8
lias-templates.cpp
6ff6cfe696df9e618c3deae7b34c701d58484c23 08-Jul-2012 Richard Smith <richard-llvm@metafoo.co.uk> Halve template depth in an attempt to get this test passing on mingw32.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159917 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiation-depth-defarg.cpp
fff457fc28f18fd75b8f1b0b01edf6a042afcff9 08-Jul-2012 NAKAMURA Takumi <geek4civic@gmail.com> test/SemaTemplate/instantiation-depth-defarg.cpp: Mark as XFAIL:mingw for now.

I'll try to increase stack size later.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159912 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiation-depth-defarg.cpp
5a343d7856e5de04fd92b6192e94becddf541e3e 08-Jul-2012 Richard Smith <richard-llvm@metafoo.co.uk> PR13243: When deducing a non-type template parameter which is specified as an
expression, skip over any SubstNonTypeTemplateParmExprs which alias templates
may have inserted before checking for a DeclRefExpr referring to a non-type
template parameter declaration.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159909 91177308-0d34-0410-b5e6-96231b3b80d8
lias-templates.cpp
ab91ef1dbe524bba3c0147b11dfdd394153c783d 08-Jul-2012 Richard Smith <richard-llvm@metafoo.co.uk> PR9793: Treat substitution as an instantiation step for the purpose of the
-ftemplate-depth limit. There are various ways to get an infinite (or merely
huge) stack of substitutions with no intervening instantiations. This is also
consistent with gcc's behavior.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159907 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiation-depth-defarg.cpp
nstantiation-depth-subst-2.cpp
nstantiation-depth-subst.cpp
ff817f7070c0308e9d4486432b774005d4f8e420 07-Jul-2012 Richard Smith <richard-llvm@metafoo.co.uk> When marking virtual functions as used for a class' vtable, mark all functions
which will appear in the vtable as used, not just those ones which were
declared within the class itself. Fixes an issue reported as comment#3 in
PR12763 -- we sometimes assert in codegen if we try to emit a reference to a
function declaration which we've not marked as referenced. This also matches
gcc's observed behavior.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159895 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-exception-spec-cxx11.cpp
6b02009359a462ffe633696a4441313b462e6566 25-Jun-2012 Nico Weber <nicolasweber@gmx.de> Make explicit specializations at class scope work
for non-type template parameters in microsoft mode.
PR12709.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159147 91177308-0d34-0410-b5e6-96231b3b80d8
s-function-specialization-class-scope.cpp
94c4d61625122e7a7ac9a45418e88ad742fcc661 22-Jun-2012 Nico Weber <nicolasweber@gmx.de> Show fixit for unqualified calls to methods of dependent bases
when the calling site is a member function template.

Effectively reverts r111675.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159004 91177308-0d34-0410-b5e6-96231b3b80d8
ecovery-crash.cpp
4b554f4756cefdce6e0109e96d2f13d594b30b8c 20-Jun-2012 Nico Weber <nicolasweber@gmx.de> Allow unqualified lookup of non-dependent member functions
in microsoft mode. Fixes PR12701.

The code for this was already in 2 of the 3 branches of a
conditional and missing in the 3rd branch, so lift it above
the conditional.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158842 91177308-0d34-0410-b5e6-96231b3b80d8
s-lookup-template-base-classes.cpp
ca5233044ef679840d1ad1c46a36b16e2ee8a6e1 10-Jun-2012 Richard Smith <richard-llvm@metafoo.co.uk> PR13064: Store whether an in-class initializer uses direct or copy
initialization, and use that information to produce the right kind of
initialization during template instantiation.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158288 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-init.cpp
8c14de83188640bab9cae658e92a655e6d4fd484 08-Jun-2012 Kaelyn Uhrain <rikka@google.com> Fix up the 'typename' suggestion logic introduced in r157085, based on
feedback from Doug Gregor.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158185 91177308-0d34-0410-b5e6-96231b3b80d8
ypename-specifier.cpp
d95e95ec5300249f5b7c6f1b72bde59e5141069c 22-May-2012 Simon Atanasyan <satanasyan@mips.com> Replace inline asm constraint "=a" by the more general constraint "=r".
That extend a range of platforms support this test case.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157247 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-1.cpp
d21016f0b6d9dfcce9cd9f2d1451286e75d9de48 20-May-2012 Eli Friedman <eli.friedman@gmail.com> Make delegating initializers use a similar codepath to base initializers in dependent contexts. PR12890.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157136 91177308-0d34-0410-b5e6-96231b3b80d8
elegating-constructors.cpp
ab7ad72f432810011041c5628b377f77cb1c81e6 19-May-2012 Kaelyn Uhrain <rikka@google.com> Suggest adding 'typename' when it would make the compiler
accept the template argument expression as a type.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157085 91177308-0d34-0410-b5e6-96231b3b80d8
ypename-specifier.cpp
be0ee875d8a91c031a085cbbd73ad9e8dc1aa8ff 15-May-2012 David Blaikie <dblaikie@gmail.com> Improve some of the conversion warnings to fire on conversion to bool.

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
ember-template-access-expr.cpp
83a22ecbf52c06b4ee364f3fadcdb0abaf2dabf6 09-May-2012 Richard Smith <richard-llvm@metafoo.co.uk> Recover properly if a class member declaration starts with a scope specifier
or template-id which can't be parsed.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156468 91177308-0d34-0410-b5e6-96231b3b80d8
ependent-base-classes.cpp
4493c0aa8add05b2fc534b0d8970c4b5480fad3b 09-May-2012 Richard Smith <richard-llvm@metafoo.co.uk> A little tweak to the SFINAE condition reporting. Don't say:

candidate template ignored: substitution failed [with T = int]: no type named 'type' in 'std::enable_if<false, void>'

Instead, just say:

candidate template ignored: disabled by 'enable_if' [with T = int]

... and point at the enable_if condition which (we assume) failed.

This is applied to all cases where the user writes 'typename enable_if<...>::type' (optionally prefixed with a nested name specifier), and 'enable_if<...>' names a complete class type which does not have a member named 'type', and this results in a candidate function being ignored in a SFINAE context. Thus it catches 'std::enable_if', 'std::__1::enable_if', 'boost::enable_if' and 'llvm::enable_if'.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156463 91177308-0d34-0410-b5e6-96231b3b80d8
verload-candidates.cpp
b8590f3572158bde97f14037c4cc8f4a57c8d810 07-May-2012 Richard Smith <richard-llvm@metafoo.co.uk> When we suppress an error due to SFINAE, stash the diagnostic away with the
overload candidate, and include its message in any subsequent 'candidate not
viable due to substitution failure' note we may produce.

To keep the note small (since the 'overload resolution failed' diagnostics are
often already very verbose), the text of the SFINAE diagnostic is included as
part of the text of the note, and any notes which were attached to it are
discarded.

There happened to be spare space in OverloadCandidate into which a
PartialDiagnosticAt could be squeezed, and this patch goes to lengths to avoid
unnecessary PartialDiagnostic copies, resulting in no slowdown that I could
measure. (Removal in passing of some PartialDiagnostic copies has resulted in a
slightly smaller clang binary overall.) Even on a torture test, I was unable to
measure a memory increase of above 0.2%.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156297 91177308-0d34-0410-b5e6-96231b3b80d8
verload-candidates.cpp
d8a1361ab4a36d06fb5d37b07d444f4f9fcdb4a8 01-May-2012 David Blaikie <dblaikie@gmail.com> Fix test cases broken by 155936.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155948 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-objc-1.mm
9b94cd1b2527c8dc9ec19a8608f2313010e721b5 27-Apr-2012 Eli Friedman <eli.friedman@gmail.com> Add a missing ExpressionEvaluationContext for template default arguments. Fixes PR12581.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155670 91177308-0d34-0410-b5e6-96231b3b80d8
efault-expr-arguments.cpp
ad579916bc402cf617793e94770bab78e9bdaec8 25-Apr-2012 Argyrios Kyrtzidis <akyrtzi@gmail.com> When resolving default template arguments, it should be done in the declaration context
of the template what we are going to instantiate.

Fixes various crashes of rdar://11242625 & http://llvm.org/PR11421.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155576 91177308-0d34-0410-b5e6-96231b3b80d8
ependent-names.cpp
6e21b16ab226959341b85e16060fd81f71cee628 22-Apr-2012 Richard Smith <richard-llvm@metafoo.co.uk> PR12585: When processing a friend template inside a class template, don't
pretend there was no previous declaration -- that can lead us to injecting
a class template (with no access specifier) into a class scope. Instead,
just avoid the problematic checks.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155303 91177308-0d34-0410-b5e6-96231b3b80d8
riend-template.cpp
227e9f6f08a8715f341b37db6be50d60dff7f863 21-Apr-2012 Richard Smith <richard-llvm@metafoo.co.uk> Fix test failure.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155271 91177308-0d34-0410-b5e6-96231b3b80d8
lass-template-decl.cpp
71c598fc0515f7a95f2e0051ca056b6114970fe5 21-Apr-2012 Richard Smith <richard-llvm@metafoo.co.uk> When declaring a template, check that the context doesn't already contain a
declaration of the same name. r155187 caused us to miss this if the prior
declaration did not declare a type.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155269 91177308-0d34-0410-b5e6-96231b3b80d8
lass-template-decl.cpp
c93e014cd43b08812370cfc8ef7bb7b92305f8fb 20-Apr-2012 Richard Smith <richard-llvm@metafoo.co.uk> Replace r155185 with a better fix, which also addresses PR12557. When looking
up an elaborated type specifier in a friend declaration, only look for type
declarations, per [basic.lookup.elab]p2. If we know that the redeclaration
lookup for a friend class template in a dependent context finds a non-template,
don't delay the diagnostic to instantiation time.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155187 91177308-0d34-0410-b5e6-96231b3b80d8
lass-template-decl.cpp
riend-template.cpp
b2f245e77de13c6619923d6569a947e6dcdd0666 20-Apr-2012 Richard Smith <richard-llvm@metafoo.co.uk> Fix a bug which creduce found reducing PR12585.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155185 91177308-0d34-0410-b5e6-96231b3b80d8
lass-template-decl.cpp
eb382ec1507cf2c8c12d7443d0b67c076223aec6 19-Apr-2012 Patrick Beard <pcbeard@mac.com> Implements boxed expressions for Objective-C. <rdar://problem/10194391>


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155082 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-objc-1.mm
13bffc532bafd45d4a77867993c1afb83c7661be 19-Apr-2012 Richard Smith <richard-llvm@metafoo.co.uk> PR 12586: Fix assert while running libc++ testsuite: deal with exception
specifications on member function templates of class templates and other such
nested beasties. Store the function template from which we are to instantiate
an exception specification rather than trying to deduce it. Plus some
additional test cases.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155076 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-exception-spec-cxx11.cpp
87162c2e528921aabb84e96fe7272348a4b3354e 18-Apr-2012 Richard Smith <richard-llvm@metafoo.co.uk> PR12569: Instantiate exception specifications of explicit instantiations
and explicit specializations of function templates appropriately.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154956 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-exception-spec-cxx11.cpp
e6975e9b0985ad7f7ff9187e38d95bfe9ac4181b 17-Apr-2012 Richard Smith <richard-llvm@metafoo.co.uk> Implement DR1330 in C++11 mode, to support libstdc++4.7 which uses it.

We have a new flavor of exception specification, EST_Uninstantiated. A function
type with this exception specification carries a pointer to a FunctionDecl, and
the exception specification for that FunctionDecl is instantiated (if needed)
and used in the place of the function type's exception specification.

When a function template declaration with a non-trivial exception specification
is instantiated, the specialization's exception specification is set to this
new 'uninstantiated' kind rather than being instantiated immediately.

Expr::CanThrow has migrated onto Sema, so it can instantiate exception specs
on-demand. Also, any odr-use of a function triggers the instantiation of its
exception specification (the exception specification could be needed by IRGen).
In passing, fix two places where a DeclRefExpr was created but the corresponding
function was not actually marked odr-used. We used to get away with this, but
don't any more.

Also fix a bug where instantiating an exception specification which refers to
function parameters resulted in a crash. We still have the same bug in default
arguments, which I'll be looking into next.

This, plus a tiny patch to fix libstdc++'s common_type, is enough for clang to
parse (and, in very limited testing, support) all of libstdc++4.7's standard
headers.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154886 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-declref.cpp
nstantiate-exception-spec-cxx11.cpp
e31b8fb25b458f00e31dcd657c0840e5238e0f05 05-Apr-2012 David Blaikie <dblaikie@gmail.com> Enable warn_impcast_literal_float_to_integer by default.

This diagnostic seems to be production ready, it's just an oversight that it
wasn't turned on by default.

The test changes are a bit of a mixed bag. Some tests that seemed like they
clearly didn't need to use this behavior have been modified not to use it.
Others that I couldn't be sure about, I added the necessary expected-warnings
to.

It's possible the diagnostic message could be improved to make it clearer that
this warning can be suppressed by using a value that won't lose precision when
converted to the target type (but can still be a floating point literal, such
as "bool b = 1.0;").

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154068 91177308-0d34-0410-b5e6-96231b3b80d8
ember-template-access-expr.cpp
0f6931a2c2cf7f19bab07ab752dfd632d8494205 02-Apr-2012 Richard Smith <richard-llvm@metafoo.co.uk> PR12438: Profile a reference to a type template parameter by depth and index,
not by canonical decl. This only matters for sizeof...(Pack) expressions; in
all other cases, we'd profile it as a type instead.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153884 91177308-0d34-0410-b5e6-96231b3b80d8
anonical-expr-type-0x.cpp
8b0fa5241a0416fc50dfbb7e38f20e777f191848 30-Mar-2012 Douglas Gregor <dgregor@apple.com> If we encounter a friend class template for which we cannot resolve
the nested-name-specifier (e.g., because it is dependent), do not
error even though we can't represent it in the AST at this point.

This is a horrible, horrible hack. The actual feature we still need to
implement (for C++98!) is covered by PR12292. However, we used to
silently accept this code, so when we recently started rejecting it we
caused some regressions (e.g., <rdar://problem/11147355>). This hack
brings us back to the passable-but-not-good state we had previously.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153752 91177308-0d34-0410-b5e6-96231b3b80d8
riend-template.cpp
564f4c5664f552becbd05407611a92754c40e641 22-Mar-2012 Richard Smith <richard-llvm@metafoo.co.uk> During the instantiation of a class template specialization, that
specialization is known to be incomplete. If we're asked to try to
complete it, don't attempt to instantiate it again -- that can lead
to stack overflow, and to rejects-valids if the class being incomplete
is not an error.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153236 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-self.cpp
957ff27311d444fb87b5b3acb6f44d5de4533b23 18-Mar-2012 Douglas Gregor <dgregor@apple.com> Replace a FIXME with a diagnostic when we can't resolve the
nested-name-specifier for a class template declaration. Fixes PR12291.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153006 91177308-0d34-0410-b5e6-96231b3b80d8
ualified-id.cpp
69730c115c2d0fec2f20609d905d920a5a41b29b 12-Mar-2012 Richard Smith <richard-llvm@metafoo.co.uk> Fix parsing of type-specifier-seq's. Types are syntactically allowed to be
defined here, but not semantically, so

new struct S {};

is always ill-formed, even if there is a struct S in scope.

We also had a couple of bugs in ParseOptionalTypeSpecifier caused by it being
under-loved (due to it only being used in a few places) so merge it into
ParseDeclarationSpecifiers with a new DeclSpecContext. To avoid regressing, this
required improving ParseDeclarationSpecifiers' diagnostics in some cases. This
also required teaching ParseSpecifierQualifierList about constexpr... which
incidentally fixes an issue where we'd allow the constexpr specifier in other
bad places.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152549 91177308-0d34-0410-b5e6-96231b3b80d8
eduction-crash.cpp
4a90e1a8a296c30e94e34e19974d84fb8cfc2bd3 07-Mar-2012 Eli Friedman <eli.friedman@gmail.com> Correct test from r152189.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152191 91177308-0d34-0410-b5e6-96231b3b80d8
emp_arg_template.cpp
9e9c454b12671a624f666fc6fbf132fdf183effc 07-Mar-2012 Eli Friedman <eli.friedman@gmail.com> Make sure we consistently canonicalize types when canonicalizing TemplateTemplateParmDecls. PR12179.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152189 91177308-0d34-0410-b5e6-96231b3b80d8
emp_arg_template.cpp
16581335fc32abcbc6ab14eda7af38cf759664b7 02-Mar-2012 Richard Smith <richard-llvm@metafoo.co.uk> Ensure that we instantiate static reference data members of class templates
early, since their values can be used in constant expressions in C++11. For
odr-use checking, the opposite change is required, since references are
odr-used whether or not they satisfy the requirements for appearing in a
constant expression.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151881 91177308-0d34-0410-b5e6-96231b3b80d8
onstexpr-instantiate.cpp
72b8b1ef9f7fb4f66fefcbd8d82fce2301b851d4 29-Feb-2012 Eli Friedman <eli.friedman@gmail.com> A couple minor bug-fixes for template instantiation for expressions which are sometimes potentially evaluated.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151707 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-sizeof.cpp
nstantiate-typeof.cpp
a2d7dfab309375fbf016b650fa74f9b5d03a9752 16-Feb-2012 Eli Friedman <eli.friedman@gmail.com> Shift Microsoft enum extensions from -fms-extensions to -fms-compatibility, so -fms-extensions doesn't affect enum semantics in incompatible ways. <rdar://problem/10657186>.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150663 91177308-0d34-0410-b5e6-96231b3b80d8
num-forward.cpp
37ce0104b182c9410cf2a76fe5a63a81dac876ac 15-Feb-2012 Richard Smith <richard-llvm@metafoo.co.uk> If a static data member of a class template which could be used in a constant
expression is referenced, defined, then referenced again, make sure we
instantiate it the second time it's referenced. This is the static data member
analogue of r150518.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150560 91177308-0d34-0410-b5e6-96231b3b80d8
onstexpr-instantiate.cpp
57b9c4e9d85971e20ab0dac3eadabae672c43c62 14-Feb-2012 Richard Smith <richard-llvm@metafoo.co.uk> If a constexpr function template specialization is referenced, and then the
template is defined, and then the specialization is referenced again, don't
forget to instantiate the template on the second reference. Use the source
location of the first reference as the point of instantiation, though.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150518 91177308-0d34-0410-b5e6-96231b3b80d8
onstexpr-instantiate.cpp
5b9cc5df25c2198f270dd1d5c438fdce70d4051d 12-Feb-2012 Sebastian Redl <sebastian.redl@getdesigned.at> Represent C++ direct initializers as ParenListExprs before semantic analysis
instead of having a special-purpose function.

- ActOnCXXDirectInitializer, which was mostly duplication of
AddInitializerToDecl (leading e.g. to PR10620, which Eli fixed a few days
ago), is dropped completely.
- MultiInitializer, which was an ugly hack I added, is dropped again.
- We now have the infrastructure in place to distinguish between
int x = {1};
int x({1});
int x{1};
-- VarDecl now has getInitStyle(), which indicates which of the above was used.
-- CXXConstructExpr now has a flag to indicate that it represents list-
initialization, although this is not yet used.
- InstantiateInitializer was renamed to SubstInitializer and simplified.
- ActOnParenOrParenListExpr has been replaced by ActOnParenListExpr, which
always produces a ParenListExpr. Placed that so far failed to convert that
back to a ParenExpr containing comma operators have been fixed. I'm pretty
sure I could have made a crashing test case before this.

The end result is a (I hope) considerably cleaner design of initializers.
More importantly, the fact that I can now distinguish between the various
initialization kinds means that I can get the tricky generalized initializer
test cases Johannes Schaub supplied to work. (This is not yet done.)

This commit passed self-host, with the resulting compiler passing the tests. I
hope it doesn't break more complicated code. It's a pretty big change, but one
that I feel is necessary.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150318 91177308-0d34-0410-b5e6-96231b3b80d8
ested-incomplete-class.cpp
eefb3d5b49c844347f212073a7e975b8118fe8e9 10-Feb-2012 Richard Smith <richard-llvm@metafoo.co.uk> Track whether a function type has a trailing return type as type sugar. Use this
to pretty-print such function types better, and to fix a case where we were not
instantiating templates in lexical order. In passing, move the Variadic bit from
Type's bitfields to FunctionProtoType to get the Type bitfields down to 32 bits.
Also ensure that we always substitute the return type of a function when
substituting explicitly-specified arguments, since that can cause us to bail
out with a SFINAE error before we hit a hard error in parameter substitution.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150241 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiation-order.cpp
09aaaa43cd5e24d21c666350476802e7d01d6988 10-Feb-2012 Richard Smith <richard-llvm@metafoo.co.uk> --lies.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150240 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-complete.cpp
572ae0a32ece4bd7ea24e3d8f9bfe3e11aa26414 10-Feb-2012 Eli Friedman <eli.friedman@gmail.com> Make sure we convert struct layout pragmas to attributes for class templates the same way we do for non-template classes. <rdar://problem/10791194>.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150221 91177308-0d34-0410-b5e6-96231b3b80d8
ragma-ms_struct.cpp
9d9922af13edf3ddf8804a41a98d997324fdd58e 06-Feb-2012 Abramo Bagnara <abramo.bagnara@gmail.com> Fixed instantiation of DependentScopeDeclRefExpr.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149868 91177308-0d34-0410-b5e6-96231b3b80d8
emplate-id-expr.cpp
emplate-id-printing.cpp
bd2b6f0e57e2380bd992f50af434a9970d8e23bb 28-Jan-2012 Abramo Bagnara <abramo.bagnara@gmail.com> Added tests for template keyword presence.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149177 91177308-0d34-0410-b5e6-96231b3b80d8
emplate-id-printing.cpp
d1bb4ae6cbc0f8bea4b329e040f58b18c03388e7 25-Jan-2012 Douglas Gregor <dgregor@apple.com> When we're substituting into a function parameter pack and expect to
get a function parameter pack (but don't due to weird substitutions),
complain. Fixes the last bit of PR11848.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148960 91177308-0d34-0410-b5e6-96231b3b80d8
lias-templates.cpp
c0536c8294fc4453f0f1d1cf24a62bfc725fd492 25-Jan-2012 Richard Smith <richard-llvm@metafoo.co.uk> Fix PR11848: decree that an alias template contains an unexpanded parameter pack
iff its substitution contains an unexpanded parameter pack. This has the effect
that we now reject declarations such as this (which we used to crash when
expanding):

template<typename T> using Int = int;
template<typename ...Ts> void f(Int<Ts> ...ints);

The standard is inconsistent on how this case should be treated.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148905 91177308-0d34-0410-b5e6-96231b3b80d8
lias-templates.cpp
ecd7b04ae7764179d40ee4e3e49c99d1fbcb4eff 24-Jan-2012 Douglas Gregor <dgregor@apple.com> Promote the extension warning for attempts to catch a reference or
pointer to incomplete type from an ExtWarn to an error. We put the
ExtWarn in place as part of a workaround for Boost (PR6527), but it
(1) doesn't actually match a GCC extension and (2) has been fixed for
two years in Boost, and (3) causes us to emit code that fails badly at
run time, so it's a bad idea to keep it. Fixes PR11803.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148838 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-function-1.cpp
244ee7b89a483fd3764637abdf95de2893b437d0 15-Jan-2012 Richard Smith <richard-llvm@metafoo.co.uk> Pedantic diagnostic correction: in C++, we have integral constant expressions,
not integer constant expressions. In passing, fix the 'folding is an extension'
diagnostic to not claim we're accepting the code, since that's not true in
-pedantic-errors mode, and add this diagnostic to -Wgnu.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148209 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-1.cpp
cb7709c06027448c754dd03e2e521d82d04818bf 05-Jan-2012 Richard Smith <richard-llvm@metafoo.co.uk> PR10828: Produce a warning when a no-arguments function is declared in block
scope, when no other indication is provided that the user intended to declare a
function rather than a variable.

Remove some false positives from the existing 'parentheses disambiguated as a
function' warning by suppressing it when the declaration is marked as 'typedef'
or 'extern'.

Add a new warning group -Wvexing-parse containing both of these warnings.

The new warning is enabled by default; despite a number of false positives (and
one bug) in clang's test-suite, I have only found genuine bugs with it when
running it over a significant quantity of real C++ code.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147599 91177308-0d34-0410-b5e6-96231b3b80d8
lass-template-ctor-initializer.cpp
d7c56e1114bfe7d461786903bb720d2c6efc05a1 29-Dec-2011 Richard Smith <richard-llvm@metafoo.co.uk> Change the diagnostics which said 'accepted as an extension' to instead say
'is an extension'. The former is inappropriate and confusing when building with
-Werror/-pedantic-errors.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147357 91177308-0d34-0410-b5e6-96231b3b80d8
lass-template-spec.cpp
nstantiate-static-var.cpp
emp_class_spec_neg.cpp
9241057266d3460392cbb7fec6ec942d3330ece3 23-Dec-2011 Argyrios Kyrtzidis <akyrtzi@gmail.com> Pass context and access to Parser::ParseExplicitInstantiation() for
good parser error recovery and for not crashing.

We still have a accepts-invalid-code bug.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147216 91177308-0d34-0410-b5e6-96231b3b80d8
xplicit-instantiation.cpp
3e9ea0b8cd7c4691d62e385245556be5fded58a7 21-Dec-2011 Richard Smith <richard-llvm@metafoo.co.uk> C++ constant expression handling: eagerly instantiate static const integral data
members of class templates so that their values can be used in ICEs. This
required reverting r105465, to get such instantiated members to be included in
serialized ASTs.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147023 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-declref-ice.cpp
2fe9b7fb07dff15dd15dd8755a9a9e6de0fe46fc 15-Dec-2011 Richard Trieu <rtrieu@google.com> Modify how the -verify flag works. Currently, the verification string and
diagnostic message are compared. If either is a substring of the other, then
no error is given. This gives rise to an unexpected case:

// expect-error{{candidate function has different number of parameters}}

will match the following error messages from Clang:

candidate function has different number of parameters (expected 1 but has 2)
candidate function has different number of parameters

It will also match these other error messages:

candidate function
function has different number of parameters
number of parameters

This patch will change so that the verification string must be a substring of
the diagnostic message before accepting. Also, all the failing tests from this
change have been corrected. Some stats from this cleanup:

87 - removed extra spaces around verification strings
70 - wording updates to diagnostics
40 - extra leading or trailing characters (typos, unmatched parens or quotes)
35 - diagnostic level was included (error:, warning:, or note:)
18 - flag name put in the warning (-Wprotocol)



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146619 91177308-0d34-0410-b5e6-96231b3b80d8
xplicit-instantiation.cpp
riend.cpp
nstantiate-expr-5.cpp
9d24a8be93b28488dbfb9bbe8aa6fe35b21a5b0c 13-Dec-2011 Francois Pichet <pichet2000@gmail.com> Implement the Microsoft __if_exists/if_not_exists extension in initializer-list.
Necessary to parse Microsoft ATL code.

Example:
int array[] = {
0,
__if_exists(CLASS::Type) {2, }
3
};

will declare an array of 2 or 3 elements depending on if CLASS::Type exists or not.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146447 91177308-0d34-0410-b5e6-96231b3b80d8
s-if-exists.cpp
2def77399ab3088106a2d61372344f5b7104e1a2 09-Dec-2011 David Blaikie <dblaikie@gmail.com> Add notes for suppressing and (if it's a zero-arg function returning bool) fixing the function-to-bool conversion warning.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146280 91177308-0d34-0410-b5e6-96231b3b80d8
esolve-single-template-id.cpp
e14ca9f509dc22d8fcc5d21d70d28a5848983b42 05-Dec-2011 Lang Hames <lhames@gmail.com> Add a warning for implicit conversion from function literals (and static
methods) to bool. E.g.

void foo() {}
if (f) { ... // <- Warns here.
}

Only applies to non-weak functions, and does not apply if the function address
is taken explicitly with the addr-of operator.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145849 91177308-0d34-0410-b5e6-96231b3b80d8
esolve-single-template-id.cpp
4d604d6f1d413864e7dad8e368ba9a69a3f478c7 03-Dec-2011 Francois Pichet <pichet2000@gmail.com> In Microsoft mode, don't perform typo correction in a template member function dependent context because it interferes with the "lookup into dependent bases of class templates" feature.

Basically typo correction will try to offer a correction instead of looking into type dependent base classes.

I found this problem while parsing Microsoft ATL code with clang.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145772 91177308-0d34-0410-b5e6-96231b3b80d8
s-lookup-template-base-classes.cpp
c8ff915c4bafe520548cc29d342951da23591ae1 25-Nov-2011 Francois Pichet <pichet2000@gmail.com> In Microsoft mode, make "Unqualified lookup into dependent bases of class templates" works inside a friend function definition at class scope.

Basically we have to look into the parent *lexical* DeclContext for friend functions at class scope. That's because calling GetParent() return the namespace or file DeclContext.

This fixes all remaining cases of "Unqualified lookup into dependent bases of class templates" when parsing MFC code with clang.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145127 91177308-0d34-0410-b5e6-96231b3b80d8
s-lookup-template-base-classes.cpp
c18c42345636e2866fed75c7e434fb659d747672 21-Nov-2011 Richard Smith <richard-llvm@metafoo.co.uk> Add driver arguments -ftemplate-depth=N and -fconstexpr-depth=N, with the same
semantics and defaults as the corresponding g++ arguments. The historical g++
argument -ftemplate-depth-N is kept for compatibility, but modern g++ versions
no longer document that option.

Add -cc1 argument -fconstexpr-depth N to implement the corresponding
functionality.

The -ftemplate-depth=N part of this fixes PR9890.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145045 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiation-depth.cpp
e6226ae490903717c8c07782f28bc8349543021f 17-Nov-2011 Francois Pichet <pichet2000@gmail.com> In Microsoft mode, make "Unqualified lookup into dependent bases of class templates" works inside default argument instantiation.

This is a little bit tricky because during default argument instantiation the CurContext points to a CXXMethodDecl but we can't use the keyword this or have an implicit member call generated.

This fixes 2 errors when parsing MFC code with clang.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144881 91177308-0d34-0410-b5e6-96231b3b80d8
s-lookup-template-base-classes.cpp
e614d6c6b12f20f0072c20eb312db2e80d1cb051 16-Nov-2011 Francois Pichet <pichet2000@gmail.com> In Microsoft mode, make "Unqualified lookup into dependent bases of class templates" works inside static functions.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144729 91177308-0d34-0410-b5e6-96231b3b80d8
s-lookup-template-base-classes.cpp
7432b90e88ac9e219f6e8a3151c097b0b7da933c 15-Nov-2011 Douglas Gregor <dgregor@apple.com> When we're checking access in a dependent context, don't try to look
at the bases of an undefined class. Fixes <rdar://problem/10438657>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144582 91177308-0d34-0410-b5e6-96231b3b80d8
rash-10438657.cpp
ef04ecf96d83cd3cbc7bf8cf36d4c7873964194e 11-Nov-2011 Francois Pichet <pichet2000@gmail.com> Move "Unqualified lookup into dependent bases of class templates" Microsoft specific behavior from -fms-extensions to -fms-compatibility.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144341 91177308-0d34-0410-b5e6-96231b3b80d8
s-lookup-template-base-classes.cpp
5b0c5199a7037d0435d75f37e3ba69a24f757931 08-Nov-2011 Douglas Gregor <dgregor@apple.com> Mark the overloaded atomic builtins as having custom type checking,
which they do. This avoids all of the default argument promotions that
we (1) don't want, and (2) undo during that custom type checking, and
makes sure that we don't run into trouble during template
instantiation. Fixes PR11320.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144110 91177308-0d34-0410-b5e6-96231b3b80d8
tomics.cpp
2c1227c4da661bdc0b1976740c3ff203ed7609b2 07-Nov-2011 Douglas Gregor <dgregor@apple.com> Drastically simplify the mapping from the declaration corresponding to
the injected-class-name of a class (or class template) to the
declaration that results from substituting the given template
arguments. Previously, we would actually perform a substitution into
the injected-class-name type and then retrieve the resulting
declaration. However, in certain, rare circumstances involving
deeply-nested member templates, we would get the wrong substitution
arguments.

This new approach just matches up the declaration with a declaration
that's part of the current context (or one of its parents), which will
either be an instantiation (during template instantiation) or the
declaration itself (during the definition of the template). This is
both more efficient (we're avoiding a substitution) and more correct
(we can't get the template arguments wrong in the member-template
case).

Fixes <rdar://problem/9676205>.

Reinstated, now that we have the fix in r143967.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143968 91177308-0d34-0410-b5e6-96231b3b80d8
lass-template-decl.cpp
efaa93aaa2653f4eb40e6a22e504a448da94aaf8 07-Nov-2011 Douglas Gregor <dgregor@apple.com> Tighten up the conditions under which we consider ourselves to be
entering the context of a nested-name-specifier. Fixes
<rdar://problem/10397846>.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143967 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-member-class.cpp
03ea52f9f0f6fc796ecae5b568a7be489438269b 04-Nov-2011 Devang Patel <dpatel@apple.com> Revert r143551. It is causing g++.dg/template/crash52.C test failure.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143725 91177308-0d34-0410-b5e6-96231b3b80d8
lass-template-decl.cpp
0b1beb7a295b20f7e05479d599dde027f9f692fe 02-Nov-2011 Douglas Gregor <dgregor@apple.com> Drastically simplify the mapping from the declaration corresponding to
the injected-class-name of a class (or class template) to the
declaration that results from substituting the given template
arguments. Previously, we would actually perform a substitution into
the injected-class-name type and then retrieve the resulting
declaration. However, in certain, rare circumstances involving
deeply-nested member templates, we would get the wrong substitution
arguments.

This new approach just matches up the declaration with a declaration
that's part of the current context (or one of its parents), which will
either be an instantiation (during template instantiation) or the
declaration itself (during the definition of the template). This is
both more efficient (we're avoiding a substitution) and more correct
(we can't get the template arguments wrong in the member-template
case).

Fixes <rdar://problem/9676205>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143551 91177308-0d34-0410-b5e6-96231b3b80d8
lass-template-decl.cpp
ea9f54aefc0cbf963df8b79028775a39bcf7393f 01-Nov-2011 Douglas Gregor <dgregor@apple.com> When we see an out-of-line definition of a member class template that
does not match any declaration in the class (or class template), be
sure to mark it as invalid. Fixes PR10924 / <rdar://problem/10119422>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143504 91177308-0d34-0410-b5e6-96231b3b80d8
ested-template.cpp
76852c218a207ef43583515cb835b6e855353a0f 01-Nov-2011 Douglas Gregor <dgregor@apple.com> Rework the AST for the initializer of a delegating constructor, so
that it retains source location information for the type. Aside from
general goodness (being able to walk the types described in that
information), we now have a proper representation for dependent
delegating constructors. Fixes PR10457 (for real).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143410 91177308-0d34-0410-b5e6-96231b3b80d8
elegating-constructors.cpp
f1f6d85694fcf772f6d602fd9709318b08b96328 26-Oct-2011 Richard Smith <richard-llvm@metafoo.co.uk> Fix crash due to missing array-to-pointer decay when instantiating an unresolved
member expression. Refactoring to follow.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143017 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-4.cpp
65019acfc46ffb191fac4e781ac0c4b8d0c8434e 25-Oct-2011 Douglas Gregor <dgregor@apple.com> Check for unexpanded parameter packs in the name that guards a
Microsoft __if_exists/__if_not_exists statement. Also note that we
weren't traversing DeclarationNameInfo *at all* within the
RecursiveASTVisitor, which would be rather fatal for variadic
templates.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142906 91177308-0d34-0410-b5e6-96231b3b80d8
s-if-exists.cpp
ba0513de93d2fab6db5ab30b6927209fcc883078 25-Oct-2011 Douglas Gregor <dgregor@apple.com> Implement support for dependent Microsoft __if_exists/__if_not_exists
statements. As noted in the documentation for the AST node, the
semantics of __if_exists/__if_not_exists are somewhat different from
the way Visual C++ implements them, because our parsed-template
representation can't accommodate VC++ semantics without serious
contortions. Hopefully this implementation is "good enough".


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142901 91177308-0d34-0410-b5e6-96231b3b80d8
s-if-exists.cpp
3896fc5d4daaf003e451e797e37de57dd8cf9cd5 25-Oct-2011 Douglas Gregor <dgregor@apple.com> Rework Microsoft __if_exists/__if_not_exists parsing and semantic
analysis to separate dependent names from non-dependent names. For
dependent names, we'll behave differently from Visual C++:

- For __if_exists/__if_not_exists at class scope, we'll just warn
and then ignore them.
- For __if_exists/__if_not_exists in statements, we'll treat the
inner statement as a compound statement, which we only instantiate
in templates where the dependent name (after instantiation)
exists. This behavior is different from VC++, but it's as close as
we can get without encroaching ridiculousness.

The latter part (dependent statements) is not yet implemented.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142864 91177308-0d34-0410-b5e6-96231b3b80d8
s-if-exists.cpp
95e5510ee07c465abdcc458fabfd93cf09d90125 21-Oct-2011 Douglas Gregor <dgregor@apple.com> When performing name lookup for the previous declaration of a field,
be sure to consider all of the possible lookup results. We were
assert()'ing (but behaving correctly) for unresolved values. Fixes
PR11134 / <rdar://problem/10290422>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142652 91177308-0d34-0410-b5e6-96231b3b80d8
lass-template-decl.cpp
ember-access-ambig.cpp
8e0c118cb6c22c448ce502f3e00d01630192f095 20-Oct-2011 Douglas Gregor <dgregor@apple.com> Diagnose class template (partial) specializations that occur in the
*wrong* class scope. This is one of the problems behind
<rdar://problem/9676205>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142588 91177308-0d34-0410-b5e6-96231b3b80d8
lass-template-spec.cpp
ba4ee9a9b6e4cffc12bb6b395a58b89c189bb07e 20-Oct-2011 Douglas Gregor <dgregor@apple.com> When we parse something that looks like a templated friend tag but
actually just has an extraneous 'template<>' header, strip off the
'template<>' header and treat it as a normal friend tag. Fixes PR10660
/ <rdar://problem/9958322>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142587 91177308-0d34-0410-b5e6-96231b3b80d8
riend-template.cpp
5f31f0893d75203c326ddcd9808099bbfe34aec0 18-Oct-2011 David Blaikie <dblaikie@gmail.com> Switch to the C++11 warning flags in tests.
Patch by Ahmed Charles!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142340 91177308-0d34-0410-b5e6-96231b3b80d8
emp_explicit.cpp
4e8ea0b2e163aa9681e2f14ad75ab4990a69d39b 18-Oct-2011 Douglas Gregor <dgregor@apple.com> When transforming the arguments for a C++ "new" expression, make sure
to drop the implicitly-generated value initialization expression used
for initializing scalars. Fixes <rdar://problem/10283928>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142330 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-1.cpp
3e2e91e934ecf083a7c0835b58d9627ca2faddc9 18-Oct-2011 Richard Smith <richard-llvm@metafoo.co.uk> Refactor the checking for explicit template instantiations being performed in
the right namespace in C++11 mode. Teach the code to prefer the 'must be in
precisely this namespace' diagnostic whenever that's true, and fix a defect
which resulted in the -Wc++11-compat warning in C++98 mode sometimes being
omitted.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142329 91177308-0d34-0410-b5e6-96231b3b80d8
emp_explicit.cpp
emp_explicit_cxx0x.cpp
2060650f2743650a815ce3daa414352911d408fd 14-Oct-2011 Douglas Gregor <dgregor@apple.com> When declaring an out-of-line template, attempt to rebuild any types
within the template parameter list that may have changed now that we
know the current instantiation. Fixes <rdar://problem/10194295>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141954 91177308-0d34-0410-b5e6-96231b3b80d8
urrent-instantiation.cpp
762bb9d0ad20320b9f97a841dce57ba5e8e48b07 14-Oct-2011 Richard Smith <richard-llvm@metafoo.co.uk> Update all tests other than Driver/std.cpp to use -std=c++11 rather than
-std=c++0x. Patch by Ahmed Charles!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141900 91177308-0d34-0410-b5e6-96231b3b80d8
lias-church-numerals.cpp
lias-nested-nontag.cpp
lias-template-template-param.cpp
lias-templates.cpp
anonical-expr-type-0x.cpp
efault-arguments-cxx0x.cpp
elegating-constructors.cpp
ependent-names.cpp
nstantiate-array.cpp
nstantiate-expr-basic.cpp
nstantiate-try-catch.cpp
esolve-single-template-id.cpp
emp_explicit_cxx0x.cpp
nresolved-construct.cpp
5fad9b8362c62e230f6603d86ec7d1747e74c737 12-Oct-2011 Douglas Gregor <dgregor@apple.com> When we determine that a function template specialization produced as
part of template argument deduction is ill-formed, we mark it as
invalid and treat it as a deduction failure. If we happen to find that
specialization again, treat it as a deduction failure rather than
silently building a call to the declaration.

Fixes PR11117, a marvelous bug where deduction failed after creating
an invalid specialization, causing overload resolution to pick a
different candidate. Then we performed a similar overload resolution
later, and happily picked the invalid specialization to
call... resulting in a silent link failure.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141809 91177308-0d34-0410-b5e6-96231b3b80d8
perator-template.cpp
emp_arg_nontype.cpp
b3df1386680b3830d2f4d300d4d7eaba134135fc 12-Oct-2011 Douglas Gregor <dgregor@apple.com> Switch diagnostic text from "C++0x" over to "C++11".

We'd also like for "C++11" or "c++11" to be used for the warning
groups, but without removing the old warning flags. Patches welcome;
I've run out of time to work on this today.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141801 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-function-2.cpp
nstantiate-member-class.cpp
emp_arg_nontype.cpp
6dbba4fc128e2e2f5b26be996392bd32c0707f13 12-Oct-2011 John McCall <rjmccall@apple.com> Catch placeholder types in DefaultLvalueConversion
and DefaultFunctionArrayLvalueConversion. To prevent
significant regression for should-this-be-a-call fixits,
and to repair some such regression from the introduction of
bound member placeholders, make those placeholder checks
try to build calls appropriately. Harden the build-a-call
logic while we're at it.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141738 91177308-0d34-0410-b5e6-96231b3b80d8
esolve-single-template-id.cpp
6c73a2975ba9112787380abd878876336957b3f6 10-Oct-2011 Douglas Gregor <dgregor@apple.com> For the various CF and NS attributes, don't complain if the parameter
or return types are dependent. Fixes PR9049.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141518 91177308-0d34-0410-b5e6-96231b3b80d8
ttributes.cpp
947be1941e9a1d4233116f51a45799d3904d4231 30-Sep-2011 Richard Smith <richard-llvm@metafoo.co.uk> Mark the ExtWarn for in-class initialization of static const float members as a GNU extension. Don't extend the scope of this extension to all literal types in C++0x mode.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140820 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-static-var.cpp
c6d990a767150b02337de1136fdb55ccf349f4d1 29-Sep-2011 Richard Smith <richard-llvm@metafoo.co.uk> constexpr: semantic checking for constexpr variables.

We had an extension which allowed const static class members of floating-point type to have in-class initializers, 'as a C++0x extension'. However, C++0x does not allow this. The extension has been kept, and extended to all literal types in C++0x mode (with a fixit to add the 'constexpr' specifier).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140801 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-static-var.cpp
480b53cfff18c40d10fcb09b0185a9b75dfd491e 26-Sep-2011 Douglas Gregor <dgregor@apple.com> Diagnose attempts to use 'using typename' with a non-identifier name,
from Stepan Dyatkovskiy. Fixes PR10925.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140528 91177308-0d34-0410-b5e6-96231b3b80d8
ypename-specifier.cpp
d836c0d379403a173ae1ede56fcad034d04a1e34 23-Sep-2011 Douglas Gregor <dgregor@apple.com> Don't finalize checking of base and member initializers for a
constructor template. Fixes PR10457.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140350 91177308-0d34-0410-b5e6-96231b3b80d8
elegating-constructors.cpp
f250365ce65412d7d4e331fccf042b6e974c2f14 21-Sep-2011 Douglas Gregor <dgregor@apple.com> Diagnose attempts to write a templated data member, from Stepan
Dyatkovskiy! Fixes PR10896.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140250 91177308-0d34-0410-b5e6-96231b3b80d8
ested-template.cpp
f45b357c0d0df99e160a6320e279ef788dd91ba6 14-Sep-2011 Eli Friedman <eli.friedman@gmail.com> PR10864: make sure we correctly delay type-checking for inline asm tied operands with dependent type. Patch by Likai Liu.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139716 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-1.cpp
bbcb7ea8a062a8f1d5cb504e4518a5d4fbab873a 09-Sep-2011 Douglas Gregor <dgregor@apple.com> When type-checking a call to an overloaded, builtin atomic operation,
construct a new DeclRefExpr rather than re-using the existing
DeclRefExpr. Patch by Likai Liu, fixes PR8345.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139373 91177308-0d34-0410-b5e6-96231b3b80d8
tomics.cpp
0f74d1e441fdf2229118b7ca5c88db29d5e8f44f 07-Sep-2011 Francois Pichet <pichet2000@gmail.com> In Microsoft mode, if we are inside a template class member function and we can't resolve a function call then create a type-dependent CallExpr even if the function has no type dependent arguments. The goal is to postpone name lookup to instantiation time to be able to search into type dependent base classes.

With this patch in, clang will generate only 37 errors (down from 212) when parsing a typical MFC source file.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139210 91177308-0d34-0410-b5e6-96231b3b80d8
s-lookup-template-base-classes.cpp
7b2f51c758a14205f4c4215d7dc04a4cf3947b8a 26-Aug-2011 Eli Friedman <eli.friedman@gmail.com> Don't assert on taking the address of a non-type template parameter. Fixes PR10766.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138648 91177308-0d34-0410-b5e6-96231b3b80d8
emp_arg_nontype.cpp
3a51d418b267c2b302f1f6a10273049c6ce95e2b 26-Aug-2011 Matt Beaumont-Gay <matthewbg@google.com> Fix a crash-on-invalid.

Much to everyone's surprise, the default constructor for TypeResult produces
an instance with Invalid == false. This seems like a decision we may want to
revisit.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138601 91177308-0d34-0410-b5e6-96231b3b80d8
issing-class-keyword-crash.cpp
9b10683a3f222d8dc6e139073ca96b97b439747b 17-Aug-2011 Chandler Carruth <chandlerc@gmail.com> Whitelist operator== and operator!= as valid for unused value warnings,
even when overloaded and user-defined. These operators are both more
valuable to warn on (due to likely typos) and extremely unlikely to be
reasonable for use to trigger side-effects.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137823 91177308-0d34-0410-b5e6-96231b3b80d8
verload-uneval.cpp
ec8058f64bbcd79bd47748f4cf8628123dd3bae6 17-Aug-2011 Chandler Carruth <chandlerc@gmail.com> Treating the unused equality comparisons as something other than part of
-Wunused was a mistake. It resulted in duplicate warnings and lots of
other hacks. Instead, this should be a special sub-category to
-Wunused-value, much like -Wunused-result is.

Moved to -Wunused-comparison, moved the implementation to piggy back on
the -Wunused-value implementation instead of rolling its own, different
mechanism for catching all of the "interesting" statements.

I like the unused-value mechanism for this better, but its currently
missing several top-level statements. For now, I've FIXME-ed out those
test cases. I'll enhance the generic infrastructure to catch these
statements in a subsequent patch.

This patch also removes the cast-to-void fixit hint. This hint isn't
available on any of the other -Wunused-value diagnostics, and if we want
it to be, we should add it generically rather than in one specific case.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137822 91177308-0d34-0410-b5e6-96231b3b80d8
esolve-single-template-id.cpp
2fd9a474877d476400df06e8cbce7e972b342b5a 15-Aug-2011 Francois Pichet <pichet2000@gmail.com> fix typo in test.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137592 91177308-0d34-0410-b5e6-96231b3b80d8
s-function-specialization-class-scope.cpp
af0f4d0b2e38c810effc8b024ad2fb6604eec5d3 14-Aug-2011 Francois Pichet <pichet2000@gmail.com> Implement function template specialization at class scope extension in Microsoft mode. A new AST node is introduced: ClassScopeFunctionSpecialization. This node holds a FunctionDecl that is not yet specialized; then during the class template instantiation the ClassScopeFunctionSpecialization will spawn the actual function specialization.

Example:
template <class T>
class A {
public:
template <class U> void f(U p) { }
template <> void f(int p) { } // <== class scope specialization
};

This extension is necessary to parse MSVC standard C++ headers, MFC and ATL code.
BTW, with this feature in, clang can parse (-fsyntax-only) all the MSVC 2010 standard header files without any error.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137573 91177308-0d34-0410-b5e6-96231b3b80d8
s-function-specialization-class-scope.cpp
6b63f551b183e14fab6ac51d6e5199c90b699035 09-Aug-2011 Douglas Gregor <dgregor@apple.com> Make sure to canonicalize the argument type of a non-type template
argument of enumeration type when checking template arguments. Fixes PR10579.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137101 91177308-0d34-0410-b5e6-96231b3b80d8
emp_arg_nontype.cpp
dfb6ae1d8d114772bd91b7079c7e4bf4b517e63c 27-Jul-2011 Francois Pichet <pichet2000@gmail.com> In Microsoft mode, if we are within a templated function and we can't resolve Identifier during BuildCXXNestedNameSpecifier, then extend the SS with Identifier. This will have the effect of resolving Identifier during template instantiation. The goal is to be able to resolve a function call whose nested-name-specifier is located inside a dependent base class.

class C {
public:
static void foo2() { }
};

template <class T> class A {
public:
typedef C D;
};

template <class T> class B : public A<T> {
public:
void foo() { D::foo2(); }
};

Note that this won't work if the NestedNameSpecifier refers to a type.
This fixes 1 error when parsing the MSVC 2010 standard headers file with clang.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136203 91177308-0d34-0410-b5e6-96231b3b80d8
ookup-dependent-bases.cpp
2ad63cf7146268a336b5a931f626adaa8a5150f0 26-Jul-2011 Douglas Gregor <dgregor@apple.com> When we decide not to rebuild an instantiated C++ 'new' expression
that allocates an array of objects with a non-trivial destructor, be
sure to mark the destructor is "used". Fixes PR10480 /
<rdar://problem/9834317>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136081 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-4.cpp
0ff6f8f038f32d85c32fd984673cea51ef737b22 20-Jul-2011 Richard Smith <richard-llvm@metafoo.co.uk> Replace r134583's fix for PR10290 with one which also works for non-value-dependent cases.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135543 91177308-0d34-0410-b5e6-96231b3b80d8
ember-inclass-init-value-dependent.cpp
4e9272de54094da012d49990acaf06553369d6ec 15-Jul-2011 John McCall <rjmccall@apple.com> Restore the C-style cast hack for enum template arguments,
which is required given the current setup for template
argument deduction substitution validation, and add a test
case to make sure we don't break it in the future.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135262 91177308-0d34-0410-b5e6-96231b3b80d8
eduction.cpp
cf6b0a20c697ba8daf2dff3a4cce2a028b33cb48 14-Jul-2011 Richard Smith <richard-llvm@metafoo.co.uk> PR10359: Template declarations which define classes are not permitted to also contain declarators. Previously we would accept code like this:

template<typename T> struct S { } f() { return 0; }

This case now produces a missing ';' diagnostic, since that seems like a much more likely error than an attempt to declare a function or variable in addition to the class template.

Treat this


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135195 91177308-0d34-0410-b5e6-96231b3b80d8
lass-template-decl.cpp
032c86921177031ecbb46c398b3e710758ba915e 08-Jul-2011 Douglas Gregor <dgregor@apple.com> Teach CXXUnresolvedConstructExpr when it should be an
lvalue/xvalue/rvalue, rather than just (incorrectly) assuming it's an
lvalue. Fixes PR10285 / <rdar://problem/9743926>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134700 91177308-0d34-0410-b5e6-96231b3b80d8
nresolved-construct.cpp
e4f22adc862ca3e689c5cefa06dc52c480236805 07-Jul-2011 Nick Lewycky <nicholas@mxc.ca> In an in-class initialization, defer checks for value-dependent initialization
expressions.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134583 91177308-0d34-0410-b5e6-96231b3b80d8
ember-inclass-init-value-dependent.cpp
c41b878b24bf9619d5351b05d7088221dfbe9447 06-Jul-2011 Douglas Gregor <dgregor@apple.com> Don't try to type-check a copy construction of an exception
declaration with dependent type. Fixes PR10232 /
<rdar://problem/9700653>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134515 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-try-catch.cpp
5cbe101b502e06d16bc77df45a27ce8bc13f33c8 05-Jul-2011 Douglas Gregor <dgregor@apple.com> Look through parenthesized declarators when determining whether an
instantiated function template was written with a prototype or via
some kind of typedef. Fixes PR10273 / <rdar://problem/9723679>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134426 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-function-2.cpp
c89edf5aaa08683f4afcf61a7a1d183c08b76498 01-Jul-2011 Richard Smith <richard-llvm@metafoo.co.uk> Fix AST representations of alias-declarations which define tag types. Inside classes, the tag types need to have an associated access specifier, and inside function definitions, they need to be included in the declarations of the DeclStmt. These issues manifested as assertions during template instantiation, and also in a WIP constexpr patch.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134250 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-function-2.cpp
nstantiate-member-class.cpp
2ced044c34311d8e6301f2b4566f4b612bc8b628 27-Jun-2011 Richard Smith <richard-llvm@metafoo.co.uk> Fix PR10187: when diagnosing a two-phase-lookup-related failure, don't assert that any names we find are valid candidates for the call.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133898 91177308-0d34-0410-b5e6-96231b3b80d8
ependent-names.cpp
1d441ee69aaf3b3afa4521d05df934c5c7ea5f62 22-Jun-2011 Douglas Gregor <dgregor@apple.com> When instantiating a function template declaration that was expressed
via a typedef of a function, make sure to synthesize parameter
declarations. Fixes PR9654 / <rdar://problem/9257497>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133628 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-function-2.cpp
4ac01401b1ec602a1f58c217544d3dcb5fcbd7f1 15-Jun-2011 Douglas Gregor <dgregor@apple.com> Eliminate a 'default' case in template argument deduction, where we
were just punting on template argument deduction for a number of type
nodes. Most of them, obviously, didn't matter.

As a consequence of this, make extended vector types (via the
ext_vector_type attribute) actually work properly for several
important cases:
- If the attribute appears in a type-id (i.e, not attached to a
typedef), actually build a proper vector type
- Build ExtVectorType whenever the size is constant; previously, we
were building DependentSizedExtVectorType when the size was constant
but the type was dependent, which makes no sense at all.
- Teach template argument deduction to handle
ExtVectorType/DependentSizedExtVectorType.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133060 91177308-0d34-0410-b5e6-96231b3b80d8
xt-vector-type.cpp
383041d31ca14cdf87865ccac6e6f9821d40f61a 15-Jun-2011 Douglas Gregor <dgregor@apple.com> When performing substitution of default template template parameters
before the template parameters have acquired a proper context (e.g.,
because the enclosing context has yet to be built), provide empty
parameter lists for all outer template parameter scopes to inhibit any
substitution for those template parameters. Fixes PR9643 /
<rdar://problem/9251019>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133055 91177308-0d34-0410-b5e6-96231b3b80d8
efault-arguments.cpp
2a00b8347bdf0064cc106295a070c00669ded9a9 14-Jun-2011 Jay Foad <jay.foad@gmail.com> Hyphenate "argument-dependent".

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132989 91177308-0d34-0410-b5e6-96231b3b80d8
ependent-names-no-std.cpp
ependent-names.cpp
nstantiate-call.cpp
0adde128d96a73864569516e684faa570e3c0333 14-Jun-2011 David Majnemer <david.majnemer@gmail.com> Properly diagnose using abstract and incomplete types in va_arg

- Move a test from test/SemaTemplate/instantiate-expr-3.cpp, it did not belong there
- Incomplete and abstract types are considered hard errors


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132979 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-3.cpp
db11b0187bafe77263036eafc3977fa5da3bcf1a 13-Jun-2011 David Majnemer <david.majnemer@gmail.com> Give a diagnostic when using non-POD types in a va_arg


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132905 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-3.cpp
45cad4adb802b818211b1c697f550d3bf1e98e51 08-Jun-2011 Chandler Carruth <chandlerc@gmail.com> Fix a regression in the two-phase lookup diagnostics that switching the
namespace set algorithm (re-)introduced. We may not have seen the 'std'
namespace, but we should still suggested associated namespaces. Easy
fix, but a bit annoying to test.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132744 91177308-0d34-0410-b5e6-96231b3b80d8
ependent-names-no-std.cpp
f50e88a793dd5bc7073c717fec78912e3234e95a 06-Jun-2011 Richard Smith <richard-llvm@metafoo.co.uk> Fix PR10053: Improve diagnostics and error recovery for code which some compilers incorrectly accept due to a lack of proper support for two-phase name lookup.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132672 91177308-0d34-0410-b5e6-96231b3b80d8
ependent-names.cpp
nstantiate-call.cpp
36f255c324d37dd8e0e5ab2e026814e8396a05aa 03-Jun-2011 Douglas Gregor <dgregor@apple.com> Improve the instantiation of static data members in
Sema::RequireCompleteExprType() a bit more, setting the point of
instantiation if needed, and skipping explicit specializations entirely.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132547 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-init.cpp
f15748a28c8443eef2924ef83689c358c661e9c5 03-Jun-2011 Douglas Gregor <dgregor@apple.com> When performing template argument deduction given a function argument
of incomplete array type, attempt to complete the array type. This was
made much easier by Chandler's addition of RequireCompleteExprType(),
which I've tweaked (slightly) to improve the consistency of the
DeclRefExpr. Fixes PR7985.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132530 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-init.cpp
e4d645cbe073042d8abc1a4eb600af4ff7a8dffb 27-May-2011 Chandler Carruth <chandlerc@gmail.com> Enhance Clang to start instantiating static data member definitions
within class templates when they are necessary to complete the type of
the member. The canonical example is code like:

template <typename T> struct S {
static const int arr[];
static const int x;
static int f();
};

template <typename T> const int S<T>::arr[] = { 1, 2, 3 };
template <typename T> const int S<T>::x = sizeof(arr) / sizeof(arr[0]);
template <typename T> int S<T>::f() { return x; }

int x = S<int>::f();

We need to instantiate S<T>::arr's definition to pick up its initializer
and complete the array type. This involves new code to specially handle
completing the type of an expression where the type alone is
insufficient. It also requires *updating* the expression with the newly
completed type. Fortunately, all the other infrastructure is already in
Clang to do the instantiation, do the completion, and prune out the
unused bits of code that result from this instantiation.

This addresses the initial bug in PR10001, and will be a step to
fleshing out other cases where we need to work harder to complete an
expression's type. Who knew we still had missing C++03 "features"?

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132172 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-init.cpp
9625e44c0252485277a340746ed8ac950686156f 22-May-2011 Douglas Gregor <dgregor@apple.com> It's considered poor form to create references to the overloaded
function type. Educate template argument deduction thusly, fixing
PR9974 / <rdar://problem/9479155>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131811 91177308-0d34-0410-b5e6-96231b3b80d8
eduction-crash.cpp
1804174e1591bf59118f317775b48edd0382c3f0 14-May-2011 Richard Smith <richard-llvm@metafoo.co.uk> PR9908: Fix the broken fix for PR9902 to get the template argument lists in the right order.
Also, don't reject alias templates in all ElaboratedTypes: some ElaboratedTypes do not correspond to elaborated-type-specifiers.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131342 91177308-0d34-0410-b5e6-96231b3b80d8
lias-templates.cpp
c056c1792eac0717640f1f48b3739cc9a98ee413 09-May-2011 Douglas Gregor <dgregor@apple.com> When determining whether we need to instantiate a function type,
also consider whether any of the parameter types (as written, prior to
decay) are dependent. Fixes PR9880 and <rdar://problem/9408413>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131099 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-function-1.cpp
00c93a10c3504b77dad4467766bfca3248defbfb 07-May-2011 Richard Trieu <rtrieu@google.com> Patch for PR 7409 - only error on definition of invalid typedefs. Suppress errors for additional uses of this invalid typedef.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131043 91177308-0d34-0410-b5e6-96231b3b80d8
ypename-specifier.cpp
3e4c6c4c79a03f5cb0c4671d7c282d623c6dc35e 05-May-2011 Richard Smith <richard-llvm@metafoo.co.uk> Implement support for C++0x alias templates.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130953 91177308-0d34-0410-b5e6-96231b3b80d8
lias-church-numerals.cpp
lias-nested-nontag.cpp
lias-template-template-param.cpp
c7469374548b06e50aa8b4d41bf1a35338e9b358 04-May-2011 Douglas Gregor <dgregor@apple.com> When converting an integral template argument value to a non-type
template parameter of type 'bool', force the value to be zero or
one. Fixes <rdar://problem/9169404>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130873 91177308-0d34-0410-b5e6-96231b3b80d8
artial-spec-instantiate.cpp
eccce7e246a17e12a2afd6eabb9ac7c8d582db4e 03-May-2011 Argyrios Kyrtzidis <akyrtzi@gmail.com> Fix a double free when parsing malformed code. Fixes rdar://9173693.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130775 91177308-0d34-0410-b5e6-96231b3b80d8
dar9173693.cpp
0f4be74ff0273e505d383f89174ef539828424ed 03-May-2011 Chandler Carruth <chandlerc@gmail.com> When parsing a template friend declaration we dropped the template
parameters on the floor in certain cases:
class X {
template <typename T> friend typename A<T>::Foo;
};

This was parsed as a *non* template friend declaration some how, and
received an ExtWarn. Fixing the parser to actually provide the template
parameters to the freestanding declaration parse triggers the code which
specifically looks for such constructs and hard errors on them.

Along the way, this prevents us from trying to instantiate constructs
like the above inside of a outer template. This is important as loosing
the template parameters means we don't have a well formed declaration
and template instantiation will be unable to rebuild the AST. That fixes
a crash in the GCC test suite.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130772 91177308-0d34-0410-b5e6-96231b3b80d8
riend-template.cpp
769d0cc72b1831785596d0e76f327bdb887823be 30-Apr-2011 Douglas Gregor <dgregor@apple.com> When comparing parameters of reference-to-qualified type during
partial ordering of function templates, use a simple superset
relationship rather than the convertibility-implying
isMoreQualifiedThan/compatibilyIncludes relationship. Fixes partial
ordering between references and address-space-qualified references.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130612 91177308-0d34-0410-b5e6-96231b3b80d8
ddress-spaces.cpp
61d0b6baf47cf411f6c0f6ddb4acffcfeec724f1 28-Apr-2011 Douglas Gregor <dgregor@apple.com> More cleanup of template argument deduction and its handling of
non-CVR qualifiers. We can now properly match address-space--qualified
references during template argument deduction.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130365 91177308-0d34-0410-b5e6-96231b3b80d8
ddress-spaces.cpp
a459cc26f6c895ae48742a36203f753cea8b3e91 28-Apr-2011 Douglas Gregor <dgregor@apple.com> Clean up the handling of non-CVR qualifiers in template argument
deduction. The good news is that address spaces are a lot less broken
in this regard than I'd expected.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130346 91177308-0d34-0410-b5e6-96231b3b80d8
ddress-spaces.cpp
3b887354b1b667c97d070ddc67b5354353c4c07b 27-Apr-2011 Douglas Gregor <dgregor@apple.com> Extend Sema::ClassifyName() to support C++, ironing out a few issues
in the classification of template names and using declarations. We now
properly typo-correct the leading identifiers in statements to types,
templates, values, etc. As an added bonus, this reduces the number of
lookups required for disambiguation.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130288 91177308-0d34-0410-b5e6-96231b3b80d8
eduction-crash.cpp
d941fa4ff0d0d64b5a541dbd4f99693bff7f6e8d 24-Apr-2011 Sebastian Redl <sebastian.redl@getdesigned.at> Make the invalid declarator recovery when parsing members work the same as when parsing global decls. It's still rather broken (skipping much too far when the declarator belongs to a function definition), but at least not so broken as to mismatch braces. Tested by the removal of the fixme in the template test case.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130101 91177308-0d34-0410-b5e6-96231b3b80d8
eduction-crash.cpp
xplicit-instantiation.cpp
d4c5f84bbed2ecb5ddd0f0e8316c553b2084772a 15-Apr-2011 Douglas Gregor <dgregor@apple.com> Implement appropriate semantics for C++ casting and conversion when
dealing with address-space- and GC-qualified pointers. Previously,
these qualifiers were being treated just like cvr-qualifiers (in some
cases) or were completely ignored, leading to uneven behavior. For
example, const_cast would allow conversion between pointers to
different address spaces.

The new semantics are fairly simple: reinterpret_cast can be used to
explicitly cast between pointers to different address spaces
(including adding/removing addresss spaces), while
static_cast/dynamic_cast/const_cast do not tolerate any changes in the
address space. C-style casts can add/remove/change address spaces
through the reinterpret_cast mechanism. Other non-CVR qualifiers
(e.g., Objective-C GC qualifiers) work similarly.

As part of this change, I tweaked the "casts away constness"
diagnostic to use the term "casts away qualifiers". The term
"constness" actually comes from the C++ standard, despite the fact
that removing "volatile" also falls under that category. In Clang, we
also have restrict, address spaces, ObjC GC attributes, etc., so the
more general "qualifiers" is clearer.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129583 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-cast.cpp
ea698b3f6cad84f7f583282dce3e03e24fe80e98 14-Apr-2011 Richard Smith <richard-llvm@metafoo.co.uk> Detect when the string "<::" is found in code after a cast or template name and is interpreted as "[:" because of the digraph "<:". When found, give an error with a fix-it to add whitespace between the "<" and "::".

Patch by Richard Trieu! Plus a small tweak from me to deal with one of the tokens coming from a macro.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129540 91177308-0d34-0410-b5e6-96231b3b80d8
emp_arg_template.cpp
fb8721ce4c6fef3739b1cbd1e38e3f1949462033 10-Apr-2011 John McCall <rjmccall@apple.com> Simplify calling CheckPlaceholderExpr, converge on it in a few places,
and move a vector-splat check to follow l-value conversion.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129254 91177308-0d34-0410-b5e6-96231b3b80d8
esolve-single-template-id.cpp
1de4d4e8cb2e9c88809fea8092bc6e835a5473d2 07-Apr-2011 John McCall <rjmccall@apple.com> Basic, untested implementation for an "unknown any" type requested by LLDB.
The idea is that you can create a VarDecl with an unknown type, or a
FunctionDecl with an unknown return type, and it will still be valid to
access that object as long as you explicitly cast it at every use. I'm
still going back and forth about how I want to test this effectively, but
I wanted to go ahead and provide a skeletal implementation for the LLDB
folks' benefit and because it also improves some diagnostic goodness for
placeholder expressions.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129065 91177308-0d34-0410-b5e6-96231b3b80d8
esolve-single-template-id.cpp
db2eae639d3b7ed61ceb56890b73168517ef57f1 16-Mar-2011 Douglas Gregor <dgregor@apple.com> Clean up our handling of template-ids that resolve down to a single
overload, so that we actually do the resolution for full expressions
and emit more consistent, useful diagnostics. Also fixes an IRGen
crasher, where Sema wouldn't diagnose a resolvable bound member
function template-id used in a full-expression (<rdar://problem/9108698>).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127747 91177308-0d34-0410-b5e6-96231b3b80d8
esolve-single-template-id.cpp
esolve-single-template-id.patch
fadb53b351977ca7f99a9a613596cba6531979a3 12-Mar-2011 Douglas Gregor <dgregor@apple.com> Fixes for some more expressions containing function templateids that
should be resolvable, from Faisal Vali!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127521 91177308-0d34-0410-b5e6-96231b3b80d8
esolve-single-template-id.patch
d078bd2e02bd4e6661fe06645d98280a2a5a3e8c 12-Mar-2011 Douglas Gregor <dgregor@apple.com> Don't ask if a depenendent CXXRecordDecl has any dependent bases
unless we already know that it has a definition. Fixes
PR9449/<rdar://problem/9115785>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127512 91177308-0d34-0410-b5e6-96231b3b80d8
ested-name-spec-template.cpp
0a0367a479e2ad204a97f87ed72f18209169b775 07-Mar-2011 Douglas Gregor <dgregor@apple.com> When transforming a dependent template specialization type, make sure
to set the source-location information for the template arguments to
the *transformed* source-location information, not the original
source-location information. Fixes <rdar://problem/8986308> (a libc++
SFINAE issue) and the Boost.Polygon failure.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127150 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-member-template.cpp
eff1dbec93999bfc5406eb861efd8add9de23633 06-Mar-2011 Douglas Gregor <dgregor@apple.com> We may fail to map a declaration in a template to its instantiated
declaration because of interesting ordering dependencies while
instantiating a class template or member class thereof. Complain,
rather than asserting (+Asserts) or silently rejecting the code
(-Asserts).

Fixes the crash-on-invalid in PR8965.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127129 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-member-class.cpp
5875038f5c333b8bd013f62950281618d08e36a8 05-Mar-2011 Douglas Gregor <dgregor@apple.com> When substituting in for a template name, do not produce a qualified
template name as the result of substitution. The qualifier is handled
separately by the tree transformer, so we would end up in an
inconsistent state.

This is actually the last bit of PR9016, and possibly also fixes
PR8965. It takes Boost.Icl from "epic fail" down to a single failure.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127108 91177308-0d34-0410-b5e6-96231b3b80d8
ssue150.cpp
c494f77363f057dd8619fec4e885c4f80e3d1b66 05-Mar-2011 Douglas Gregor <dgregor@apple.com> When determining template instantiation arguments within a function
template (not a specialization!), use the "injected" function template
arguments, which correspond to the template parameters of the function
template. This is required when substituting into the default template
parameters of template template parameters within a function template.

Fixes PR9016.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127092 91177308-0d34-0410-b5e6-96231b3b80d8
ssue150.cpp
0b4bcb639a9aab9c466a9e6d6e61b3bd1bb36d68 05-Mar-2011 Douglas Gregor <dgregor@apple.com> When transforming a substituted template type parameter, try to
transform the type that replaces the template type parameter. In the
vast majority of cases, there's nothing to do, because most template
type parameters are replaced with something non-dependent that doesn't
need further transformation. However, when we're dealing with the
default template arguments of template template parameters, we might
end up replacing a template parameter (of the template template
parameter) with a template parameter of the enclosing template.

This addresses part of PR9016, but not within function
templates. That's a separate issue.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127091 91177308-0d34-0410-b5e6-96231b3b80d8
ssue150.cpp
cb710a4df50b79659399f0722ea29e90251ea834 04-Mar-2011 Douglas Gregor <dgregor@apple.com> Diagnose destructor templates. Fixes PR7904.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127042 91177308-0d34-0410-b5e6-96231b3b80d8
estructor-template.cpp
6cd9d4aa13c2145c8b4398453974515b734bfe42 04-Mar-2011 Douglas Gregor <dgregor@apple.com> Teach Sema::ActOnCXXNestedNameSpecifier and Sema::CheckTemplateIdType
to cope with non-type templates by providing appropriate
errors. Previously, we would either assert, crash, or silently build a
dependent type when we shouldn't. Fixes PR9226.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127037 91177308-0d34-0410-b5e6-96231b3b80d8
ested-name-spec-template.cpp
087eb5a2d3c7988eb7c440cd86cc7479e57d5dc0 04-Mar-2011 Douglas Gregor <dgregor@apple.com> When constructing source-location information for a
DependentTemplateSpecializationType during tree transformation, retain
the NestedNameSpecifierLoc as it was used to translate the template
name, rather than reconstructing it from the template name.

Fixes PR9401.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127015 91177308-0d34-0410-b5e6-96231b3b80d8
ependent-template-recover.cpp
9a299e0575ce235f491014627c7267e2d2cd73de 04-Mar-2011 Douglas Gregor <dgregor@apple.com> Make sure to put template parameters into their owning template's
DeclContext once we've created it. This mirrors what we do for
function parameters, where the parameters start out with
translation-unit context and then are adopted by the appropriate
DeclContext when it is created. Also give template parameters public
access and make sure that they don't show up for the purposes of name
lookup.

Fixes PR9400, a regression introduced by r126920, which implemented
substitution of default template arguments provided in template
template parameters (C++ core issue 150).

How on earth could the DeclContext of a template parameter affect the
handling of default template arguments?

I'm so glad you asked! The link is
Sema::getTemplateInstantiationArgs(), which determines the outer
template argument lists that correspond to a given declaration. When
we're instantiating a default template argument for a template
template parameter within the body of a template definition (not it's
instantiation, per core issue 150), we weren't getting any outer
template arguments because the context of the template template
parameter was the translation unit. Now that the context of the
template template parameter is its owning template, we get the
template arguments from the injected-class-name of the owning
template, so substitution works as it should.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127004 91177308-0d34-0410-b5e6-96231b3b80d8
ssue150.cpp
67714230a191bc3c01f33378f34f34ef377991a6 03-Mar-2011 Douglas Gregor <dgregor@apple.com> When we use the default template arguments of a template template
parameter, save the instantiated default template arguments along with
the explicitly-specified template argument list. That way, we prefer
the default template template arguments corresponding to the template
template parameter rather than those of its template template argument.

This addresses the likely direction of C++ core issue 150, and fixes
PR9353/<rdar://problem/9069136>, bringing us closer to the behavior of
EDG and GCC.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126920 91177308-0d34-0410-b5e6-96231b3b80d8
ssue150.cpp
059101f922de6eb765601459925f4c8914420b23 02-Mar-2011 Douglas Gregor <dgregor@apple.com> Push nested-name-specifier source-location information into dependent
template specialization types. This also required some parser tweaks,
since we were losing track of the nested-name-specifier's source
location information in several places in the parser. Other notable
changes this required:

- Sema::ActOnTagTemplateIdType now type-checks and forms the
appropriate type nodes (+ source-location information) for an
elaborated-type-specifier ending in a template-id. Previously, we
used a combination of ActOnTemplateIdType and
ActOnTagTemplateIdType that resulted in an ElaboratedType wrapped
around a DependentTemplateSpecializationType, which duplicated the
keyword ("class", "struct", etc.) and nested-name-specifier
storage.

- Sema::ActOnTemplateIdType now gets a nested-name-specifier, which
it places into the returned type-source location information.

- Sema::ActOnDependentTag now creates types with source-location
information.




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126808 91177308-0d34-0410-b5e6-96231b3b80d8
eduction-crash.cpp
ef24c4b85e354255240bbbc21772098e6c3f6ae8 01-Mar-2011 Douglas Gregor <dgregor@apple.com> When building a type for a typename specifier, check specifically for
a dependent template name rather than (indirectly and incorrectly)
trying to determine whether we can compute a context for the
nested-name-specifier. Fixes a GCC testsuite regression,
<rdar://problem/9068589>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126749 91177308-0d34-0410-b5e6-96231b3b80d8
ypename-specifier-4.cpp
abea951c34876a5374d0e3678c7989b225c5c895 28-Feb-2011 Anders Carlsson <andersca@mac.com> Add -fcxx-exceptions to all tests that use C++ exceptions.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126599 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-4.cpp
nstantiate-function-1.cpp
nstantiate-try-catch.cpp
d9ea180032eda76a46c099a9aab99512447c326d 19-Feb-2011 Douglas Gregor <dgregor@apple.com> The member classes of a current instantiation aren't necessarily a
current instantiation, even though we have a RecordDecl describing
them. Fixes PR9255.

Amusingly, I've had this patch sitting around for a month or two
because it was "obviously" wrong, but hadn't gotten around to writing
a test case to submit the fix :)


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126038 91177308-0d34-0410-b5e6-96231b3b80d8
urrent-instantiation.cpp
e41721e7dfabcc15cb50be9075a4153f1ad648ea 19-Feb-2011 Anders Carlsson <andersca@mac.com> Pass -fexceptions to all tests that use try/catch/throw.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126037 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-4.cpp
nstantiate-function-1.cpp
nstantiate-try-catch.cpp
781701c3d34740c53ad912ad007383ae2951c637 19-Feb-2011 Chandler Carruth <chandlerc@gmail.com> Improve bool and char integral template argument printing in
diagnostics, resolving PR9227.

Patch originally by Mihai Rusu and Stephen Hines with some minimal style
tweaks from me.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125999 91177308-0d34-0410-b5e6-96231b3b80d8
emp_arg_nontype.cpp
f58483268995daef120529687813a6c5340ff09d 18-Feb-2011 Douglas Gregor <dgregor@apple.com> When building a qualified reference to a member of an anonymous struct
or union, place the qualifier on the outermost member reference
expression, which actually contains the entity name.

Fixes PR9188/<rdar://problem/8990184>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125822 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-anonymous-union.cpp
8f5667d06a785719691c1139b961411d7f0aedf5 18-Feb-2011 Douglas Gregor <dgregor@apple.com> When we're creating an expression for an integral template argument of
enumeration type, we were generating an integer literal implicitly
casted to the appropriate enumeration type. However, later checks on
that expression would strip the implicit cast.

This commit tweaks the lame hack, by creating an explicit cast instead
of an implicit cast. The right answer is to introduce a
SubstNonTypeTemplateParmExpr expression that acts like the substituted
result. I'll investigate that soon.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125818 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-non-type-template-parameter.cpp
c6daf0b29d6c48a99cb1ad707973a7e6dfcafd58 17-Feb-2011 Douglas Gregor <dgregor@apple.com> When printing a qualified type, look through a substituted template
parameter type to see what's behind it, so that we don't end up
printing silly things like "float const *" when "const float *" would
make more sense. Also, replace the pile of "isa" tests with a simple
switch enumerating all of the cases, making a few more obvious cases
use prefix qualifiers.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125729 91177308-0d34-0410-b5e6-96231b3b80d8
eduction.cpp
nstantiate-static-var.cpp
79ab2c8104ef5df233d271560ccc734836738e56 14-Feb-2011 John McCall <rjmccall@apple.com> Provide overload diagnostics when explicit casts involving class types fail.
PR8626.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125506 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-cast.cpp
2f9f89c6938a788a904c3be3ae7a64f4297c90a6 04-Feb-2011 Douglas Gregor <dgregor@apple.com> Improve our handling of the current instantiation for qualified
id-expression, e.g.,

CurrentClass<T>::member

Previously, if CurrentClass<T> was dependent and not complete, we
would treat it as a dependent-scoped declaration reference expression,
even if CurrentClass<T> referred to the current instantiation.

Fixes PR8966 and improves type checking of templates.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124867 91177308-0d34-0410-b5e6-96231b3b80d8
ependent-names.cpp
46ff3034d14aaa92b530e96480741f3d5d458cb8 04-Feb-2011 Douglas Gregor <dgregor@apple.com> Before checking bitfield initialization, make sure that neither the
bit-field width nor the initializer value are type- or
value-dependent. Fixes PR8712.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124866 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-field.cpp
9f0f3cd94ac992bc6714b49ffe5272521ce12d77 25-Jan-2011 Douglas Gregor <dgregor@apple.com> Add test for PR8629

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124204 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-template-template-parm.cpp
5505c72695161e2fb55391d1453b82b7adbff923 24-Jan-2011 Douglas Gregor <dgregor@apple.com> Disallow function template partial specializations, from Hans
Wennborg! Fixes PR8295.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124135 91177308-0d34-0410-b5e6-96231b3b80d8
unction-template-specialization.cpp
a009b59fc2c550a229b9146aabda8e33fe3a7771 07-Jan-2011 Douglas Gregor <dgregor@apple.com> Factor out the template transformation of a sequence of function
parameters into parameter types, so that substitution of
explicitly-specified function template arguments uses the same
path. This enables the use of explicitly-specified function template
arguments with variadic templates.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122986 91177308-0d34-0410-b5e6-96231b3b80d8
emp_arg_nontype.cpp
b2b5cc0cf908d516a107d373db963f692449a8a8 04-Jan-2011 Chandler Carruth <chandlerc@gmail.com> Enhance the diagnostic for negative array sizes to include the
declaration name of the array when present. This ensures that
a poor-man's C++03 static_assert will include the user error message
often embedded in the name.

Update all the tests to reflect the new wording, and add a test for the
name behavior.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122802 91177308-0d34-0410-b5e6-96231b3b80d8
ttributes.cpp
efault-expr-arguments.cpp
riend-template.cpp
nstantiate-default-assignment-operator.cpp
nstantiate-expr-4.cpp
nstantiate-member-expr.cpp
nstantiate-member-pointers.cpp
d2592a34a059e7cbb2b11dc53649ac4912422909 22-Dec-2010 Argyrios Kyrtzidis <akyrtzi@gmail.com> [analyzer] Refactoring: Drop the 'GR' prefix.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122424 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-member-expr.cpp
cfddf7be7992d386391968db448c3abbdc6e324a 21-Dec-2010 Douglas Gregor <dgregor@apple.com> For member pointer conversions potentially involving derived-to-base
conversions, make sure that the (possibly) derived type is complete
before looking for base classes.

Finishes the fix for PR8801.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122363 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-local-class.cpp
ebb1c56a4b7a944921b564025df53505ff886050 21-Dec-2010 Douglas Gregor <dgregor@apple.com> When searching for the instantiation of a locally-scoped tag
declaration, also look for an instantiation of its previous
declarations. Fixes PR8801.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122361 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-local-class.cpp
b0ee93cf945744569b82b8a07361061f2963264a 21-Dec-2010 Douglas Gregor <dgregor@apple.com> A class template partial specialization cannot be a friend. Fixes PR8649.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122325 91177308-0d34-0410-b5e6-96231b3b80d8
riend-template.cpp
14af91a38c8cf89f0a5e1835d7d8e0fa220e17a9 21-Dec-2010 Douglas Gregor <dgregor@apple.com> Don't try to compute the value of a value-dependent expression when
checking trivial comparisons. Fixes PR8795.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122322 91177308-0d34-0410-b5e6-96231b3b80d8
ependent-expr.cpp
9f6f6a107287bd81aedab8b578216535b0b51d0f 10-Dec-2010 Peter Collingbourne <peter@pcc.me.uk> Do not substitute template types if template has dependent context

We should not substitute template types if the template has a dependent
context because the template argument stack is not yet fully formed.
Instead, defer substitution until the template has a non-dependent
context (i.e. instantiation of an outer template).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@121491 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-template-template-parm.cpp
d95450421ee3b7cebfb18ce1312310d6c703431c 09-Dec-2010 Douglas Gregor <dgregor@apple.com> A typename specifier can end up referring to a unresolved using
declaration that is a value in ill-formed code. Instead of crashing,
treat this as a dependent typename specifier and suggest that the
using add "typename" into the using declaration. Fixes <rdar://problem/8740998>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@121322 91177308-0d34-0410-b5e6-96231b3b80d8
ypename-specifier-4.cpp
01b2e4e3e2fbd60e62539f7e8e8b99575fa8a5b0 06-Dec-2010 John McCall <rjmccall@apple.com> Clarify the logic for when to build an overloaded binop. In particular,
build one when either of the operands calls itself type-dependent;
previously we were building when one of the operand types was dependent,
which is not always the same thing and which can lead to unfortunate
inconsistencies later. Fixes PR8739.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120990 91177308-0d34-0410-b5e6-96231b3b80d8
num-argument.cpp
ember-access-expr.cpp
f6a1648197562e0b133440d612d9af297d0a86cc 04-Dec-2010 John McCall <rjmccall@apple.com> Although we currently have explicit lvalue-to-rvalue conversions, they're
not actually frequently used, because ImpCastExprToType only creates a node
if the types differ. So explicitly create an ICE in the lvalue-to-rvalue
conversion code in DefaultFunctionArrayLvalueConversion() as well as several
other new places, and consistently deal with the consequences throughout the
compiler.

In addition, introduce a new cast kind for loading an ObjCProperty l-value,
and make sure we emit those nodes whenever an ObjCProperty l-value appears
that's not on the LHS of an assignment operator.

This breaks a couple of rewriter tests, which I've x-failed until future
development occurs on the rewriter.

Ted Kremenek kindly contributed the analyzer workarounds in this patch.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120890 91177308-0d34-0410-b5e6-96231b3b80d8
num-argument.cpp
7306ebfacfa51ba5270fd20f162f62d2ed813485 01-Dec-2010 Douglas Gregor <dgregor@apple.com> Not content to implement just "extern" explicit template
instantiations, GCC also supports "inline" and "static" explicit
template instantiations. Parse and warn about such constructs, but
don't implement the semantics of either "inline" or "static". They
don't seem to be widely used.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120599 91177308-0d34-0410-b5e6-96231b3b80d8
xplicit-instantiation.cpp
9b4b9d6d221ab804f5b65fec6c8661be4d5c2b84 30-Nov-2010 John McCall <rjmccall@apple.com> Fix another case of giving the wrong value kind to a dependent cast to
a non-dependent type.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120384 91177308-0d34-0410-b5e6-96231b3b80d8
ependent-expr.cpp
a21e06cb62dbd806073f646e756e89d8e23fc1c3 26-Nov-2010 John McCall <rjmccall@apple.com> For internal consistency's sake, compute the value kind of a dependent cast
based on the known properties of the casted-to type. Fixes a crash on spirit.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120180 91177308-0d34-0410-b5e6-96231b3b80d8
ependent-expr.cpp
7d14d389f0539545715e756629127c1fe5a4773a 13-Nov-2010 Douglas Gregor <dgregor@apple.com> When we're type-checking the result of calling a conversion function
(while computing user conversion sequences), make sure that a result
of class type is a complete class type. Had we gone through
ActOnCallExpr, this would have happened when we built the CallExpr.

Fixes PR8425.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@119005 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-complete.cpp
f56017fd93236bfc34d3e5b5c31b8d40a5d75808 13-Nov-2010 Chandler Carruth <chandlerc@gmail.com> Switch to using %clang_cc1 properly rather than manually passing the -cc1 flag.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118996 91177308-0d34-0410-b5e6-96231b3b80d8
nject-templated-friend-post.cpp
nject-templated-friend.cpp
43fed0de4f5bc189e45562491f83d5193eb8dac0 12-Nov-2010 John McCall <rjmccall@apple.com> Replace one hack with a different hack: strip out the ObjectType
parameters to the Transform*Type functions and instead call out
the specific cases where an object type and the unqualified lookup
results are important. Fixes an assert and failed compile on
a testcase from PR7248.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118887 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-member-expr.cpp
d65587f7a6d38965fa37158d3f57990a7faf3836 10-Nov-2010 Douglas Gregor <dgregor@apple.com> Instantiate class member template partial specialization declarations
in the order they occur within the class template, delaying
out-of-line member template partial specializations until after the
class has been fully instantiated. This fixes a regression introduced
by r118454 (itself a fix for PR8001).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118704 91177308-0d34-0410-b5e6-96231b3b80d8
xplicit-specialization-member.cpp
37574f55cd637340f651330f5cfda69742880d36 09-Nov-2010 Nick Lewycky <nicholas@mxc.ca> Don't lose track of previous-declarations when instantiating a class template.
Fixes PR8001.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118454 91177308-0d34-0410-b5e6-96231b3b80d8
lass-template-decl.cpp
6493cc50b66c2d097b3e22514bbe303048c4a8ff 08-Nov-2010 Douglas Gregor <dgregor@apple.com> 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118418 91177308-0d34-0410-b5e6-96231b3b80d8
onstructor-template.cpp
910f8008fea79120489a53593fe971b0b8a4a740 08-Nov-2010 Douglas Gregor <dgregor@apple.com> 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118385 91177308-0d34-0410-b5e6-96231b3b80d8
ariadic-class-template-1.cpp
ariadic-class-template-2.cpp
ariadic-parse.cpp
ariadic-unsupported.cpp
a43064c7b721a51ab2c0d0ccdc4f84064aa7cecc 06-Nov-2010 Douglas Gregor <dgregor@apple.com> 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>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118313 91177308-0d34-0410-b5e6-96231b3b80d8
nonymous-union.cpp
264bf66d55563dd86a3d7e06738aa427de512d2c 04-Nov-2010 Douglas Gregor <dgregor@apple.com> 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118211 91177308-0d34-0410-b5e6-96231b3b80d8
ypename-specifier-4.cpp
61139c561f1a2c872209e32ff9143487cebf4324 30-Oct-2010 Nick Lewycky <nicholas@mxc.ca> Preserve the template type parameter name when instantiating a templace.
Fixes PR8489.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117776 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-member-template.cpp
dd8c10fbd87f171e361a53c5835800369170123b 22-Oct-2010 Douglas Gregor <dgregor@apple.com> When we perform name lookup for a template, we may end up finding an
ambiguous name where none of the declarations found are actually
templates. In this case, make sure we clear out the ambiguous-path
data when recomputing the lookup result kind. Fixes PR8439.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117112 91177308-0d34-0410-b5e6-96231b3b80d8
ember-access-ambig.cpp
a25c4080a490ea2bab6f54094dd75b19eae83770 19-Oct-2010 John McCall <rjmccall@apple.com> Tag references shouldn't ever get template parameter lists.
Fixes rdar://problem/8568507



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116843 91177308-0d34-0410-b5e6-96231b3b80d8
laborated-type-specifier.cpp
102ff97bc55ba9f925a100671d49e49b3c5f7129 19-Oct-2010 Douglas Gregor <dgregor@apple.com> When marking declarations referenced within an expression (e.g.,
within a default argument), recurse into default arguments. Fixes
PR8401, a regression I introduced in r113700 while refactoring our
handling of "used" declarations in default arguments.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116817 91177308-0d34-0410-b5e6-96231b3b80d8
efault-expr-arguments.cpp
7d520baec9b762633a09d31ee0db12e41fe2758a 13-Oct-2010 Douglas Gregor <dgregor@apple.com> There is no reason for dereferencing a pointer-to-member to require
that the class type into which the pointer points be complete, even
though the standard requires it. GCC/EDG do not require a complete
type here, so we're calling this a problem with the standard. Fixes
PR8328.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116429 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-complete.cpp
171dcdb092232e5561152c334ce6d2836be33f0c 13-Oct-2010 Douglas Gregor <dgregor@apple.com> Place conversion warnings for non-type template arguments under the
control of -Wconversion, and ignore them by default.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116415 91177308-0d34-0410-b5e6-96231b3b80d8
emp_arg_nontype.cpp
b535041ee33c5eff255832bc5541c8d52aae8254 13-Oct-2010 Douglas Gregor <dgregor@apple.com> Fix a silly bug in the suppression of non-error diagnostics in a
SFINAE context, where we weren't getting the right diagnostic argument
count. I blame DiagnosticBuilder's weirdness. Fixes PR8372.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116411 91177308-0d34-0410-b5e6-96231b3b80d8
emp_arg_nontype.cpp
df41f18936693f7c62e457eefb9fad5b2d2fe3cd 12-Oct-2010 John McCall <rjmccall@apple.com> Enter the context of the declared function template when performing
deduction and the final substitution, but not while substituting the
explicit template arguments. Fixes rdar://problem/8537391



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116332 91177308-0d34-0410-b5e6-96231b3b80d8
eduction.cpp
1274ccd90aec0b205fc838c3d504821ccfb55482 09-Oct-2010 Douglas Gregor <dgregor@apple.com> Implement C++0x scoped enumerations, from Daniel Wallin! (and tweaked a
bit by me).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116122 91177308-0d34-0410-b5e6-96231b3b80d8
num-forward.cpp
1b398205267ea69f35230eea50e0225db22ebb7e 29-Sep-2010 Douglas Gregor <dgregor@apple.com> Fix handling of dependent nested namespace specifiers in UsingDecls
during template instantiation, from Martin Vejnar!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@115051 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-using-decl.cpp
200b2921390bd75a659be3c77011e9a5548b7273 18-Sep-2010 Douglas Gregor <dgregor@apple.com> When we run into an error parsing or type-checking the left-hand side
of a binary expression, continue on and parse the right-hand side of
the binary expression anyway, but don't call the semantic actions to
type-check. Previously, we would see the error and then, effectively,
skip tokens until the end of the statement.

The result should be more useful recovery, both in the normal case
(we'll actually see errors beyond the first one in a statement), but
it also helps code completion do a much better job, because we do
"real" code completion on the right-hand side of an invalid binary
expression rather than completing with the recovery completion. For
example, given

x = p->y

if there is no variable named "x", we can still complete after the p->
as a member expression. Along the recovery path, we would have
completed after the "->" as if we were in an expression context, which
is mostly useless.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114225 91177308-0d34-0410-b5e6-96231b3b80d8
ependent-base-classes.cpp
5833b0b831d6afae2885e6af420e2bda639652e6 15-Sep-2010 Douglas Gregor <dgregor@apple.com> When marking the declarations in a default argument expression as
"used", at the time that the default argument itself is used, also
mark destructors that will be called by this expression. This fixes a
regression that I introduced in r113700, which broke WebKit, and fixes
<rdar://problem/8427926>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113883 91177308-0d34-0410-b5e6-96231b3b80d8
efault-expr-arguments.cpp
2c5399f99c95b831fa90fd3a3c1d9719c1dd9441 13-Sep-2010 Abramo Bagnara <abramo.bagnara@gmail.com> Parentheses around address non-type template argument is demoted to an extension warning.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113739 91177308-0d34-0410-b5e6-96231b3b80d8
emp_arg_nontype.cpp
a4d5de539bc2f0cd25d6292e84eaa067591ff792 12-Sep-2010 Douglas Gregor <dgregor@apple.com> When diagnosing C++ [temp.expl.spec]p3 in C++98/03 mode, downgrade the
error to a warning if we're in a case that would be allowed in
C++0x. This "fixes" PR8084 by making Clang accept more code than GCC
and (non-strict) EDG do.

Also, add the missing test case for the C++0x semantics, which should
have been in r113717.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113718 91177308-0d34-0410-b5e6-96231b3b80d8
lass-template-spec.cpp
emp_class_spec_neg.cpp
4fcf5b2f816347ba7a3f16557d5e2b293634d4d6 12-Sep-2010 Douglas Gregor <dgregor@apple.com> Teach the EvaluatedExprVisitor and its client, which marks
declarations in potentially-evaluated subexpressions, about
recursion. Fixes the release-mode self-host failure I introduced in
r113700.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113708 91177308-0d34-0410-b5e6-96231b3b80d8
efault-expr-arguments.cpp
be0f7bd61c7b2879d02ae75aad7a91d92f819d94 11-Sep-2010 Douglas Gregor <dgregor@apple.com> When parsing default function arguments, do not mark any declarations
used in the default function argument as "used". Instead, when we
actually use the default argument, make another pass over the
expression to mark any used declarations as "used" at that point. This
addresses two kinds of related problems:

1) We were marking some declarations "used" that shouldn't be,
because we were marking them too eagerly.
2) We were failing to mark some declarations as "used" when we
should, if the first time it was instantiated happened to be an
unevaluated context, we wouldn't mark them again at a later point.

I've also added a potentially-handy visitor class template
EvaluatedExprVisitor, which only visits the potentially-evaluated
subexpressions of an expression. I bet this would have been useful for
noexcept...

Fixes PR5810 and PR8127.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113700 91177308-0d34-0410-b5e6-96231b3b80d8
efault-expr-arguments.cpp
c6cb2b02f0f4b3f162985803df3729b4def32108 11-Sep-2010 Douglas Gregor <dgregor@apple.com> Tweak GetPreamblePCHPath() to more closely match the behavior of the
Windows GetTempPath() function, and be sure to create the directory in
which the precompiled preamble will reside before creating the
temporary file itself.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113695 91177308-0d34-0410-b5e6-96231b3b80d8
efault-expr-arguments-2.cpp
4e6356426fcfef84e2484820814a8eaaaf547eda 11-Sep-2010 John McCall <rjmccall@apple.com> Support in-class initialization of static const floating-point data members.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113663 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-static-var.cpp
2f69a816a0986caa24d8e4273a3f83420b05f707 05-Sep-2010 Chris Lattner <sabre@nondot.org> "const std::vector<int>*" not "std::vector<int> const*"


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113094 91177308-0d34-0410-b5e6-96231b3b80d8
lass-template-id.cpp
0c42bb653dc40b1caae010618831e320af824b18 05-Sep-2010 Chris Lattner <sabre@nondot.org> 'const std::type_info*' instead of 'std::type_info const*'



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113092 91177308-0d34-0410-b5e6-96231b3b80d8
un-template-def.cpp
emp_arg_nontype.cpp
58f9e13e87e57236fee4b914eea9be6f92a1c345 05-Sep-2010 Chris Lattner <sabre@nondot.org> make clang print types as "const int *" instead of "int const*",
which is should have done from the beginning. As usual, the most
fun with this sort of change is updating all the testcases.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113090 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-4.cpp
nstantiation-default-1.cpp
030ef472f31709e175895853fcb43d61d09022c7 03-Sep-2010 Chandler Carruth <chandlerc@gmail.com> Fix PR7402 when it strikes via template instantiation.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113019 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-anonymous-union.cpp
17fb855280be411389361f1c79753e0013c4187c 03-Sep-2010 Chandler Carruth <chandlerc@gmail.com> Allow anonymous and local types. The support was already in place for these,
but this makes them work even as an extension in C++98. This resolves PR8077.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113011 91177308-0d34-0410-b5e6-96231b3b80d8
emp_arg_type.cpp
71b87e4fa6bfb47107b099135864f9024004a4c9 31-Aug-2010 Douglas Gregor <dgregor@apple.com> When template substitution into a template parameter reduces the level
of that parameter, reduce the level by the number of active template
argument lists rather than by 1. The number of active template
argument lists is only > 1 when we have a class template partial
specialization of a member template of a class template that itself is
a member template of another class template.

... and Boost.MSM does this. Fixes PR7669.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112551 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-member-template.cpp
d304fe66c032b6c73028cb45758614904e3c1735 30-Aug-2010 Gabor Greif <ggreif@gmail.com> add two more use-cases (explicit instantiation) that should pass now

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112533 91177308-0d34-0410-b5e6-96231b3b80d8
nject-templated-friend-post.cpp
ab297ac4d3f7c078a34c75493b840ef6b5801be3 30-Aug-2010 Gabor Greif <ggreif@gmail.com> fix dual aspect of PR8007,
namely when the friend function prototype is already used
at the point of the template definition that is supposed
to inject the friend function. Testcase verifies four
scenarios.
I would like receive some code review for this.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112524 91177308-0d34-0410-b5e6-96231b3b80d8
nject-templated-friend-post.cpp
e2248be8746e0ebb01e9a3b823bc0e129283bef4 30-Aug-2010 Douglas Gregor <dgregor@apple.com> Fix an corner-case assertion introduced by the refactoring in r112258;
when we're taking the address of a unresolvable value, it might be an
implicit member access. Fixes some Boost.Spirit regressions.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112487 91177308-0d34-0410-b5e6-96231b3b80d8
ember-access-expr.cpp
cd05e81e2e2640a0a0097658c660afc6c8a9f4fd 29-Aug-2010 John McCall <rjmccall@apple.com> When perform exact-qualifier-match template argument deduction,
properly account for the possibility that certain opaque types
might be more qualified than they appear. Fixes PR7708.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112390 91177308-0d34-0410-b5e6-96231b3b80d8
eduction.cpp
67d22fb57ecccd29ea9c8ec004f63dc356cd477d 28-Aug-2010 John McCall <rjmccall@apple.com> If filtering a lookup result leaves it ambiguous, keep the ambiguity
kind. Fixes PR7252.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112383 91177308-0d34-0410-b5e6-96231b3b80d8
emp.cpp
4d99a3da7ef08be34131b60b91f16adb3bc5f001 28-Aug-2010 Gabor Greif <ggreif@gmail.com> add another test for PR8007
this is still failing, need to come up with a fix
(but we are in good company as the first gcc version
pass this test will be v4.6)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112369 91177308-0d34-0410-b5e6-96231b3b80d8
nject-templated-friend-post.cpp
aaafddba8b2b7f2f601bd86fdafaefde38da469d 28-Aug-2010 Gabor Greif <ggreif@gmail.com> check whether sema issues a redefinition error

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112347 91177308-0d34-0410-b5e6-96231b3b80d8
nject-templated-friend.cpp
bb452e99a8b97ea20bcfb5c3583dbf1da53b0024 28-Aug-2010 Gabor Greif <ggreif@gmail.com> note to self: save before committing; add PR

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112339 91177308-0d34-0410-b5e6-96231b3b80d8
nject-templated-friend.cpp
19de06bd7b7772a6a70ccefdc20be75ed1e7b69c 28-Aug-2010 Gabor Greif <ggreif@gmail.com> fix test by applying it in top namespace: PR8007 only showed up this way

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112338 91177308-0d34-0410-b5e6-96231b3b80d8
nject-templated-friend.cpp
40181c4e587b8a988e691d7b46580b1a1212c535 28-Aug-2010 Gabor Greif <ggreif@gmail.com> fix PR8007
reordering and redefinition issues still may linger,
I plan to nail them next

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112333 91177308-0d34-0410-b5e6-96231b3b80d8
nject-templated-friend.cpp
c620ace6dbeb2a07e80088d64ea98cc0c8b58121 28-Aug-2010 Gabor Greif <ggreif@gmail.com> reproduction recipe for PR8007, expected to fail for now, review welcome

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112326 91177308-0d34-0410-b5e6-96231b3b80d8
nject-templated-friend.cpp
7114cbab7eb6e8b714eb22f014327daf2c741c08 27-Aug-2010 John McCall <rjmccall@apple.com> Continue to instantiate sub-statements in a CompoundStmt as long as
we don't see a DeclStmt (failure to instantiate which generally causes
panic).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112282 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-clang.cpp
nstantiate-expr-3.cpp
nstantiate-expr-4.cpp
nstantiate-function-1.cpp
d9ca4ab3ed3637e97a19d716aa9fbd54c6a5f698 20-Aug-2010 Nick Lewycky <nicholas@mxc.ca> Add a workaround for PR7947, a crash trying to recover from invalid C++ code.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111675 91177308-0d34-0410-b5e6-96231b3b80d8
ecovery-crash.cpp
766724566289e6951a90b6483f0d3e22fe4b9b52 20-Aug-2010 John McCall <rjmccall@apple.com> Correctly instantiate templates with non-type template arguments that
are local externs. Fixes <rdar://problem/8302138>.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111570 91177308-0d34-0410-b5e6-96231b3b80d8
emp_arg_nontype.cpp
e4f26e54d81fb1987333132fe34cd927e62c803c 19-Aug-2010 John McCall <rjmccall@apple.com> When deducing the element type of an array, ignore qualifiers if
the context allows us to ignore qualifiers on the array type itself.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111486 91177308-0d34-0410-b5e6-96231b3b80d8
eduction.cpp
ec8045d3f0375302eadaa63deb373bacaf25a569 17-Aug-2010 John McCall <rjmccall@apple.com> Implicit decl ref expressions might not have name locations; don't silently
fail to instantiate them.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111293 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-declref.cpp
647c8b32c2a6e38ee44dde1782a629e9c03786e2 07-Aug-2010 Eli Friedman <eli.friedman@gmail.com> PR7837: For qualified id's, make sure the decl context is complete if not
dependent in ActOnIdExpression. (This issue only shows up with member
operators because an operator is never a type.)



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110486 91177308-0d34-0410-b5e6-96231b3b80d8
ependent-class-member-operator.cpp
caadc127fef2a5ce5dddae0d3ac6a582c285baff 06-Aug-2010 Douglas Gregor <dgregor@apple.com> Remove some incorrect assertions when deduction template arguments in
a template-argument-list. When template template parameters are
involved, we won't already have checked the template-argument-list (it
may not be known yet!). Fixes PR7807.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110444 91177308-0d34-0410-b5e6-96231b3b80d8
emp_arg_template.cpp
57e97786433e70197a089360228d8f0d82e3ad4c 05-Aug-2010 John McCall <rjmccall@apple.com> TDK_InconsistentQuals is really totally different from TDK_Inconsistent.
Rename it to TDK_Underqualified to avoid this sort of confusion and give it
its own diagnostic.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110318 91177308-0d34-0410-b5e6-96231b3b80d8
eduction.cpp
1d8d1ccd36888f1120b3a1df9e76f35dc2edb81d 01-Aug-2010 John McCall <rjmccall@apple.com> Instantiate attributes from the pattern record when instantiating
a class template. Fixes rdar://problem/8243419.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109967 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-attr.cpp
207014eb2b372aa33721e86d90a8a586ba8dc8ae 30-Jul-2010 John McCall <rjmccall@apple.com> Improve error recovery when presented with an ill-formed template-id
(e.g. due to a broken template argument) following template parameters.

Fixes rdar://problem/8254267



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109853 91177308-0d34-0410-b5e6-96231b3b80d8
lass-template-id.cpp
eduction-crash.cpp
98c2e6248fa4152cd6a6aea9a8d894f7fe21f394 29-Jul-2010 Douglas Gregor <dgregor@apple.com> Don't set out-of-line template specialization/definition information
for AST nodes that aren't actually out-of-line (i.e., require a
nested-name-specifier). Fixes <rdar://problem/8204126>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109704 91177308-0d34-0410-b5e6-96231b3b80d8
rash-8204126.cpp
6813d7ba5fa79e36bdb3986e7f3f8100915a61ab 28-Jul-2010 Douglas Gregor <dgregor@apple.com> Enable expression transformations in the current-instantiation
rebuilder, i.e., remove a silly short-sighted hack from long
ago. Thanks to Abramo Bagnara for the test case/bug report!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109583 91177308-0d34-0410-b5e6-96231b3b80d8
urrent-instantiation.cpp
ac7cbd8102a944c7e988b066fc52c03fdd536dc0 28-Jul-2010 Douglas Gregor <dgregor@apple.com> When a nested-name-specifier refers into a current instantiation that has
dependent bases, construct a dependent nested-name-specifier rather
than complaining that the name could not be found within the current
instantiation itself. Fixes PR7725.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109582 91177308-0d34-0410-b5e6-96231b3b80d8
ested-name-spec-template.cpp
787b0946959d1203d5bb95a298ee2e7286ded995 27-Jul-2010 Eli Friedman <eli.friedman@gmail.com> PR7724: Don't try to evaluate value-dependent expressions.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109532 91177308-0d34-0410-b5e6-96231b3b80d8
ependent-expr.cpp
0f2b97d1b0bfbcec727a386dc9e5cf06051cb29b 24-Jul-2010 Eli Friedman <eli.friedman@gmail.com> PR7698: Make sure we correctly handle the initialization of an array with
dependent size.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109356 91177308-0d34-0410-b5e6-96231b3b80d8
ependent-base-member-init.cpp
f9f97a0ea15456dca52ba7962e5d8017f996cd4a 16-Jul-2010 Douglas Gregor <dgregor@apple.com> When performing template name lookup for a dependent member access
expression such as the "foo" in "this->blah.foo<1, 2>", and we can't
look into the type of "this->blah" (e.g., because it is dependent),
look into the local scope of a template of the same name. Fixes
<rdar://problem/8198511>.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108531 91177308-0d34-0410-b5e6-96231b3b80d8
ember-template-access-expr.cpp
0167f3c25581c39cd024d7a924553959c4893381 15-Jul-2010 Douglas Gregor <dgregor@apple.com> When there are extra or missing template parameter lists in a template
definition, we're likely going to end up breaking the invariants of
the template system, e.g., that the depths of template parameter lists
match up with the nesting template of the template. So, make sure we
mark such ill-formed declarations as invalid or don't even build them
at all.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108372 91177308-0d34-0410-b5e6-96231b3b80d8
eduction-crash.cpp
5495f37302f7c82192dab1ce8d9c9fe76ed0ee37 14-Jul-2010 Chandler Carruth <chandlerc@gmail.com> Wire up '-Wignored-qualifiers' to the warning on 'const' in 'const int f()'.
This flag and warning match GCC semantics. Also, move it to -Wextra as this is
a largely cosmetic issue and doesn't seem to mask problems. Subsequent fixes to
the tests which no longer by default emit the warning. Added explicit test
cases for both C and C++ behavior with the warning turned on.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108325 91177308-0d34-0410-b5e6-96231b3b80d8
eduction.cpp
218f47ff746b2216e949e79a287c034fd0bd8713 13-Jul-2010 Douglas Gregor <dgregor@apple.com> When computing the canonical profile of a DeclRefExpr or MemberExpr,
don't include the nested-name-specifier or template arguments: they
were only relevant when resolving the declaration. Fixes PR7460.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108235 91177308-0d34-0410-b5e6-96231b3b80d8
ependent-type-identity.cpp
5291c3cec0dbe8ad1d8e7e67e93af2b1586d5400 13-Jul-2010 Douglas Gregor <dgregor@apple.com> When forming a function call or message send expression, be sure to
strip cv-qualifiers from the expression's type when the language calls
for it: in C, that's all the time, while C++ only does it for
non-class types.

Centralized the computation of the call expression type in
QualType::getCallResultType() and some helper functions in other nodes
(FunctionDecl, ObjCMethodDecl, FunctionType), and updated all relevant
callers of getResultType() to getCallResultType().

Fixes PR7598 and PR7463, along with a bunch of getResultType() call
sites that weren't stripping references off the result type (nothing
stripped cv-qualifiers properly before this change).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108234 91177308-0d34-0410-b5e6-96231b3b80d8
eduction.cpp
669eed8d676458c701f45f7fd686f01de2dee53b 13-Jul-2010 Douglas Gregor <dgregor@apple.com> Provide a special diagnostic for attempts to explicitly specialize
class templates within class scope (which is ill-formed), and recover
by dropping the explicit specialization entirely. Fixes the infinite
loop in PR7622.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108217 91177308-0d34-0410-b5e6-96231b3b80d8
xplicit-instantiation.cpp
184aa4e6ded190bfb3bbe207040467f8d7e28a04 12-Jul-2010 Chris Lattner <sabre@nondot.org> fix PR7280 by making the warning on code like this:

int test1() {
return;
}

default to an error.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108108 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-function-1.cpp
999194739e3a2d35b5a1e563ba514cba8b4ab252 10-Jul-2010 Chandler Carruth <chandlerc@gmail.com> Lay the ground work for resoving PR7047. This doesn't actually fix it because
default arguments to template parameters don't have a DeclContext when
instantiated, and so we can't detect that we're in an instantiation context as
opposed to the definition context. However, it fixes the more commonly-occuring
cases in TMP code that use devolve to this type of tautology after
substitution.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108044 91177308-0d34-0410-b5e6-96231b3b80d8
elf-comparison.cpp
24bae92f08ae098cc50a602d8cf1273b423e14da 08-Jul-2010 Douglas Gregor <dgregor@apple.com> When performing substitution of template arguments within the body of
a template, be sure to include the template arguments from the
injected-class-name. Fixes PR7587.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107895 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-member-template.cpp
27cac990649d9c1217f018921749683464a28e6b 30-Jun-2010 Douglas Gregor <dgregor@apple.com> Clean up the diagnostic complaining about the element type of a vector
type so that it actually complains about the element type itself.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107299 91177308-0d34-0410-b5e6-96231b3b80d8
xt-vector-type.cpp
9fde9c424f734e1ef45177999e3a04faad127414 29-Jun-2010 Daniel Dunbar <daniel@zuster.org> tests: Use %clangxx when using driver for C++, in case C++ support is disabled.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107153 91177308-0d34-0410-b5e6-96231b3b80d8
xample-dynarray.cpp
4ced79f0971592e6e7122037de69ee9ae534ce72 25-Jun-2010 Chandler Carruth <chandlerc@gmail.com> Implement dependent alignment attribute support. This is a bit gross given the
current attribute system, but it is enough to handle class templates which
specify parts of their alignment in terms of their template parameters.

This also replaces the attributes test in SemaTemplate with one that actually
tests working attributes instead of broken ones. I plan to add more tests here
for non-dependent attributes in a subsequent patch.

Thanks to John for walking me through some of this. =D


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106818 91177308-0d34-0410-b5e6-96231b3b80d8
ttributes.cpp
83c9abcce26422420dcdb9d2741bced21ee2477f 22-Jun-2010 Douglas Gregor <dgregor@apple.com> Apply array-to-pointer decay when instantiating a MemberExpr. Fixes
PR7405, patch by Kyle Lippincott!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106523 91177308-0d34-0410-b5e6-96231b3b80d8
rray-to-pointer-decay.cpp
c070cc602d6eefea881f71a60de09e05b54c3fdd 18-Jun-2010 Douglas Gregor <dgregor@apple.com> Given Decl::isUsed() a flag indicating when to consider the "used"
attribute as part of the calculation. Sema::MarkDeclReferenced(), and
a few other places, want only to consider the "used" bit to determine,
e.g, whether to perform template instantiation. Fixes a linkage issue
with Boost.Serialization.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106252 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-function-2.cpp
e2872d0bda1d209d4409de2ed13648e6811628b7 17-Jun-2010 Douglas Gregor <dgregor@apple.com> When pushing a copy of the TypeLoc information for a dependent
template specialization type, copy the location information but use
the new type. Fixes PR7385.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106224 91177308-0d34-0410-b5e6-96231b3b80d8
ested-name-spec-template.cpp
d6ab232bb3ec9847de5af06249afb63078b5f2ee 17-Jun-2010 Douglas Gregor <dgregor@apple.com> When we see a 'template' disambiguator that marks the next identifier
(or operator-function-id) as a template, but the context is actually
non-dependent or the current instantiation, allow us to use knowledge
of what kind of template it is, e.g., type template vs. function
template, for further syntactic disambiguation. This allows us to
parse properly in the presence of stray "template" keywords, which is
necessary in C++0x and it's good recovery in C++98/03.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106167 91177308-0d34-0410-b5e6-96231b3b80d8
ested-name-spec-template.cpp
1a15dae8be2b28e02b6639aa92b832465c5be420 17-Jun-2010 Douglas Gregor <dgregor@apple.com> Fix the recently-added warning about 'typename' and 'template'
disambiguation keywords outside of templates in C++98/03. Previously,
the warning would fire when the associated nested-name-specifier was
not dependent, but that was a misreading of the C++98/03 standard:
now, we complain only when we're outside of any template.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106161 91177308-0d34-0410-b5e6-96231b3b80d8
ested-name-spec-template.cpp
emplate-id-expr.cpp
ypename-specifier-4.cpp
ypename-specifier.cpp
3e1274f2b99cb99c03cc8e2c6517c37d330b597a 16-Jun-2010 Douglas Gregor <dgregor@apple.com> Canonicalize template template parameters when canonicalizing a
template name that refers to such a parameter. It's amazing that this
problem didn't surface earlier. Fixes PR7387.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106147 91177308-0d34-0410-b5e6-96231b3b80d8
ember-function-template.cpp
d27e50cd839760880a73cfaaa93f912c01cb2171 16-Jun-2010 Douglas Gregor <dgregor@apple.com> Don't poke at an undefined class type of a field. Fixes PR7355.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106111 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-field.cpp
3956b1ab303139d9e952c2c30ed16643fad0c325 16-Jun-2010 Douglas Gregor <dgregor@apple.com> If a non-dependent base class initializer fails to match any direct or
virtual base class, but the class still has dependent base classes,
then don't diagnose the failed match as an error: the right base class
might magically appear. Fixes PR7259.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106103 91177308-0d34-0410-b5e6-96231b3b80d8
lass-template-ctor-initializer.cpp
732281de5d518fca96c449ae185ee56bde422c4f 15-Jun-2010 Douglas Gregor <dgregor@apple.com> Warn when a 'typename' or a 'template' keyword refers to a
non-dependent type or template name, respectively, in C++98/03. Fixes
PR7111 and <rdar://problem/8002682>.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105968 91177308-0d34-0410-b5e6-96231b3b80d8
ested-name-spec-template.cpp
emplate-id-expr.cpp
ypename-specifier-4.cpp
ypename-specifier.cpp
24da7093a84e4eb92731e0565ab655697b2ed08f 11-Jun-2010 John McCall <rjmccall@apple.com> Provide an Objective C mangling for wchar_t. Patch by Nico Weber!



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105818 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-objc-1.mm
9f716e4140da8d18165a702f81d2286a12e83a8c 27-May-2010 Douglas Gregor <dgregor@apple.com> When we've parsed a nested-name-specifier in a member access
expression, "forget" about the object type; only the
nested-name-specifier matters for name lookup purposes. Fixes PR7239.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104834 91177308-0d34-0410-b5e6-96231b3b80d8
estructor-template.cpp
5613876991c80a684595fe8de1f039296a0657ff 27-May-2010 John McCall <rjmccall@apple.com> Require a complete type when performing the qualified lookup during
instantiation of a dependent elaborated type specifier. Fixes PR 7199.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104822 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-complete.cpp
ff2e4f44e56aef84fa423af4ca5c1fe56886b4aa 26-May-2010 Douglas Gregor <dgregor@apple.com> When transforming a C++ "new" expression's constructor arguments, drop
any arguments that are default-argument expressions. The can show up
when we have a new expression whose constructor arguments are not
type-dependent and whose allocated type is not dependent and has a
constructor with default arguments. Fixes PR7202.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104690 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-2.cpp
ceafbdeb93ecf323cca74e660bf54504c86f3b71 24-May-2010 Douglas Gregor <dgregor@apple.com> A type- or value-dependent expression cannot use bitfield
promotion. Fixes <rdar://problem/8020920>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104545 91177308-0d34-0410-b5e6-96231b3b80d8
num-argument.cpp
fb2db4657dc1e305c98d0c48fb1009a9f65b337a 22-May-2010 Douglas Gregor <dgregor@apple.com> Don't look for a destructor in a dependent type. Fixes PR7198.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104445 91177308-0d34-0410-b5e6-96231b3b80d8
ependent-expr.cpp
0fddb97901dbe36a8253dee29961cba8e0a87cf6 22-May-2010 Douglas Gregor <dgregor@apple.com> Implement support for variable length arrays in C++. VLAs are limited
in several important ways:

- VLAs of non-POD types are not permitted.
- VLAs cannot be used in conjunction with C++ templates.

These restrictions are intended to keep VLAs out of the parts of the
C++ type system where they cause the most trouble. Fixes PR5678 and
<rdar://problem/8013618>.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104443 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-declref-ice.cpp
d5ab9b0a0ae24f7d0f49f6f10fd1b247e64b3306 22-May-2010 Douglas Gregor <dgregor@apple.com> Improve recovery when we see a dependent template name that is missing
the required "template" keyword, using the same heuristics we do for
dependent template names in member access expressions, e.g.,

test/SemaTemplate/dependent-template-recover.cpp:11:8: error: use 'template'
keyword to treat 'getAs' as a dependent template name
T::getAs<U>();
^
template

Fixes PR5404.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104409 91177308-0d34-0410-b5e6-96231b3b80d8
ependent-base-classes.cpp
ependent-template-recover.cpp
1fd6d44d7ca97631497551bbf98866263143d706 22-May-2010 Douglas Gregor <dgregor@apple.com> Improve parser recovery when we encounter a dependent template name
that is missing the 'template' keyword, e.g.,

t->getAs<T>()

where getAs is a member of an unknown specialization. C++ requires
that we treat "getAs" as a value, but that would fail to parse since T
is the name of a type. We would then fail at the '>', since a type
cannot be followed by a '>'.

This is a very common error for C++ programmers to make, especially
since GCC occasionally allows it when it shouldn't (as does Visual
C++). So, when we are in this case, we use tentative parsing to see if
the tokens starting at "<" can only be parsed as a template argument
list. If so, we produce a diagnostic with a fix-it that states that
the 'template' keyword is needed:

test/SemaTemplate/dependent-template-recover.cpp:5:8: error: 'template' keyword
is required to treat 'getAs' as a dependent template name
t->getAs<T>();
^
template

This is just a start of this patch; I'd like to apply the same
approach to everywhere that a template-id with dependent template name
can be parsed.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104406 91177308-0d34-0410-b5e6-96231b3b80d8
ependent-template-recover.cpp
b212d9a8e10308cde5b7a1ce07bd59d8df14fa06 21-May-2010 Douglas Gregor <dgregor@apple.com> When instantiating a function declaration within a function template,
be sure to merge its parameter scope with its parent's scope. Fixes
PR7184.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104386 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-function-2.cpp
9901c57806f7e36736ed1616e6ab3eebcc99b78c 21-May-2010 Douglas Gregor <dgregor@apple.com> When instantiating anonymous structs/unions within a function, make
sure that the anonymous struct/union record declaration gets
instantiated before the variable declaration, and that it and its
fields (recursively) get entries in the local instantiation map. Fixes
PR7088.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104305 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-anonymous-union.cpp
4469e8a97cdca3725b4f8f366916143113c029ac 19-May-2010 Douglas Gregor <dgregor@apple.com> Revert r104106; it's breaking linking of Boost.Serialization.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104121 91177308-0d34-0410-b5e6-96231b3b80d8
ttributes.cpp
a89064aa4695d9a2fec24efcc74ca0e795aaa17c 19-May-2010 Douglas Gregor <dgregor@apple.com> 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104107 91177308-0d34-0410-b5e6-96231b3b80d8
ependent-type-identity.cpp
7d2bcc74fd32875b737dabe3b4f867fe4c907ca0 19-May-2010 Douglas Gregor <dgregor@apple.com> Teach clang to instantiate attributes on more declarations. Fixes PR7102.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104106 91177308-0d34-0410-b5e6-96231b3b80d8
ttributes.cpp
ac06a0e1e3feb95c2ffd352c086882b492a65b99 19-May-2010 Douglas Gregor <dgregor@apple.com> Protect isIntegerConstantExpr from seeing type- or value-dependent
expressions in attributes, pragmas.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104083 91177308-0d34-0410-b5e6-96231b3b80d8
ttributes.cpp
a6b0907a71c66e6bf65e2477a6f9783d9fec4d47 18-May-2010 Douglas Gregor <dgregor@apple.com> Instantiate attributes on typedefs. This is a quick fix for PR7148,
when we really need a proper audit of our handling of attributes in
templates.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103999 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-attr.cpp
00b4b039f02d338ae4774797053235a7e65abbde 14-May-2010 Douglas Gregor <dgregor@apple.com> Make sure to search semantic scopes and appropriate template-parameter
scopes during unqualified name lookup that has fallen out to namespace
scope. Fixes PR7133.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103766 91177308-0d34-0410-b5e6-96231b3b80d8
ested-name-spec-template.cpp
6fb745bdf1ff1e32caf07e42093a7920726892c1 13-May-2010 Douglas Gregor <dgregor@apple.com> Rework when and how vtables are emitted, by tracking where vtables are
"used" (e.g., we will refer to the vtable in the generated code) and
when they are defined (i.e., because we've seen the key function
definition). Previously, we were effectively tracking "potential
definitions" rather than uses, so we were a bit too eager about emitting
vtables for classes without key functions.

The new scheme:
- For every use of a vtable, Sema calls MarkVTableUsed() to indicate
the use. For example, this occurs when calling a virtual member
function of the class, defining a constructor of that class type,
dynamic_cast'ing from that type to a derived class, casting
to/through a virtual base class, etc.
- For every definition of a vtable, Sema calls MarkVTableUsed() to
indicate the definition. This happens at the end of the translation
unit for classes whose key function has been defined (so we can
delay computation of the key function; see PR6564), and will also
occur with explicit template instantiation definitions.
- For every vtable defined/used, we mark all of the virtual member
functions of that vtable as defined/used, unless we know that the key
function is in another translation unit. This instantiates virtual
member functions when needed.
- At the end of the translation unit, Sema tells CodeGen (via the
ASTConsumer) which vtables must be defined (CodeGen will define
them) and which may be used (for which CodeGen will define the
vtables lazily).

From a language perspective, both the old and the new schemes are
permissible: we're allowed to instantiate virtual member functions
whenever we want per the standard. However, all other C++ compilers
were more lazy than we were, and our eagerness was both a performance
issue (we instantiated too much) and a portability problem (we broke
Boost test cases, which now pass).

Notes:
(1) There's a ton of churn in the tests, because the order in which
vtables get emitted to IR has changed. I've tried to isolate some of
the larger tests from these issues.
(2) Some diagnostics related to
implicitly-instantiated/implicitly-defined virtual member functions
have moved to the point of first use/definition. It's better this
way.
(3) I could use a review of the places where we MarkVTableUsed, to
see if I missed any place where the language effectively requires a
vtable.

Fixes PR7114 and PR6564.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103718 91177308-0d34-0410-b5e6-96231b3b80d8
irtual-member-functions.cpp
9679cafc6368cceed1a5e69d3038d0316401b352 12-May-2010 Douglas Gregor <dgregor@apple.com> Whenever we instantiate a function definition or class, enter a new
potentially-evaluated expression context, to ensure that used
declarations get properly marked. Fixes PR7123.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103624 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-field.cpp
380c2139959d8608782292984b457640a143a70d 11-May-2010 Daniel Dunbar <daniel@zuster.org> Speculatively revert r103497, "Do not mark the virtual members of an
implicitly-instantiated class as ...", which seems to have broken bootstrap.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103515 91177308-0d34-0410-b5e6-96231b3b80d8
irtual-member-functions.cpp
bbbe074566a8defed299ff676bc65b3631861768 11-May-2010 Douglas Gregor <dgregor@apple.com> Do not mark the virtual members of an implicitly-instantiated class as
referenced unless we see one of them defined (or the key function
defined, if it as one) or if we need the vtable for something. Fixes
PR7114.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103497 91177308-0d34-0410-b5e6-96231b3b80d8
irtual-member-functions.cpp
2166beba8d939d2938c5401af2c8d3687afd5d8c 11-May-2010 Douglas Gregor <dgregor@apple.com> The C++98/03 standard is disturbingly silent about out-of-scope
explicit instantiations of template. C++0x clarifies the intent
(they're ill-formed in some cases; see [temp.explicit] for
details). However, one could squint at the C++98/03 standard and
conclude they are permitted, so reduce the error to a warning
(controlled by -Wc++0x-compat) in C++98/03 mode.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103482 91177308-0d34-0410-b5e6-96231b3b80d8
emp_explicit.cpp
85bcd9920582f4d3879d8fbbaf4ca4fe09690160 11-May-2010 Douglas Gregor <dgregor@apple.com> Static data members intialized in-class that have constant values are
value-dependent if their initializers are value-dependent; my recent
tweak to these dependent rules overstepped by taking away this
value-dependents. Fixes a Boost.GIL regression.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103476 91177308-0d34-0410-b5e6-96231b3b80d8
urrent-instantiation.cpp
bb6e73fcf60fa5a4cc36c14744dc366b658443b5 11-May-2010 Douglas Gregor <dgregor@apple.com> A DeclRefExpr that refers to a member function or a static data member
of the current instantiation is value-dependent. The C++ standard
fails to enumerate this case and, therefore, we missed it. Chandler
did all of the hard work of reducing the last remaining
Boost.PtrContainer failure (which had to do with static initialization
in the Serialization library) down to this simple little test.

While I'm at it, clean up the dependence rules for template arguments
that are declarations, and implement the dependence rules for template
argument packs.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103464 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-member-pointers.cpp
444eaa83cc2dd7904e4deed82574696b9337de02 11-May-2010 Chandler Carruth <chandlerc@gmail.com> Add a test for a subtle instantiation pattern that showed up within a Boost
miscompile reduction. Clang already handles this correctly, but let's make sure
it stays that way.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103463 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-overload-candidates.cpp
5764f613e61cb3183f3d7ceeafd23396de96ed16 09-May-2010 Douglas Gregor <dgregor@apple.com> Improve our handling of the -Wunused-variable warning in templates. In
particular, don't complain about unused variables that have dependent
type until instantiation time, so that we can look at the type of the
variable. Moreover, only complain about unused variables that have
neither a user-declared constructor nor a non-trivial destructor.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103362 91177308-0d34-0410-b5e6-96231b3b80d8
nused-variables.cpp
eaa18e449bb09c1e580aa35f9606ff2ca682f4cb 09-May-2010 Douglas Gregor <dgregor@apple.com> When instantiating statements that involve conditions (if, while, do,
for, and switch), be careful to construct the full expressions as soon
as we perform template instantation, so we don't either forget to call
temporary destructors or destroy temporaries at the wrong time. This
is the template-instantiation analogue to r103187, during which I
hadn't realized that the issue would affect the handling of these
constructs differently inside and outside of templates.

Fixes a regression in Boost.Function.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103357 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-3.cpp
ff5adac099e9be58e16cf118ca3eb3f3e570c616 08-May-2010 Douglas Gregor <dgregor@apple.com> Record template argument deduction failures for member function
templates and conversion function templates.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103349 91177308-0d34-0410-b5e6-96231b3b80d8
verload-candidates.cpp
ec20f46740a59758b12c22108002395bcf5b6f9b 08-May-2010 Douglas Gregor <dgregor@apple.com> When printing an overload candidate that failed due to SFINAE, print a
specific message that includes the template arguments, e.g.,

test/SemaTemplate/overload-candidates.cpp:27:20: note: candidate template
ignored: substitution failure [with T = int *]
typename T::type get_type(const T&); // expected-note{{candidate ...
^



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103348 91177308-0d34-0410-b5e6-96231b3b80d8
verload-candidates.cpp
f1a8445036a2d047c7165d4170e3058cdeaba6eb 08-May-2010 Douglas Gregor <dgregor@apple.com> Improve overload-candidate diagnostic for a function template that
failed because the explicitly-specified template arguments did not
match its template parameters, e.g.,

test/SemaTemplate/overload-candidates.cpp:18:8: note: candidate
template
ignored: invalid explicitly-specified argument for template
parameter 'I'
void get(const T&);
^
test/SemaTemplate/overload-candidates.cpp:20:8: note: candidate
template
ignored: invalid explicitly-specified argument for 1st template
parameter
void get(const T&);
^



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103344 91177308-0d34-0410-b5e6-96231b3b80d8
verload-candidates.cpp
a933319ebf754396623165f9dc0a29c2a48879f5 08-May-2010 Douglas Gregor <dgregor@apple.com> When printing a non-viable overload candidate that failed due to
conflicting deduced template argument values, give a more specific
reason along with those values, e.g.,

test/SemaTemplate/overload-candidates.cpp:4:10: note: candidate template
ignored: deduced conflicting types for parameter 'T' ('int' vs. 'long')
const T& min(const T&, const T&);
^




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103339 91177308-0d34-0410-b5e6-96231b3b80d8
verload-candidates.cpp
b4eeaff1595b7d0a8fbc2b3c8bec7dc63f48b7fd 08-May-2010 Douglas Gregor <dgregor@apple.com> When we encounter a non-dependent type during template instantiation,
mark any declarations we see inside of that type as
"referenced". Fixes PR7079.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103323 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-non-dependent-types.cpp
6b6d01fbc297d703f7ad1e605aa97afc6289a64f 07-May-2010 Douglas Gregor <dgregor@apple.com> Reapply the reference-binding patch applied below, along with a fix to
ensure that we complete the type when we need to look at constructors
during reference binding.

When determining whether the two types involved in reference binding
are reference-compatible, reference-related, etc., do not complete the
type of the reference itself because it is not necessary to determine
well-formedness of the program. Complete the type that we are binding
to, since that can affect whether we know about a derived-to-base
conversion.

Re-fixes PR7080.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103283 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-complete.cpp
44c980611525b607ea3ad5c816bd91f37d1b5df5 07-May-2010 Douglas Gregor <dgregor@apple.com> Revert r103220. It seems to be breaking self-host

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103259 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-complete.cpp
abfe1925e7cb0fbc36944f376b0695a68eebb455 07-May-2010 Douglas Gregor <dgregor@apple.com> When determining whether the two types involved in reference binding
are reference-compatible, reference-related, etc., do not complete the
type of the reference itself because it is not necessary to determine
well-formedness of the program. Complete the type that we are binding
to, since that can affect whether we know about a derived-to-base
conversion.

Fixes PR7080.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103220 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-complete.cpp
13c8577201e4fc0ddac5f09d05fd1778832137d1 06-May-2010 Douglas Gregor <dgregor@apple.com> Partial and full specializations of a class template may have a
different tag kind ("struct" vs. "class") than the primary template,
which has an affect on access control.

Should fix the last remaining Boost.Accumulors failure.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103144 91177308-0d34-0410-b5e6-96231b3b80d8
artial-spec-instantiate.cpp
0278e123b4606ea15dbfa717e9c5a76a5ef2bc7d 05-May-2010 Douglas Gregor <dgregor@apple.com> Support for 'template' as a disambiguator (PR7030)

ParseOptionalCXXScopeSpecifier() only annotates the subset of
template-ids which are not subject to lexical ambiguity. Add support
for the more general case in ParseUnqualifiedId() to handle cases
such as A::template B().

Also improve some diagnostic locations.

Fixes PR7030, from Alp Toker!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103081 91177308-0d34-0410-b5e6-96231b3b80d8
emplate-id-expr.cpp
5f970eee81372dfc6a1457c3d6d052af04e32a38 04-May-2010 Douglas Gregor <dgregor@apple.com> When instantiating a function that was declared via a typedef, e.g.,

typedef int functype(int, int);
functype func;

also instantiate the synthesized function parameters for the resulting
function declaration.

With this change, Boost.Wave builds and passes all of its regression
tests.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103025 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-function-params.cpp
e7089b0c6ffe8a8854150b60df00fb544099f77d 04-May-2010 Douglas Gregor <dgregor@apple.com> When computing the template arguments for the instantiation of a
friend function template, be sure to adjust the computed template
argument lists based on the location of the definition of the function
template: it's possible that the definition we're instantiating with
and the template declaration that we found when creating the
specialization are in different contexts, which meant that we would
end up using the wrong template arguments for instantiation.

Fixes PR7013; all Boost.DynamicBitset tests now pass.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102974 91177308-0d34-0410-b5e6-96231b3b80d8
riend-template.cpp
f7d72f5a4a3f0e610d77c6779ca3c21920a14bc7 03-May-2010 Douglas Gregor <dgregor@apple.com> When instantiating a function-local variable definition, introduce the
mapping from the declaration in the template to the instantiated
declaration before transforming the initializer, in case some crazy
lunatic decides to use a variable in its own initializer. Fixes PR7016.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102945 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-function-1.cpp
8fc6d236b8d05bad4b41a9be689b26d931adedd5 03-May-2010 Douglas Gregor <dgregor@apple.com> It's okay to reference an enum in a template definition, even though
it's ill-formed to form an enum template. Fixes <rdar://problem/7933063>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102926 91177308-0d34-0410-b5e6-96231b3b80d8
emplate-decl-fail.cpp
6920cdce298ac9ba50dc7ebb7dea982a300b0664 03-May-2010 Douglas Gregor <dgregor@apple.com> When instantiating a member function declared via a typedef, don't try
to enter the instantiated parameter declarations into the local
instantiation scope; they can't be referenced anyway. Fixes PR7022.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102914 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-method.cpp
06a9f3680d22529a2fcf20c52d71cf221d99d910 01-May-2010 Douglas Gregor <dgregor@apple.com> Complete reimplementation of the synthesis for implicitly-defined copy
assignment operators.

Previously, Sema provided type-checking and template instantiation for
copy assignment operators, then CodeGen would synthesize the actual
body of the copy constructor. Unfortunately, the two were not in sync,
and CodeGen might pick a copy-assignment operator that is different
from what Sema chose, leading to strange failures, e.g., link-time
failures when CodeGen called a copy-assignment operator that was not
instantiation, run-time failures when copy-assignment operators were
overloaded for const/non-const references and the wrong one was
picked, and run-time failures when by-value copy-assignment operators
did not have their arguments properly copy-initialized.

This implementation synthesizes the implicitly-defined copy assignment
operator bodies in Sema, so that the resulting ASTs encode exactly
what CodeGen needs to do; there is no longer any special code in
CodeGen to synthesize copy-assignment operators. The synthesis of the
body is relatively simple, and we generate one of three different
kinds of copy statements for each base or member:

- For a class subobject, call the appropriate copy-assignment
operator, after overload resolution has determined what that is.
- For an array of scalar types or an array of class types that have
trivial copy assignment operators, construct a call to
__builtin_memcpy.
- For an array of class types with non-trivial copy assignment
operators, synthesize a (possibly nested!) for loop whose inner
statement calls the copy constructor.
- For a scalar type, use built-in assignment.

This patch fixes at least a few tests cases in Boost.Spirit that were
failing because CodeGen picked the wrong copy-assignment operator
(leading to link-time failures), and I suspect a number of undiagnosed
problems will also go away with this change.

Some of the diagnostics we had previously have gotten worse with this
change, since we're going through generic code for our
type-checking. I will improve this in a subsequent patch.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102853 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-default-assignment-operator.cpp
c0c8300329718b45df259c49310d3c2b377a6e0f 30-Apr-2010 Douglas Gregor <dgregor@apple.com> After substituting a template argument for a non-type template
parameter with pointer-to-member type, we may have to perform a
qualification conversion, since the pointee type of the parameter
might be more qualified than the pointee type of the argument we form
from the declaration. Fixes PR6986.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102777 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-non-type-template-parameter.cpp
895162da2d52f4243f61081d7436de66af4503fc 30-Apr-2010 Douglas Gregor <dgregor@apple.com> Clean up our handling of local instantiation scopes, which keep track
of the mapping from local declarations to their instantiated
counterparts during template instantiation. Previously, we tried to do
some unholy merging of local instantiation scopes that involved
storing a single hash table along with an "undo" list on the
side... which was ugly, and never handled function parameters
properly.

Now, we just keep separate hash tables for each local instantiation
scope, and "combining" two scopes means that we'll look in each of the
combined hash tables. The combined scope stack is rarely deep, and
this makes it easy to avoid the "undo" issues we were hitting. Also,
I've simplified the logic for function parameters: if we're declaring
a function and we need the function parameters to live longer, we just
push them back into the local instantiation scope where we need them.

Fixes PR6990.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102732 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-function-params.cpp
9ffce2182e4fe72052d620698d272207f494b1cf 30-Apr-2010 Douglas Gregor <dgregor@apple.com> When we start the definition of a class template, set the
InjectedClassNameType's Decl to point at the definition. It's a little
messy, but we do the same thing with classes and their record types,
since much of Clang expects that the TagDecl* one gets out of a type
is the definition. Fixes several Boost.Proto failures.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102691 91177308-0d34-0410-b5e6-96231b3b80d8
njected-class-name.cpp
63b4385822857374d035128dff3feac131465496 30-Apr-2010 John McCall <rjmccall@apple.com> Rebuild the nested name specifiers in member-pointer declarator chunks when
entering the current instantiation. Set up a little to preserve type location
information for typename types while we're in there.

Fixes a Boost failure.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102673 91177308-0d34-0410-b5e6-96231b3b80d8
ested-name-spec-template.cpp
ypename-specifier-4.cpp
77e2c67411084c47b1cf511a191b31adf38662ba 29-Apr-2010 Douglas Gregor <dgregor@apple.com> It turns out that we *can* end up having to display template argument
bindings when the template argument is still an expression; it happens
while checking the template arguments of a class template partial
specializations. Fixes PR6964.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102595 91177308-0d34-0410-b5e6-96231b3b80d8
emp_arg_nontype.cpp
29d2fd56b5eeeb52f7fdbdd232229e570c30d62b 29-Apr-2010 Douglas Gregor <dgregor@apple.com> Fix template instantiation for __builtin_offfsetof expressions that refer to members of anonymous structs/unions

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102551 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-5.cpp
8ecdb65716cd7914ffb2eeee993fa9039fcd31e8 29-Apr-2010 Douglas Gregor <dgregor@apple.com> Completely reimplement __builtin_offsetof, based on a patch by Roberto
Amadini.

This change introduces a new expression node type, OffsetOfExpr, that
describes __builtin_offsetof. Previously, __builtin_offsetof was
implemented using a unary operator whose subexpression involved
various synthesized array-subscript and member-reference expressions,
which was ugly and made it very hard to instantiate as a
template. OffsetOfExpr represents the AST more faithfully, with proper
type source information and a more compact representation.

OffsetOfExpr also has support for dependent __builtin_offsetof
expressions; it can be value-dependent, but will never be
type-dependent (like sizeof or alignof). This commit introduces
template instantiation for __builtin_offsetof as well.

There are two major caveats to this patch:

1) CodeGen cannot handle the case where __builtin_offsetof is not a
constant expression, so it produces an error. So, to avoid
regressing in C, we retain the old UnaryOperator-based
__builtin_offsetof implementation in C while using the shiny new
OffsetOfExpr implementation in C++. The old implementation can go
away once we have proper CodeGen support for this case, which we
expect won't cause much trouble in C++.

2) __builtin_offsetof doesn't work well with non-POD class types,
particularly when the designated field is found within a base
class. I will address this in a subsequent patch.

Fixes PR5880 and a bunch of assertions when building Boost.Python
tests.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102542 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-5.cpp
e6ec5c42047c717014f7490bb9697945ae7a9d5b 28-Apr-2010 Douglas Gregor <dgregor@apple.com> When the qualifier of a id-expression is non-dependent but not
complete, return an error rather than falling back to building a
dependent declaration reference, since we might not be in a dependent
context. Fixes a fiendish crash-on-invalid in Boost.FunctionTypes that
I wasn't able to reduce to anything useful.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102491 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-function-params.cpp
d4598a2cc7576c06f69d3cf64d0e2c9783ddf529 28-Apr-2010 Douglas Gregor <dgregor@apple.com> When instantiating a function template specialization following
template argument deduction, use the lexical declaration context as
the owner for friend function templates. Fixes 2 failures in
Boost.Graph.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102489 91177308-0d34-0410-b5e6-96231b3b80d8
riend-template.cpp
66c45154186b7786d5dca645d548d73c47cf5d87 27-Apr-2010 Douglas Gregor <dgregor@apple.com> When instantiating UnresolvedLookupExpr and UnresolvedMemberExpr
expressions, be sure to set the naming class of the LookupResult
structure. Fixes PR6947.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102434 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-method.cpp
110acc1ae8d978f9b423394eaf0cace61b1339f0 27-Apr-2010 John McCall <rjmccall@apple.com> Improve the diagnostic you get when making a qualified member access
with a qualifier referencing a different type.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102409 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-member-expr.cpp
31f17ecbef57b5679c017c375db330546b7b5145 27-Apr-2010 John McCall <rjmccall@apple.com> Make the InjectedClassNameType the canonical type of the current instantiation
of a class template or class template partial specialization. That is to
say, in
template <class T> class A { ... };
or
template <class T> class B<const T*> { ... };
make 'A<T>' and 'B<const T*>' sugar for the corresponding InjectedClassNameType
when written inside the appropriate context. This allows us to track the
current instantiation appropriately even inside AST routines. It also allows
us to compute a DeclContext for a type much more efficiently, at some extra
cost every time we write a template specialization (which can be optimized,
but I've left it simple in this patch).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102407 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-member-expr.cpp
087fb7d0b5e08f34b2e28a09c376f66449f30886 26-Apr-2010 Douglas Gregor <dgregor@apple.com> Ensure that we have completed a type before attempting initialization
on that type. Fixes several problems in Boost.Interprocess.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102339 91177308-0d34-0410-b5e6-96231b3b80d8
efault-expr-arguments.cpp
f86fcb341116e72c5497e6b57695f46eca5f29e9 24-Apr-2010 Douglas Gregor <dgregor@apple.com> When we attempt to create a temporary object of class type, be sure
that the type we're copying is complete.

Boost.Regex now builds, although it's failing its regression tests
with our favorite "Sema doesn't consider destructor as used."
assertion.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102271 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-complete.cpp
77c13e07314422c6e76eda1bd1c7d83181b7e526 24-Apr-2010 Douglas Gregor <dgregor@apple.com> When we take the address of a declaration to bind it to a non-type
template parameter, by sure to mark that declaration as
"referenced". The Boost.Iterator library now passes all tests.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102256 91177308-0d34-0410-b5e6-96231b3b80d8
emp_arg_nontype.cpp
c70e93c8b1e9dc566bb9a31951c21de7a166d4ac 24-Apr-2010 Douglas Gregor <dgregor@apple.com> Tweak test case slightly

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102248 91177308-0d34-0410-b5e6-96231b3b80d8
laborated-type-specifier.cpp
48c89f4aa708e28310cb0c94b2d9d044b0ab806c 24-Apr-2010 Douglas Gregor <dgregor@apple.com> Be more careful around dependent nested-name-specifiers, complaining
when they are not complete (since we could not match them up to
anything) and ensuring that enum parsing can cope with dependent
elaborated-type-specifiers. Fixes PR6915 and PR6649.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102247 91177308-0d34-0410-b5e6-96231b3b80d8
laborated-type-specifier.cpp
d57a38ee02c285d69d05fed6df0d7406b2517888 23-Apr-2010 Douglas Gregor <dgregor@apple.com> When instantiating a typedef of an anonymous tag type, note in the tag
declaration that this typedef gives the tag a name. Fixes a problem
uncovered by Boost.GIL (Generic Image Library).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102180 91177308-0d34-0410-b5e6-96231b3b80d8
emp_arg_type.cpp
20b3c9dda95e6808865110a21bfec25f95ebcaa7 23-Apr-2010 Douglas Gregor <dgregor@apple.com> Strip cv-qualifiers when building C++ constructor and destructor
names.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102171 91177308-0d34-0410-b5e6-96231b3b80d8
estructor-template.cpp
a41a8c5972c2632247ae7913cf6ce65d45f7e702 22-Apr-2010 Douglas Gregor <dgregor@apple.com> Whenever we complain about a failed initialization of a function or
method parameter, provide a note pointing at the parameter itself so
the user does not have to manually look for the function/method being
called and match up parameters to arguments. For example, we now get:

t.c:4:5: warning: incompatible pointer types passing 'long *' to
parameter of
type 'int *' [-pedantic]
f(long_ptr);
^~~~~~~~
t.c:1:13: note: passing argument to parameter 'x' here
void f(int *x);
^



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102038 91177308-0d34-0410-b5e6-96231b3b80d8
efault-expr-arguments.cpp
nstantiate-member-template.cpp
3fb53bd53037872040396225736914fcb75c1fec 21-Apr-2010 Douglas Gregor <dgregor@apple.com> Reword the note we emit when suppressing template instantiation contexts, per John's advice

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101988 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiation-depth.cpp
575cf3791216c33770ba950430493cdd43099f8f 20-Apr-2010 Douglas Gregor <dgregor@apple.com> Introduce a limit on the depth of the template instantiation backtrace
we will print with each error that occurs during template
instantiation. When the backtrace is longer than that, we will print
N/2 of the innermost backtrace entries and N/2 of the outermost
backtrace entries, then skip the middle entries with a note such as:

note: suppressed 2 template instantiation contexts; use
-ftemplate-backtrace-limit=N to change the number of template
instantiation entries shown

This should eliminate some excessively long backtraces that aren't
providing any value.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101882 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiation-depth.cpp
3fbaf3e5d524bfff219d1e3e9ac4801a8411590f 18-Apr-2010 Douglas Gregor <dgregor@apple.com> Improve our handling of user-defined conversions as part of overload
resolution. There are two sources of problems involving user-defined
conversions that this change eliminates, along with providing simpler
interfaces for checking implicit conversions:

- It eliminates a case of infinite recursion found in Boost.

- It eliminates the search for the constructor needed to copy a temporary
generated by an implicit conversion from overload
resolution. Overload resolution assumes that, if it gets a value
of the parameter's class type (or a derived class thereof), there
is a way to copy if... even if there isn't. We now model this
properly.




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101680 91177308-0d34-0410-b5e6-96231b3b80d8
onstructor-template.cpp
d6e44a3c4193bd422bfa78c8086fb16bb2168e34 17-Apr-2010 Douglas Gregor <dgregor@apple.com> Collapse the three separate initialization paths in
TryStaticImplicitCast (for references, class types, and everything
else, respectively) into a single invocation of
InitializationSequence.

One of the paths (for class types) was the only client of
Sema::TryInitializationByConstructor, which I have eliminated. This
also simplified the interface for much of the cast-checking logic,
eliminating yet more code.

I've kept the representation of C++ functional casts with <> 1
arguments the same, despite the fact that I hate it. That fix will
come soon. To satisfy my paranoia, I've bootstrapped + tested Clang
with these changes.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101549 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-2.cpp
1a8cf73a825ef35917eede448817237b5fd47b05 15-Apr-2010 Douglas Gregor <dgregor@apple.com> Always diagnose and complain about problems in
ResolveAddressOfOverloadedFunction when asked to complain. Previously,
we had some weird handshake where ResolveAddressOfOverloadedFunction
expected its caller to handle some of the diagnostics but not others,
and yet there was no way for the caller to know which case we were
in. Eliminate this madness, fixing <rdar://problem/7765884>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101312 91177308-0d34-0410-b5e6-96231b3b80d8
emp_arg_nontype.cpp
f19de1ce44b9c7ffdeb388d6fe2fa8a1d0288f64 14-Apr-2010 John McCall <rjmccall@apple.com> Mark a function declaration invalid if any of its parameter declarations
are invalid. Prevents a crash-on-invalid during template instantiation.
I... really don't understand how this wasn't already present.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101203 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-method.cpp
57265e35292897e383d70bbd1d552209fac37b39 12-Apr-2010 Douglas Gregor <dgregor@apple.com> Fix a crash-on-invalid involving name lookup of tag names, where we
ended up finding a function template that we didn't expect. Recover
more gracefully, and fix a similar issue for class templates.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101040 91177308-0d34-0410-b5e6-96231b3b80d8
lass-template-decl.cpp
riend.cpp
cb27b0f70d2017295776afafe3616e0bcd74ab51 12-Apr-2010 Douglas Gregor <dgregor@apple.com> Be sure to instantiate the parameters of a function, even when the
function's type is (strictly speaking) non-dependent. This ensures
that, e.g., default function arguments get instantiated properly.

And, since I couldn't resist, collapse the two implementations of
function-parameter instantiation into calls to a single, new function
(Sema::SubstParmVarDecl), since the two had nearly identical code (and
each had bugs the other didn't!). More importantly, factored out the
semantic analysis of a parameter declaration into
Sema::CheckParameter, which is called both by
Sema::ActOnParamDeclarator (when parameters are parsed) and when a
parameter is instantiated. Previously, we were missing some
Objective-C and address-space checks on instantiated function
parameters.

Fixes PR6733.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101029 91177308-0d34-0410-b5e6-96231b3b80d8
efault-expr-arguments-2.cpp
nstantiate-method.cpp
59fc2690e622e9db7f7a8f5036562b19d3bfb2b5 10-Apr-2010 Sebastian Redl <sebastian.redl@getdesigned.at> When a member pointer is dereferenced, the class it points into must be complete. Enforce this.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100925 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-complete.cpp
d6ca8da0f5a4115813055729faaa5128e994806d 10-Apr-2010 John McCall <rjmccall@apple.com> Diagnose misordered initializers in constructor templates immediately instead of
when they're instantiated. Merge the note into the -Wreorder warning; it
doesn't really contribute much, and it was splitting a thought across diagnostics
anyway. Don't crash in the parser when a constructor's initializers end in a
comma and there's no body; the recovery here is still terrible, but anything's
better than a crash.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100922 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-member-initializers.cpp
7002f4c03c2d0544f4e8bea8d3a5636519081e35 09-Apr-2010 John McCall <rjmccall@apple.com> Turn access control on by default in -cc1.
Remove -faccess-control from -cc1; add -fno-access-control.
Make the driver pass -fno-access-control by default.
Update a bunch of tests to be correct under access control.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100880 91177308-0d34-0410-b5e6-96231b3b80d8
ependent-names.cpp
nstantiate-local-class.cpp
nstantiate-member-class.cpp
nstantiate-member-initializers.cpp
nstantiate-using-decl.cpp
ualified-id.cpp
d4eea8362605807327735727a9098abe1eb23b19 09-Apr-2010 Douglas Gregor <dgregor@apple.com> Improve diagnostics when we fail to convert from a source type to a
destination type for initialization, assignment, parameter-passing,
etc. The main issue fixed here is that we used rather confusing
wording for diagnostics such as

t.c:2:9: warning: initializing 'char const [2]' discards qualifiers,
expected 'char *' [-pedantic]
char *name = __func__;
^ ~~~~~~~~

We're not initializing a 'char const [2]', we're initializing a 'char
*' with an expression of type 'char const [2]'. Similar problems
existed for other diagnostics in this area, so I've normalized them all
with more precise descriptive text to say what we're
initializing/converting/assigning/etc. from and to. The warning for
the code above is now:

t.c:2:9: warning: initializing 'char *' from an expression of type
'char const [2]' discards qualifiers [-pedantic]
char *name = __func__;
^ ~~~~~~~~

Fixes <rdar://problem/7447179>.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100832 91177308-0d34-0410-b5e6-96231b3b80d8
un-template-def.cpp
nstantiate-member-class.cpp
cb821d045f5e445384f34d05a526955036073c4a 08-Apr-2010 Douglas Gregor <dgregor@apple.com> Downgrade the "declaration does not declare anything" error to a
warning. It's not harmful to have such pointless declarations, and GCC
does not diagnose this issue consistently.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100814 91177308-0d34-0410-b5e6-96231b3b80d8
emplate-decl-fail.cpp
c173be2aa78cecc6c35445165e59df99d754a1e0 08-Apr-2010 Jeffrey Yasskin <jyasskin@google.com> Explain that a template needs arguments to make it into a type, for
variable declarations.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100809 91177308-0d34-0410-b5e6-96231b3b80d8
emp_arg.cpp
9ab14541716928894821cf5d53d6b4c95ffdf3a3 08-Apr-2010 Jeffrey Yasskin <jyasskin@google.com> Make CXXScopeSpec invalid when incomplete, and propagate that into any
Declarator that depends on it. This fixes several redundant errors and bad
recoveries.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100779 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-function-params.cpp
nstantiate-typedef.cpp
ypename-specifier.cpp
db88d8ad74097e2601d81ee863ce46a8a48a7034 08-Apr-2010 Jeffrey Yasskin <jyasskin@google.com> When a template (without arguments) is passed as a template type
parameter, explicitly ask the user to give it arguments. We used to
complain that it wasn't a type and expect the user to figure it out.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100729 91177308-0d34-0410-b5e6-96231b3b80d8
emp_arg_type.cpp
edc287751a4b05e3b4d8ff2b38fa30c5b59a548b 08-Apr-2010 Jeffrey Yasskin <jyasskin@google.com> Fix some redundant errors by changing CXXScopeSpec::isSet calls into
isNotEmpty calls.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100722 91177308-0d34-0410-b5e6-96231b3b80d8
xplicit-specialization-member.cpp
bcc12fdaa7b3276b46c8e1349d5c99fd42d6a0a1 02-Apr-2010 Anders Carlsson <andersca@mac.com> If a constructor is a dependent context, just set the base and member initializers as they are written. Fixes a bug where we wouldn't show initialization order warnings when instantiating.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100180 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-member-initializers.cpp
b7a09260204f2079e0f998bf7ee52b95122a4c5d 01-Apr-2010 Douglas Gregor <dgregor@apple.com> Overhaul checking of non-type template arguments that should refer to
an object or function. Our previous checking was too lax, and ended up
allowing missing or extraneous address-of operators, among other
evils. The new checking provides better diagnostics and adheres more
closely to the standard.

Fixes PR6563 and PR6749.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100125 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiation-default-2.cpp
emp_arg_nontype.cpp
1eabb7d0c30f6a876b0fd03ad4656c096c26b8d0 01-Apr-2010 Douglas Gregor <dgregor@apple.com> Improve diagnostics when an elaborated-type-specifer containing a
nested-name-specifier (e.g., "class T::foo") fails to find a tag
member in the scope nominated by the
nested-name-specifier. Previously, we gave a bland

error: 'Nested' does not name a tag member in the specified scope

which didn't actually say where we were looking, which was rather
horrible when the nested-name-specifier was instantiated. Now, we give
something a bit better:

error: no class named 'Nested' in 'NoDepBase<T>'




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100060 91177308-0d34-0410-b5e6-96231b3b80d8
ependent-base-classes.cpp
nstantiate-declref.cpp
4033642464e8ba0982f88f34cffad808d247b393 01-Apr-2010 Douglas Gregor <dgregor@apple.com> Change the representation of dependent elaborated-type-specifiers
(such as "class T::foo") from an ElaboratedType of a TypenameType to a
DependentNameType, which more accurately models the underlying
concept.

Improve template instantiation for DependentNameType nodes that
represent nested-name-specifiers, by performing tag name lookup and
checking the resulting tag appropriately. Fixes PR5681.

There is still much testing and cleanup to do in this area.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100054 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-elab-type-specifier.cpp
a3ce8ae36144991fa125dafc5345a03cc875e503 31-Mar-2010 Chandler Carruth <chandlerc@gmail.com> Re-bind non-dependent CXXTemporaryObjectExpr nodes as temporaries when
instantiating a template, which ensures the destructor is called. This fixes
PR6671.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100029 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-4.cpp
5e40291d13ed2d7711235df947a2a18a925c7536 30-Mar-2010 Douglas Gregor <dgregor@apple.com> Improve diagnostics when printing a template instantiation backtrace
involving substitution of deduced template arguments into a class
template partial specialization or function template, or when
substituting explicitly-specific template arguments into a function
template. We now print the actual deduced argument bindings so the
user can see what got deduced.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99923 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-function-params.cpp
02024a9f0d8e6c898de276193af604c42ee41269 28-Mar-2010 Douglas Gregor <dgregor@apple.com> After performing template argument deduction for a function template,
check deduced non-type template arguments and template template
arguments against the template parameters for which they were deduced,
performing conversions as appropriate so that deduced template
arguments get the same treatment as explicitly-specified template
arguments. This is the bulk of PR6723.

Also keep track of whether deduction of a non-type template argument
came from an array bound (vs. anywhere else). With this information,
we enforce C++ [temp.deduct.type]p17, which requires exact type
matches when deduction deduces a non-type template argument from
something that is not an array bound.

Finally, when in a SFINAE context, translate the "zero sized
arrays are an extension" extension diagnostic into a hard error (for
better standard conformance), which was a minor part of PR6723.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99734 91177308-0d34-0410-b5e6-96231b3b80d8
emp_arg_nontype.cpp
2243288c4826905b5a0837f6f21d9d821688652e 26-Mar-2010 John McCall <rjmccall@apple.com> Properly account for redeclarations when explicitly instantiating class templates.
What happens here is that we actually turn the first declaration into a
definition, regardless of whether it was actually originally a definition,
and furthermore we do this all after we've instantiated all the declarations.
This exposes a bug in my DefinitionData patch where it was only setting the
DefinitionData for previous declarations, not future declarations.
Fortunately, there's an iterator for that.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99657 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-member-class.cpp
1a6e03457ebafd6ac523cdcf5d6b6f411ea08772 26-Mar-2010 Douglas Gregor <dgregor@apple.com> Reinstate change to non-type template arguments of integral type, so
that we extend/truncate then correct the sign to convert the non-type
template argument to the template parameter's type. Previously, we
reported an error when the non-type template argument was out of
range; now we just warn.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99600 91177308-0d34-0410-b5e6-96231b3b80d8
emp_arg_nontype.cpp
0d4fd8ef35ecd73ce6388cb5a6fdcfb15171f5aa 26-Mar-2010 Douglas Gregor <dgregor@apple.com> Revert attempted fix for integral template arguments. It seems to have broken tramp3d-v4.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99583 91177308-0d34-0410-b5e6-96231b3b80d8
emp_arg_nontype.cpp
684d096c204c5eef29c10777bce890400d235d8c 25-Mar-2010 Douglas Gregor <dgregor@apple.com> Warn when the conversion of an integral non-type template argument to
the type of its corresponding non-type template parameter changes the
value. Previously, we were diagnosing this as an error, which was
wrong. We give reasonably nice warnings like:

test/SemaTemplate/temp_arg_nontype.cpp:100:10: warning: non-type template
argument value '256' truncated to '0' for template parameter of type
'unsigned char'
Overflow<256> *overflow3; // expected-warning{{non-type template ...
^~~
test/SemaTemplate/temp_arg_nontype.cpp:96:24: note: template parameter is
declared here
template<unsigned char C> struct Overflow;
^



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99561 91177308-0d34-0410-b5e6-96231b3b80d8
emp_arg_nontype.cpp
479be1af979367d64963afb35c3547f6edad9c83 25-Mar-2010 Douglas Gregor <dgregor@apple.com> Add another test for weird substitutions into function types during template argument deduction

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99510 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-function-params.cpp
2b0749a4f8965d0205bf77322db150c13c39e3be 25-Mar-2010 Douglas Gregor <dgregor@apple.com> Improve our handling of local instantiation scopes in two related ways:

- When substituting template arguments as part of template argument
deduction, introduce a new local instantiation scope.
- When substituting into a function prototype type, introduce a new
"temporary" local instantiation scope that merges with its outer
scope but also keeps track of any additions it makes, removing
them when we exit that scope.

Fixes PR6700, where we were getting too much mixing of local
instantiation scopes due to template argument deduction that
substituted results into function types.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99509 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-function-params.cpp
93ba8579c341d5329175f1413cdc3b35a36592d2 25-Mar-2010 John McCall <rjmccall@apple.com> Properly instantiate friend class template declarations and link them into
the redeclaration chain. Recommitted from r99477 with a fix: we need to
merge in default template arguments from previous declarations.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99496 91177308-0d34-0410-b5e6-96231b3b80d8
riend-template.cpp
e131c574c7baa28eb0759181478d710a2aa60cb6 25-Mar-2010 Bob Wilson <bob.wilson@apple.com> Revert 99477 since it appears to be breaking the clang-x86_64-darwin10-fnt
buildbot. The tramp3d test fails.
--- Reverse-merging r99477 into '.':
U test/SemaTemplate/friend-template.cpp
U test/CXX/temp/temp.decls/temp.friend/p1.cpp
U lib/Sema/SemaTemplateInstantiateDecl.cpp
U lib/Sema/SemaAccess.cpp


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99481 91177308-0d34-0410-b5e6-96231b3b80d8
riend-template.cpp
a56623b01ed9f28f10416432d147c7a1729d5f1d 25-Mar-2010 John McCall <rjmccall@apple.com> Properly instantiate and link in friend-class-template declarations.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99477 91177308-0d34-0410-b5e6-96231b3b80d8
riend-template.cpp
28329e511854fdd3b31561b2690f91f9e6a6402e 24-Mar-2010 Douglas Gregor <dgregor@apple.com> When pulling apart an initializer that involves a CXXConstructExpr, do
not pick apart a CXXTemporaryObjectExpr because such an object
construction was explicitly written in the source code. Fixes PR6657.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99427 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-init.cpp
05030bb6790b259a169b25665656db2aee30ccda 24-Mar-2010 Douglas Gregor <dgregor@apple.com> Each non-local class instantiation is its own local instantiation
scope. Fixes PR6619.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99377 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-function-params.cpp
6c790eac94101407acfd2c664400924cab45c0b1 16-Mar-2010 John McCall <rjmccall@apple.com> Perform access control even for the implicit destructor calls from implicit
destructor definitions. Remove some code duplication.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98611 91177308-0d34-0410-b5e6-96231b3b80d8
irtual-member-functions.cpp
069ace5adc444a159003c29e85e166cee491ad39 11-Mar-2010 John McCall <rjmccall@apple.com> Fix a self-host problem caused by this over-eager assertion. I'm not sure
there's a good equivalent that's actually true, unfortunately.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98253 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-function-1.cpp
7c2342dd4c9947806842e5aca3d2bb2e542853c9 10-Mar-2010 John McCall <rjmccall@apple.com> When pretty-printing tag types, only print the tag if we're in C (and
therefore not creating ElaboratedTypes, which are still pretty-printed
with the written tag).

Most of these testcase changes were done by script, so don't feel too
sorry for my fingers.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98149 91177308-0d34-0410-b5e6-96231b3b80d8
lass-template-id-2.cpp
lass-template-spec.cpp
efault-expr-arguments.cpp
ependent-base-classes.cpp
xt-vector-type.cpp
nstantiate-cast.cpp
nstantiate-complete.cpp
nstantiate-exception-spec.cpp
nstantiate-expr-1.cpp
nstantiate-expr-4.cpp
nstantiate-field.cpp
nstantiate-member-class.cpp
nstantiate-member-expr.cpp
nstantiate-method.cpp
nstantiate-static-var.cpp
nstantiate-typedef.cpp
nstantiation-backtrace.cpp
nstantiation-default-1.cpp
etafun-apply.cpp
emp_arg_nontype.cpp
emp_arg_type.cpp
ypename-specifier.cpp
3cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4 10-Mar-2010 John McCall <rjmccall@apple.com> Create a new InjectedClassNameType to represent bare-word references to the
injected class name of a class template or class template partial specialization.
This is a non-canonical type; the canonical type is still a template
specialization type. This becomes the TypeForDecl of the pattern declaration,
which cleans up some amount of code (and complicates some other parts, but
whatever).

Fixes PR6326 and probably a few others, primarily by re-establishing a few
invariants about TypeLoc sizes.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98134 91177308-0d34-0410-b5e6-96231b3b80d8
njected-class-name.cpp
nstantiation-default-1.cpp
bbf58bb1b8dd8c5e0f07547a6c20ffd55385fcf6 10-Mar-2010 Rafael Espindola <rafael.espindola@gmail.com> Delay codegen of vtables when handling implicit instantiations.

This fixes PR6474.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98123 91177308-0d34-0410-b5e6-96231b3b80d8
irtual-member-functions.cpp
a2762918ecc636c9af207ce2a9ce705edad2a444 08-Mar-2010 Douglas Gregor <dgregor@apple.com> Downgrade errors when trying to catch a pointer or reference to
incomplete type to warnings; GCC (and EDG in GCC compatibility mode)
permit such handles. Fixes PR6527.

(For real this time)


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97927 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-function-1.cpp
3604160c2c791e043d22ed6d09b7835fc06c4e68 08-Mar-2010 Chandler Carruth <chandlerc@gmail.com> Revert r97925, it only contained the test updates not the actual fix.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97926 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-function-1.cpp
d7bf93c190e62d7714827ba255393e143e2c9a81 08-Mar-2010 Douglas Gregor <dgregor@apple.com> Downgrade errors when trying to catch a pointer or reference to
incomplete type to warnings; GCC (and EDG in GCC compatibility mode)
permit such handles. Fixes PR6527.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97925 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-function-1.cpp
a50ce325b1ddd2bcbbfc1082ac93f3861d0a3a3d 08-Mar-2010 Douglas Gregor <dgregor@apple.com> Robustify callers that rebuild typename type nodes again NULL return
types. Fixes PR6463.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97924 91177308-0d34-0410-b5e6-96231b3b80d8
ypename-specifier-4.cpp
7b9a5aa7c0d76f577699d25ce6afe21ecccb60b7 02-Mar-2010 Rafael Espindola <rafael.espindola@gmail.com> During codegen assert that any copy assignment, destructor or constructor that
we need to synthesize has been marked as used by Sema.

Change Sema to avoid these asserts.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97589 91177308-0d34-0410-b5e6-96231b3b80d8
irtual-member-functions.cpp
9b9edd619a7e616d3287435cb5a3f9b1aea648e8 02-Mar-2010 Douglas Gregor <dgregor@apple.com> Diagnose the declaration of enum templates. Also, be a bit more
careful about value-dependent enumerators. Fixes PR5786.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97570 91177308-0d34-0410-b5e6-96231b3b80d8
emplate-decl-fail.cpp
91be6f5ccbde073e592bed9a3e3bc363957714fb 02-Mar-2010 Douglas Gregor <dgregor@apple.com> Use CXXTemporaryObjectExpr for explicitly-constructed temporaries. We
used to do this, but it got lost when we switched functional-style
cast syntax over to using the new initialization code. Fixes PR6457.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97568 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-init.cpp
bbbd54e97944e88396061ff104564f155c122988 02-Mar-2010 Douglas Gregor <dgregor@apple.com> Add test case from PR5812, which works now.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97535 91177308-0d34-0410-b5e6-96231b3b80d8
ependent-base-classes.cpp
632c9d26925f9aa8179607956c83ee348930b6d7 01-Mar-2010 Chris Lattner <sabre@nondot.org> avoid issues with the new scope protector. Previously we'd error
with "address taken of label in protected scope, jump to it would have unknown effect on scope"




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97495 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-function-1.cpp
449d0a829007ea654912098e6a73134a2c529d61 01-Mar-2010 Douglas Gregor <dgregor@apple.com> When looking for a redeclaration of a static variable, only look for redeclarations. Fixes PR6449

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97478 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-static-var.cpp
96084f171f4824397dc48453146f0a9719cb9247 01-Mar-2010 Douglas Gregor <dgregor@apple.com> When instantiating a function-scoped enum, make sure that it and its
enumeration constants get placed into the local instantiation hash
table. Fixes PR6375.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97471 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-enum.cpp
00225547b51b42f7400eed36475b6672418a1151 01-Mar-2010 Douglas Gregor <dgregor@apple.com> Robustify instantiation of templates when there are errors in the
template definition. Do this both by being more tolerant of errors in
our asserts and by not dropping a variable declaration completely when
its initializer is ill-formed. Fixes the crash-on-invalid in PR6375,
but not the original issue.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97463 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-invalid.cpp
7c1e98f1cb37b40e619a0c8aee8b337f037b432b 01-Mar-2010 Douglas Gregor <dgregor@apple.com> When looking for the instantiated declaration that corresponds to a
given declaration in a template, make sure that the context we're
searching through is complete. Fixes PR6376.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97444 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-complete.cpp
5fe8c04009eff540ebaa0cceb2e75c3908322e11 27-Feb-2010 Douglas Gregor <dgregor@apple.com> Skip dependent virtual base classes; fixes PR6413.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97291 91177308-0d34-0410-b5e6-96231b3b80d8
ependent-base-classes.cpp
9ba6166f4a78722e7df8ffbd64eb788bfdf2764a 26-Feb-2010 John McCall <rjmccall@apple.com> Fix an assertion-on-error during tentative constructor parsing by
propagating error conditions out of the various annotate-me-a-snowflake
routines. Generally (but not universally) removes redundant diagnostics
as well as, you know, not crashing on bad code. On the other hand,
I have just signed myself up to fix fiddly parser errors for the next
week. Again.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97221 91177308-0d34-0410-b5e6-96231b3b80d8
ependent-base-classes.cpp
xplicit-specialization-member.cpp
ested-name-spec-template.cpp
emp_arg.cpp
1af745143eb3066660d8855c17ccec6b38f5d789 26-Feb-2010 Douglas Gregor <dgregor@apple.com> Make sure to mark constructors, operator new, and operator delete as
used when we instantiate C++ new expressions, delete expressions, and
object-construction expressions. Fixes PR6424, although we can't test
all of it until we finish implementing lookup of "operator delete" for
new expressions (!).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97195 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-1.cpp
c845aad6f7d012ab0cd0a040515ab512d1a93566 26-Feb-2010 Douglas Gregor <dgregor@apple.com> When we decide to re-use an existing CXXConstructExpr node, make sure
to mark the constructor as referenced. Fixes the narrow issue reported
in PR6424, but there are a few other places that I'll fix before
closing out that PR.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97185 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-1.cpp
a2e7dd2f4a50d835351153aee568d35ccc986310 25-Feb-2010 Douglas Gregor <dgregor@apple.com> Use CXXPseudoDestructorExpr as the stored representation for dependent
expressions that look like pseudo-destructors, e.g.,

p->T::~T()

where p has dependent type.

At template instantiate time, we determine whether we actually have a
pseudo-destructor or a member access, and funnel down to the
appropriate routine in Sema.

Fixes PR6380.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97092 91177308-0d34-0410-b5e6-96231b3b80d8
estructor-template.cpp
ember-access-expr.cpp
2fa98001f832836e3f652c211a9d2f80501d659a 16-Feb-2010 Douglas Gregor <dgregor@apple.com> Do not try to instantiate invalid declarations. It's a recipe for
disaster. Fixes PR6161.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96371 91177308-0d34-0410-b5e6-96231b3b80d8
xplicit-specialization-member.cpp
124b878dba5007df0a268ea128a6ad8dc5dd2c5e 16-Feb-2010 Douglas Gregor <dgregor@apple.com> Improve parsing and instantiation of destructor names, so that we can
now cope with the destruction of types named as dependent templates,
e.g.,

y->template Y<T>::~Y()

Nominally, we implement C++0x [basic.lookup.qual]p6. However, we don't
follow the letter of the standard here because that would fail to
parse

template<typename T, typename U>
X0<T, U>::~X0() { }

properly. The problem is captured in core issue 339, which gives some
(but not enough!) guidance. I expect to revisit this code when the
resolution of 339 is clear, and/or we start capturing better source
information for DeclarationNames.

Fixes PR6152.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96367 91177308-0d34-0410-b5e6-96231b3b80d8
estructor-template.cpp
17e0f407d56748da21050db13ff3a093b1ffdcb7 15-Feb-2010 Chandler Carruth <chandlerc@gmail.com> Fix instantiation of template functions with local classes that contain virtual
methods.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96283 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-local-class.cpp
291b441a095b289c30d9f311fe37a2cf5ed6fd45 13-Feb-2010 Chandler Carruth <chandlerc@gmail.com> Skip implicit instantiation of templated variables where a more recent
redeclaration provides an explicit instantiation or is invalid.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96097 91177308-0d34-0410-b5e6-96231b3b80d8
xplicit-instantiation.cpp
ae6288981b77d6230bf62055d3bb6380580aa1e8 13-Feb-2010 Douglas Gregor <dgregor@apple.com> Fix a fiendinshly fun little type-canonicalization bug, where we were
rebuilding a typename type terminating in a template-id (with
dependent template name, naturally) as a TypenameType when, because
its context could be fully resolved, we should have been building it
as a QualifiedNameType. Fixes PR6268.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96084 91177308-0d34-0410-b5e6-96231b3b80d8
ypename-specifier-4.cpp
60c93c9981c467738369702e7aa23fd58c2b6aac 09-Feb-2010 Douglas Gregor <dgregor@apple.com> Migrate the mish-mash of declaration checks in
Sema::ActOnUninitializedDecl over to InitializationSequence (with
default initialization), eliminating redundancy. More importantly, we
now check that a const definition in C++ has an initilizer, which was
an #if 0'd code for many, many months. A few other tweaks were needed
to get everything working again:

- Fix all of the places in the testsuite where we defined const
objects without initializers (now that we diagnose this issue)
- Teach instantiation of static data members to find the previous
declaration, so that we build proper redeclaration
chains. Previously, we had the redeclaration chain but built it
too late to be useful, because...
- Teach instantiation of static data member definitions not to try
to check an initializer if a previous declaration already had an
initializer. This makes sure that we don't complain about static
const data members with in-class initializers and out-of-line
definitions.
- Move all of the incomplete-type checking logic out of
Sema::FinalizeDeclaratorGroup; it makes more sense in
ActOnUnitializedDecl.

There may still be a few places where we can improve these
diagnostics. I'll address that as a separate commit.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95657 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-declref-ice.cpp
nstantiate-expr-4.cpp
de09096a9ee7f670dc74c6a5b7771953ffaf5c62 09-Feb-2010 Douglas Gregor <dgregor@apple.com> Implement a specific diagnostic when a class template partial
specialization does not use any of its template parameters, then
recover far more gracefully. Fixes PR6181.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95629 91177308-0d34-0410-b5e6-96231b3b80d8
emp_class_spec.cpp
a7ef13024e4cc3dfb75e3bc1695371b39d9a5240 07-Feb-2010 Chandler Carruth <chandlerc@gmail.com> Require a complete type before examining base classes during template argument
deduction. This requires refactoring the deduction to have access to the Sema
object instead of merely the ASTContext. Still leaves something to be desired
due to poor source location.

Fixes PR6257 and half of PR6259.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95528 91177308-0d34-0410-b5e6-96231b3b80d8
eduction.cpp
645cf44cc34371c808743e5e7c19bb41ff593ca0 06-Feb-2010 John McCall <rjmccall@apple.com> Use a substituted type when determining how to substitute in non-type template
params. Don't insert addrof operations when matching against a pointer;
array/function conversions should take care of this for us, assuming the
argument type-checked in the first place. Add a fixme where we seem to be
using a less-restrictive reference type than we should.

Fixes PR 6249.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95495 91177308-0d34-0410-b5e6-96231b3b80d8
emp_arg_nontype.cpp
68b6b87b6beb7922fc2c8ab923ba2ce125490363 06-Feb-2010 John McCall <rjmccall@apple.com> Teach Sema how to instantiate a local function declaration properly. Fixes
PR 5517.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95470 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-declref.cpp
8b013bdbf6474ed25d4017635cac851e51163c25 05-Feb-2010 Douglas Gregor <dgregor@apple.com> Cope with finding the "instantiated" declaration when we are
type-checking within a template definition. In this case, the
"instantiated" declaration is just the declaration itself, found
within the current instantiation. Fixes PR6239.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95442 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-member-template.cpp
6d3e627dacdb2f749195635ab587fd067ef813e1 05-Feb-2010 Douglas Gregor <dgregor@apple.com> Fix two issues with the substitution of template template parameters
when instantiating the declaration of a member template:
- Only check if the have a template template argument at a specific position
when we already know that we have template arguments at that level;
otherwise, we're substituting for a level-reduced template template
parameter.
- When trying to find an instantiated declaration for a template
template parameter, look into the instantiated scope. This was a
typo, where we had two checks for TemplateTypeParmDecl, one of
which should have been a TemplateTemplateParmDecl.

With these changes, tramp3d-v4 passes -fsyntax-only.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95421 91177308-0d34-0410-b5e6-96231b3b80d8
ember-function-template.cpp
ae4c77dc8a77ee89e5b2de8003283249e38075c3 05-Feb-2010 Douglas Gregor <dgregor@apple.com> When we're parsing an expression that may have looked like a
declaration, we can end up with template-id annotation tokens for
types that have not been converted into type annotation tokens. When
this is the case, translate the template-id into a type and parse as
an expression.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95404 91177308-0d34-0410-b5e6-96231b3b80d8
emplate-id-expr.cpp
67fa05b9ed29923b7b905a09cfb95c2ac91b5835 05-Feb-2010 Douglas Gregor <dgregor@apple.com> A dependent initializer with zero arguments should return a NULL
initializer (for no initialization) rather than a ParenListExpr with
zero arguments in it.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95382 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-decl-init.cpp
525f96c0ef39f91abd26b1b4584ba1814e7ebc28 05-Feb-2010 Douglas Gregor <dgregor@apple.com> Default function arguments for function template specializations
always come from the primary template, so gather the instantiation
template arguments from the primary template.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95380 91177308-0d34-0410-b5e6-96231b3b80d8
efault-expr-arguments.cpp
dc81c880cad01f01888632d28345077336ca06a4 05-Feb-2010 Douglas Gregor <dgregor@apple.com> When adding ADL candidates for overloaded
post-increment/post-decrement operators, be sure to consider both
arguments. Fixes PR6237.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95361 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-1.cpp
a4e8c2a65a985782344a818d356c40d117fc4f12 05-Feb-2010 Douglas Gregor <dgregor@apple.com> When determining whether a scope specifier is complete, consider a
dependent DeclContext to be "complete". Fixes PR6236.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95359 91177308-0d34-0410-b5e6-96231b3b80d8
ypename-specifier-4.cpp
86a7625062abbd40fffa186f2f5d305cc89615b8 04-Feb-2010 Douglas Gregor <dgregor@apple.com> When substituting the template argument for a pointer non-type
template parameter, perform array/function decay (if needed), take the
address of the argument (if needed), perform qualification conversions
(if needed), and remove any top-level cv-qualifiers from the resulting
expression. Fixes PR6226.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95309 91177308-0d34-0410-b5e6-96231b3b80d8
emp_arg_nontype.cpp
0b6bc8bd7a1d2a7d7478d13d78cff94cacad61fc 03-Feb-2010 Douglas Gregor <dgregor@apple.com> When a function or variable somehow depends on a type or declaration
that is in an anonymous namespace, give that function or variable
internal linkage.

This change models an oddity of the C++ standard, where names declared
in an anonymous namespace have external linkage but, because anonymous
namespace are really "uniquely-named" namespaces, the names cannot be
referenced from other translation units. That means that they have
external linkage for semantic analysis, but the only sensible
implementation for code generation is to give them internal
linkage. We now model this notion via the UniqueExternalLinkage
linkage type. There are several changes here:

- Extended NamedDecl::getLinkage() to produce UniqueExternalLinkage
when the declaration is in an anonymous namespace.
- Added Type::getLinkage() to determine the linkage of a type, which
is defined as the minimum linkage of the types (when we're dealing
with a compound type that is not a struct/class/union).
- Extended NamedDecl::getLinkage() to consider the linkage of the
template arguments and template parameters of function template
specializations and class template specializations.
- Taught code generation to rely on NamedDecl::getLinkage() when
determining the linkage of variables and functions, also
considering the linkage of the types of those variables and
functions (C++ only). Map UniqueExternalLinkage to internal
linkage, taking out the explicit checks for
isInAnonymousNamespace().

This fixes much of PR5792, which, as discovered by Anders Carlsson, is
actually the reason behind the pass-manager assertion that causes the
majority of clang-on-clang regression test failures. With this fix,
Clang-built-Clang+LLVM passes 88% of its regression tests (up from
67%). The specific numbers are:

LLVM:
Expected Passes : 4006
Expected Failures : 32
Unsupported Tests : 40
Unexpected Failures: 736

Clang:
Expected Passes : 1903
Expected Failures : 14
Unexpected Failures: 75

Overall:
Expected Passes : 5909
Expected Failures : 46
Unsupported Tests : 40
Unexpected Failures: 811

Still to do:
- Improve testing
- Check whether we should allow the presence of types with
InternalLinkage (in addition to UniqueExternalLinkage) given
variables/functions internal linkage in C++, as mentioned in
PR5792.
- Determine how expensive the getLinkage() calls are in practice;
consider caching the result in NamedDecl.
- Assess the feasibility of Chris's idea in comment #1 of PR5792.




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95216 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-decl-init.cpp
342fec43c515184a3c0d0600323dfec2b059e74e 01-Feb-2010 John McCall <rjmccall@apple.com> Note that an overload candidate was non-viable because template argument
deduction failed. Right now there's a very vague diagnostic for most cases
and a good diagnostic for incomplete deduction.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94988 91177308-0d34-0410-b5e6-96231b3b80d8
ecursive-template-instantiation.cpp
9db7dbb918ca49f4ee6c181e4917e7b6ec547353 31-Jan-2010 Douglas Gregor <dgregor@apple.com> Rework base and member initialization in constructors, with several
(necessarily simultaneous) changes:

- CXXBaseOrMemberInitializer now contains only a single initializer
rather than a set of initialiation arguments + a constructor. The
single initializer covers all aspects of initialization, including
constructor calls as necessary but also cleanup of temporaries
created by the initializer (which we never handled
before!).

- Rework + simplify code generation for CXXBaseOrMemberInitializers,
since we can now just emit the initializer as an initializer.

- Switched base and member initialization over to the new
initialization code (InitializationSequence), so that it

- Improved diagnostics for the new initialization code when
initializing bases and members, to match the diagnostics produced
by the previous (special-purpose) code.

- Simplify the representation of type-checked constructor initializers in
templates; instead of keeping the fully-type-checked AST, which is
rather hard to undo at template instantiation time, throw away the
type-checked AST and store the raw expressions in the AST. This
simplifies instantiation, but loses a little but of information in
the AST.

- When type-checking implicit base or member initializers within a
dependent context, don't add the generated initializers into the
AST, because they'll look like they were explicit.

- Record in CXXConstructExpr when the constructor call is to
initialize a base class, so that CodeGen does not have to infer it
from context. This ensures that we call the right kind of
constructor.

There are also a few "opportunity" fixes here that were needed to not
regress, for example:

- Diagnose default-initialization of a const-qualified class that
does not have a user-declared default constructor. We had this
diagnostic specifically for bases and members, but missed it for
variables. That's fixed now.

- When defining the implicit constructors, destructor, and
copy-assignment operator, set the CurContext to that constructor
when we're defining the body.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94952 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-member-initializers.cpp
86b8e0949869bb9a7af3a703e8756bad8621c9c5 29-Jan-2010 Douglas Gregor <dgregor@apple.com> When naming a function template via a qualified-id (or any other way
that ADL is suppressed), we need to build an
UnresolvedLookupExpr. Fixes PR6063, which was hitting Boost headers
pretty hard.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94814 91177308-0d34-0410-b5e6-96231b3b80d8
ualified-id.cpp
b2e90aca3ed07f48a536acb3c4c5ade567703cbf 24-Jan-2010 Anders Carlsson <andersca@mac.com> Land test case.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94362 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-1.cpp
2bbae5de98f486d03e10c039668182075b5569dd 23-Jan-2010 Anders Carlsson <andersca@mac.com> Use the new init code for member subobjects.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94329 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-4.cpp
0707bc504c392c8bd214a463f07b01809a23daa5 19-Jan-2010 Douglas Gregor <dgregor@apple.com> Teach Sema::ActOnDependentTemplateName that a dependent template name
in a member access expression referring into the current instantiation
need not be resolved at template definition *if* the current
instantiation has any dependent base classes. Fixes PR6081.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93877 91177308-0d34-0410-b5e6-96231b3b80d8
ependent-base-classes.cpp
e8aba3d374813288ee32461a917a3e5dc695f34b 19-Jan-2010 Douglas Gregor <dgregor@apple.com> Another test case for PR6062

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93872 91177308-0d34-0410-b5e6-96231b3b80d8
ependent-base-member-init.cpp
7a886e1a12ded84f49181cac9423e9db645cc452 19-Jan-2010 Douglas Gregor <dgregor@apple.com> In a mem-initializer, a nested-name-specifier followed by an
identifier always names a type. In the case of a dependent
nested-name-specifier, build a TypenameType to describe the dependent
base type. I'd like to move more of this behavior up into the parser,
but this fixes PR6062.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93871 91177308-0d34-0410-b5e6-96231b3b80d8
ependent-base-member-init.cpp
60406bede202b66ebdd98cac0c38d20f9698aeca 16-Jan-2010 Douglas Gregor <dgregor@apple.com> Introduce a second queue of "local" pending implicit instantiation,
which are instantiations of the member functions of local
classes. These implicit instantiations have to occur at the same time
as---and in the same local instantiation scope as---the enclosing
function, since the member functions of the local class can refer to
locals within the enclosing function. This should really, really fix PR5764.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93666 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-local-class.cpp
26997fd58c9560584edd154618f2f2c15ee68af4 16-Jan-2010 Douglas Gregor <dgregor@apple.com> While determining when to parse inline member functions of a class,
distinguish between nested classes (whose member functions cannot be
parsed until the innermost non-nested class is complete) and local
classes (that are defined within a function but are not necessarily
nested). The upshot of this change, which fixes PR5764, is that the
bodies of member functions of local (non-nested) classes need to be
parsed when the local class is complete (and no later), since they may
refer to function-local static variables, typedefs, enums, etc.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93653 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-local-class.cpp
79c2278a66d8fc0943774d1b7c71a32f7764e1e2 16-Jan-2010 Douglas Gregor <dgregor@apple.com> When we are instantiating a member function of a local class, be sure
to merge the local instantiation scope with the outer local
instantiation scope, so that we can instantiate declarations from the
function owning the local class. Fixes an assert while instantiating
Boost.MPL's BOOST_MPL_ASSERT_MSG.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93651 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-local-class.cpp
5d52e47ed6a4f920723ebec371594a3fe7878d7c 16-Jan-2010 Douglas Gregor <dgregor@apple.com> Partial fix for PR6022, where we were complaining when a friend
function template declared within a class template did not match a
function in another scope. We really need to rework how
friends-in-templates are semantically checked.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93642 91177308-0d34-0410-b5e6-96231b3b80d8
riend-template.cpp
501edb6a54524555ad27fbf41a7920dc756b08c6 15-Jan-2010 Douglas Gregor <dgregor@apple.com> When determining whether a DeclRefExpr is value-dependent when it
references a const variable of integral type, the initializer may be
in a different declaration than the one that name-lookup saw. Find the
initializer anyway. Fixes PR6045.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93514 91177308-0d34-0410-b5e6-96231b3b80d8
ependent-expr.cpp
1cfb7da1f34723021f362cb09636965e5ade0c6d 15-Jan-2010 Douglas Gregor <dgregor@apple.com> When determining whether the type is the current instantiation, strip
qualifiers. Fixes PR6021.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93513 91177308-0d34-0410-b5e6-96231b3b80d8
ember-template-access-expr.cpp
c2233c5c46eafebd5529bf2bbd1f0a723b892e61 15-Jan-2010 John McCall <rjmccall@apple.com> Don't repeat lookup when instantiating resolved member expressions.
Adjust BuildMemberReferenceExpr to perform the inheritance check on implicit
member accesses, which can arise from unqualified lookups and therefore may
reference decls from enclosing class scopes.

Fixes PR 5838.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93510 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-member-expr.cpp
7d3f576dc9ea6e866757abcd1736eb7e7433c325 15-Jan-2010 Douglas Gregor <dgregor@apple.com> When performing qualified name lookup into the current instantiation,
do not look into base classes if there are any dependent base
classes. Instead, note in the lookup result that we couldn't look into
any dependent bases. Use that new result kind to detect when this case
occurs, so that we can fall back to treating the type/value/etc. as a
member of an unknown specialization.

Fixes an issue where we were resolving lookup at template definition
time and then missing an ambiguity at template instantiation time.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93497 91177308-0d34-0410-b5e6-96231b3b80d8
ependent-base-classes.cpp
c781f9cd854f3d5d1c826f4a13382c6abca4cff7 14-Jan-2010 Douglas Gregor <dgregor@apple.com> After dyn_cast'ing, it generally makes sense to check the *output* of
the dyn_cast against NULL rather than the *input*. Fixes PR6025.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93435 91177308-0d34-0410-b5e6-96231b3b80d8
emp_class_spec.cpp
9edad9b6184c730a73dc9241c043ea3bae54189f 14-Jan-2010 Douglas Gregor <dgregor@apple.com> When qualified lookup into the current instantiation fails (because it
finds nothing), and the current instantiation has dependent base
classes, treat the qualified lookup as if it referred to an unknown
specialization. Fixes PR6031.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93433 91177308-0d34-0410-b5e6-96231b3b80d8
ependent-base-classes.cpp
0efc2c1716be4f1c5f1343cad3b047e74861f030 13-Jan-2010 Douglas Gregor <dgregor@apple.com> Reimplement constructor declarator parsing to cope with template-ids
that name constructors, the endless joys of out-of-line constructor
definitions, and various other corner cases that the previous hack
never imagined. Fixes PR5688 and tightens up semantic analysis for
constructor names.

Additionally, fixed a problem where we wouldn't properly enter the
declarator scope of a parenthesized declarator. We were entering the
scope, then leaving it when we saw the ")"; now, we re-enter the
declarator scope before parsing the parameter list.

Note that we are forced to perform some tentative parsing within a
class (call it C) to tell the difference between

C(int); // constructor

and

C (f)(int); // member function

which is rather unfortunate. And, although it isn't necessary for
correctness, we use the same tentative-parsing mechanism for
out-of-line constructors to improve diagnostics in icky cases like:

C::C C::f(int); // error: C::C refers to the constructor name, but
// we complain nicely and recover by treating it as
// a type.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93322 91177308-0d34-0410-b5e6-96231b3b80d8
njected-class-name.cpp
nstantiate-member-class.cpp
220ccbf2c9ef97034cce80561f9f46c4f1f63bc7 13-Jan-2010 John McCall <rjmccall@apple.com> Improve the reporting of non-viable overload candidates by noting the reason
why the candidate is non-viable. There's a lot we can do to improve this, but
it's a good start. Further improvements should probably be integrated with the
bad-initialization reporting routines.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93277 91177308-0d34-0410-b5e6-96231b3b80d8
mbiguous-ovl-print.cpp
efault-expr-arguments.cpp
xplicit-instantiation.cpp
un-template-def.cpp
nstantiate-expr-4.cpp
cb329c506d0e041b9523618158ac925d620c24ac 12-Jan-2010 Chris Lattner <sabre@nondot.org> use DiagRuntimeBehavior to silence the div/rem by zero warning when
not in an evaluated context. This removes some bogus warnings.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93258 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-1.cpp
nstantiate-static-var.cpp
84d0a19828599e8623223632d59447fd498999cf 12-Jan-2010 Douglas Gregor <dgregor@apple.com> Improve recovery for template-ids whose template-name doesn't actually
name a template, when they occur in a base-specifier. This is one of
the (few) places where we know for sure that an identifier followed by
a '<' must be a template name, so we can diagnose and recover well:

test/SemaTemplate/dependent-base-classes.cpp:9:16: error: missing
'template'
keyword prior to dependent template name 'T::apply'
struct X1 : T::apply<U> { }; // expected-error{{missing 'template' ...
^
template
test/SemaTemplate/dependent-base-classes.cpp:12:13: error: unknown
template name
'vector'
struct X2 : vector<T> { }; // expected-error{{unknown template name
'vector'}}
^
2 diagnostics generated.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93257 91177308-0d34-0410-b5e6-96231b3b80d8
ependent-base-classes.cpp
7ef655a78863c0a7550bfe51174b9c340ab1dce0 12-Jan-2010 Chris Lattner <sabre@nondot.org> implement PR6004, warning about divide and remainder by zero.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93256 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-1.cpp
nstantiate-static-var.cpp
d9b600c1a589200be905c53e2e10fceb57efa18d 12-Jan-2010 Douglas Gregor <dgregor@apple.com> Parse dependent template-ids in base clauses and member
initializers. This isn't actually in the C++ grammar (in any version),
but that's clearly an oversight: both GCC and EDG support this syntax,
and it's used within Boost code. I'll file a core issue proposing
precisely the change made here. Fixes PR6008.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93243 91177308-0d34-0410-b5e6-96231b3b80d8
ependent-base-classes.cpp
2e9338824f896790ca0766f7505259ce129eb51a 12-Jan-2010 Douglas Gregor <dgregor@apple.com> When determining whether a given name is a template in a dependent
context, do not attempt typo correction. This harms performance (as
Abramo noted) and can cause some amusing errors, as in this new
testcase.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93240 91177308-0d34-0410-b5e6-96231b3b80d8
ypo-dependent-name.cpp
277d280c20d4414d61e307789949bef8ee3063fd 11-Jan-2010 Douglas Gregor <dgregor@apple.com> When performing name lookup into a scope, check that its entity is
non-NULL before looking at the entity itself.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93199 91177308-0d34-0410-b5e6-96231b3b80d8
unction-template-specialization.cpp
1eb3e1003d5cda4d47f54321d81d678c26981e7a 07-Jan-2010 John McCall <rjmccall@apple.com> Improve the lead diagnostic for C++ object subscript expressions with
no viable overloads. Use a different message when the class provides
no operator[] overloads at all; use it for operator(), too.

Partially addresses PR 5900.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92894 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-subscript.cpp
4b0f21c0f8bed0e2a7dc62d73be64e7e277d6c9a 06-Jan-2010 Douglas Gregor <dgregor@apple.com> Fix marking of virtual members for nested classes whose first non-pure virtual function has a body inlined in the class

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92855 91177308-0d34-0410-b5e6-96231b3b80d8
irtual-member-functions.cpp
b1622a1fd7b7f4ab8d00d0183d17c90ad25c14e3 06-Jan-2010 John McCall <rjmccall@apple.com> Improve the diagnostics used to report implicitly-generated class members
as parts of overload sets. Also, refer to constructors as 'constructors'
rather than functions.

Adjust a lot of tests.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92832 91177308-0d34-0410-b5e6-96231b3b80d8
onstructor-template.cpp
efault-expr-arguments.cpp
xplicit-instantiation.cpp
un-template-def.cpp
nstantiate-expr-4.cpp
nstantiate-static-var.cpp
159ef1ed9f024f73028aa3c9b27ae0717e43786c 06-Jan-2010 Douglas Gregor <dgregor@apple.com> Make our marking of virtual members functions in a class be
deterministic and work properly with templates. Once a class that
needs a vtable has been defined, we now do one if two things:

- If the class has no key function, we place the class on a list of
classes whose virtual functions will need to be "marked" at the
end of the translation unit. The delay until the end of the
translation unit is needed because we might see template
specializations of these virtual functions.
- If the class has a key function, we do nothing; when the key
function is defined, the class will be placed on the
aforementioned list.

At the end of the translation unit, we "mark" all of the virtual
functions of the classes on the list as used, possibly causing
template instantiation and other classes to be added to the
list. This gets LLVM's lib/Support/CommandLine.cpp compiling again.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92821 91177308-0d34-0410-b5e6-96231b3b80d8
irtual-member-functions.cpp
e724246b9f655801bd96b727daf9dddc44beef4d 30-Dec-2009 Chandler Carruth <chandlerc@gmail.com> More fixes to the handling of CVR-comparisons on array types. Adds a method to
QualType to get CVR-qualifiers through array types, and switches the primary
comparison methods to use it. This may allow simplifying some of the callers of
getUnqualifiedArrayType.

Also fix the normalizing of CV-qualification during template deduction to
normalize through arrays and allow a more qualified deduced array type. This
fixes PR5911.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92289 91177308-0d34-0410-b5e6-96231b3b80d8
eduction.cpp
4df6ec10e0e623168a8e34f16e2e986945ddd07d 30-Dec-2009 Eli Friedman <eli.friedman@gmail.com> Test for PR5908.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92282 91177308-0d34-0410-b5e6-96231b3b80d8
ependent-expr.cpp
8aa5f407d9e4787ff08bd66e1a2fe39be174fddc 24-Dec-2009 Douglas Gregor <dgregor@apple.com> Add test case for PR5868, and improve location information slightly for implicit "this" expressions

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92141 91177308-0d34-0410-b5e6-96231b3b80d8
nonymous-union.cpp
036aed18662e0193aafe0e8ae13d2e57efe6df25 24-Dec-2009 Douglas Gregor <dgregor@apple.com> When we see a CXXDefaultArgExpr during template instantiation, rebuild
the default argument so that we're sure to mark any referenced
declarations. This gets us another little step closer to fixing
PR5810.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92078 91177308-0d34-0410-b5e6-96231b3b80d8
efault-expr-arguments.cpp
765ccba920269eefbf572ec4bcd6ac7b6e9f9f77 23-Dec-2009 Douglas Gregor <dgregor@apple.com> Diagnose the use of incomplete types in C++ typeid expressions

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92045 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-4.cpp
29f89f6be93b2f5c7a2b43877cf2555d03aa92a6 23-Dec-2009 Eli Friedman <eli.friedman@gmail.com> Fix the overflow calculation in Sema::CheckTemplateArgument to be a bit more
accurate.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92018 91177308-0d34-0410-b5e6-96231b3b80d8
emp_arg_nontype.cpp
65222e82d97af2120b3952d19cbd3cd923f4b43e 23-Dec-2009 Douglas Gregor <dgregor@apple.com> When using a default function argument for a function template (or
member function thereof), perform the template instantiation each time
the default argument is needed. This ensures that
(1) We get different CXXTemporary objects for each instantiation, and
(2) Any other instantiations or definitions triggered by the
instantiation of the default argument expression are guaranteed to
happen; previously, they might have been suppressed, e.g., because
they happened in an unevaluated context.

This fixes the majority of PR5810. However, it does not address the
problem where we may have multiple uses of the same CXXTemporary
within an expression when the temporary came from a non-instantiated
default argument expression.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92015 91177308-0d34-0410-b5e6-96231b3b80d8
efault-expr-arguments.cpp
323c310efa0abd7a786b0303501186b5f33eb8d7 22-Dec-2009 John McCall <rjmccall@apple.com> Add using shadow decls to the "instantiated locals" map, fixing PR5847.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91928 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-using-decl.cpp
5b5ad8453c8e79f642c3ddfeeadf162ae67309c0 22-Dec-2009 Douglas Gregor <dgregor@apple.com> When transforming a C++ "new" expression that was not explicitly given
a size, check whether the transformed type is itself an array type. If
so, take the major array bound as the size to allocate. Fixes PR5833.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91907 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-4.cpp
aa0373107968aa7a26bf63f4a2673b8325b800af 22-Dec-2009 Douglas Gregor <dgregor@apple.com> Switch initialization of parameters in a call over to
InitializationSequence (when a FunctionDecl is present). This required
a few small fixes to initialization sequences:

- Make sure to use the adjusted parameter type for initialization of
function parameters.
- Implement transparent union calling semantics in C



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91902 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-member-template.cpp
1f24032ea28d0df9d6227e4faf89306dfa990994 22-Dec-2009 Anders Carlsson <andersca@mac.com> When we simply return a retained member expression when instantiating, we must also mark the member decl as referenced.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91887 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-member-expr.cpp
4a2c19bf2330e31851330423187ec48035cab1a5 22-Dec-2009 Eli Friedman <eli.friedman@gmail.com> Switch default arguments over to InitializationSequence.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91883 91177308-0d34-0410-b5e6-96231b3b80d8
efault-expr-arguments.cpp
a91eb541a6adf81acf872e7315bc6b814c3241eb 22-Dec-2009 Eli Friedman <eli.friedman@gmail.com> Switch file-scope assignment initialization over to InitializationSequence.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91881 91177308-0d34-0410-b5e6-96231b3b80d8
ypename-specifier-2.cpp
dd4e485a0db4e651f28281cd3eda93aad6ee04fd 20-Dec-2009 Eli Friedman <eli.friedman@gmail.com> Make sure we instantiate the destructor for variables initialized by
assignment.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91798 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-decl-dtor.cpp
745880f35066bdb1950d0e870608295221346fc5 20-Dec-2009 Douglas Gregor <dgregor@apple.com> Switch default-initialization of variables of class type (or array thereof) over to InitializationSequence. I could swear that this fixes a PR somewhere, but I couldn't figure out which one

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91796 91177308-0d34-0410-b5e6-96231b3b80d8
xplicit-instantiation.cpp
nstantiate-static-var.cpp
cfdc81a83467973b14e4ea5e9e9af1690f135415 19-Dec-2009 Eli Friedman <eli.friedman@gmail.com> Initialization improvements: addition of string initialization and a few
small bug fixes in SemaInit, switch over SemaDecl to use it more often, and
change a bunch of diagnostics which are different with the new initialization
code.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91767 91177308-0d34-0410-b5e6-96231b3b80d8
un-template-def.cpp
nstantiate-method.cpp
7abfbdbc97ad8e7f340789f751df1e32b10118b4 19-Dec-2009 Douglas Gregor <dgregor@apple.com> Switch more of Sema::CheckInitializerTypes over to
InitializationSequence. Specially, switch initialization of a C++
class type (either copy- or direct-initialization).

Also, make sure that we create an elidable copy-construction when
performing copy initialization of a C++ class variable. Fixes PR5826.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91750 91177308-0d34-0410-b5e6-96231b3b80d8
efault-expr-arguments.cpp
un-template-def.cpp
410a3f3c194a541acb5cdf3b98e96d6078685cf2 19-Dec-2009 John McCall <rjmccall@apple.com> Unresolved implicit member accesses are dependent if the object type is dependent.
Avoids an assertion arising during object-argument initialization in overload
resolution. In theory we can resolve this at definition time if the class
hierarchy for the member is fully known.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91747 91177308-0d34-0410-b5e6-96231b3b80d8
ember-access-expr.cpp
ae03cb5a84d13c7a0d4b21865bd63aabd18120d2 19-Dec-2009 John McCall <rjmccall@apple.com> Teach TryAnnotateTypeOrScopeToken to deal with already-annotated
scope specifiers. Fix a tentative parsing bug that came up in LLVM.
Incidentally fixes some random FIXMEs in an existing testcase.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91734 91177308-0d34-0410-b5e6-96231b3b80d8
etafun-apply.cpp
65c49466278f3739ac879f961b94b2aff744beed 18-Dec-2009 John McCall <rjmccall@apple.com> Set up the semantic context correctly when declaring a friend class template.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91678 91177308-0d34-0410-b5e6-96231b3b80d8
riend-template.cpp
18ef5e28a9a2677f8b1dce1fb2638d66e0a1621f 18-Dec-2009 Douglas Gregor <dgregor@apple.com> Switch the initialization required by return statements over to the
new InitializationSequence. This fixes some bugs (e.g., PR5808),
changed some diagnostics, and caused more churn than expected. What's
new:

- InitializationSequence now has a "C conversion sequence" category
and step kind, which falls back to
- Changed the diagnostics for returns to always have the result type
of the function first and the type of the expression second.
CheckSingleAssignmentConstraints to peform checking in C.
- Improved ASTs for initialization of return values. The ASTs now
capture all of the temporaries we need to create, but
intentionally do not bind the tempoary that is actually returned,
so that it won't get destroyed twice.
- Make sure to perform an (elidable!) copy of the class object that
is returned from a class.
- Fix copy elision in CodeGen to properly see through the
subexpressions that occur with elidable copies.
- Give "new" its own entity kind; as with return values and thrown
objects, we don't bind the expression so we don't call a
destructor for it.

Note that, with this patch, I've broken returning move-only types in
C++0x. We'll fix it later, when we tackle NRVO.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91669 91177308-0d34-0410-b5e6-96231b3b80d8
lass-template-id.cpp
onstructor-template.cpp
nstantiate-expr-4.cpp
nstantiate-function-1.cpp
nstantiate-member-template.cpp
nstantiate-typedef.cpp
52bb5d2a1474460707e5ca11656b2749a7a33a82 16-Dec-2009 Douglas Gregor <dgregor@apple.com> In Sema::CheckInitializerTypes, replace a use of CheckReferenceInit with an InitializationSequence

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91542 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-template-template-parm.cpp
etafun-apply.cpp
3b4294e5c1e904a2e0f74449dbc3f52f69cc8e9f 16-Dec-2009 John McCall <rjmccall@apple.com> Shift things around so that it's easier to recover from a missing
function in a C++ call using an arbitrary call-expression type.
Actually exploit this to fix the recovery implemented earlier.

The diagnostic is still iffy, though.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91538 91177308-0d34-0410-b5e6-96231b3b80d8
ependent-names.cpp
578b69b186d9cba0a6ae1dd7f4c04cd6a49f0aac 16-Dec-2009 John McCall <rjmccall@apple.com> Introduce a centralized routine in Sema for diagnosing failed lookups (when
used as expressions). In dependent contexts, try to recover by doing a lookup
in previously-dependent base classes. We get better diagnostics out, but
unfortunately the recovery fails: we need to turn it into a method call
expression, not a bare call expression. Thus this is still a WIP.




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91525 91177308-0d34-0410-b5e6-96231b3b80d8
onstructor-template.cpp
ependent-names.cpp
nstantiate-call.cpp
ecursive-template-instantiation.cpp
99a2e600f9e2e51d3ce10fb6f27191677ac65b2a 16-Dec-2009 Douglas Gregor <dgregor@apple.com> Switch the C++ new expression over to InitializationSequence, rather
than using its own partial implementation of initialization.

Switched CheckInitializerTypes over to
InitializedEntity/InitializationKind, to help move us closer to
InitializationSequence.

Added InitializedEntity::getName() to retrieve the name of the entity,
for diagnostics that care about such things.

Implemented support for default initialization in
InitializationSequence.

Clean up the determination of the "source expressions" for an
initialization sequence in InitializationSequence::Perform.

Taught CXXConstructExpr to store more location information.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91492 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-4.cpp
6c1c1b8c6ca743a5b6b4c81f9ac56392c12c7457 15-Dec-2009 John McCall <rjmccall@apple.com> Link up member-class redeclarations during template instantiation.
This test courtesy of LLVM.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91462 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-member-class.cpp
80737ad5e0a67d6e3dd0a0ba48446344215a5fd5 15-Dec-2009 Daniel Dunbar <daniel@zuster.org> Update tests to use %clang instead of 'clang', and forcibly disable use of '
clang ' or ' clang -cc1 ' or ' clang-cc ' in test lines (by substituting them to
garbage).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91460 91177308-0d34-0410-b5e6-96231b3b80d8
xample-dynarray.cpp
a5728872c7702ddd09537c95bc3cbd20e1f2fb09 15-Dec-2009 Daniel Dunbar <daniel@zuster.org> Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'.
- This is designed to make it obvious that %clang_cc1 is a "test variable"
which is substituted. It is '%clang_cc1' instead of '%clang -cc1' because it
can be useful to redefine what gets run as 'clang -cc1' (for example, to set
a default target).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91446 91177308-0d34-0410-b5e6-96231b3b80d8
ckermann.cpp
mbiguous-ovl-print.cpp
anonical-expr-type-0x.cpp
anonical-expr-type.cpp
lass-template-ctor-initializer.cpp
lass-template-decl.cpp
lass-template-id-2.cpp
lass-template-id.cpp
lass-template-spec.cpp
onstructor-template.cpp
opy-ctor-assign.cpp
urrent-instantiation.cpp
eduction.cpp
efault-arguments-cxx0x.cpp
efault-arguments.cpp
efault-expr-arguments.cpp
ependent-base-member-init.cpp
ependent-names.cpp
ependent-sized_array.cpp
ependent-type-identity.cpp
estructor-template.cpp
num-argument.cpp
xample-typelist.cpp
xplicit-instantiation.cpp
xplicit-specialization-member.cpp
xt-vector-type.cpp
xtern-templates.cpp
ibonacci.cpp
riend-template.cpp
riend.cpp
un-template-def.cpp
unction-template-specialization.cpp
mplicit-instantiation-1.cpp
njected-class-name.cpp
nstantiate-anonymous-union.cpp
nstantiate-array.cpp
nstantiate-attr.cpp
nstantiate-c99.cpp
nstantiate-call.cpp
nstantiate-case.cpp
nstantiate-cast.cpp
nstantiate-clang.cpp
nstantiate-complete.cpp
nstantiate-decl-init.cpp
nstantiate-declref-ice.cpp
nstantiate-declref.cpp
nstantiate-deeply.cpp
nstantiate-default-assignment-operator.cpp
nstantiate-dependent-nested-name.cpp
nstantiate-enum-2.cpp
nstantiate-enum.cpp
nstantiate-exception-spec.cpp
nstantiate-expr-1.cpp
nstantiate-expr-2.cpp
nstantiate-expr-3.cpp
nstantiate-expr-4.cpp
nstantiate-expr-5.cpp
nstantiate-expr-basic.cpp
nstantiate-field.cpp
nstantiate-friend-class.cpp
nstantiate-function-1.cpp
nstantiate-function-1.mm
nstantiate-function-2.cpp
nstantiate-init.cpp
nstantiate-member-class.cpp
nstantiate-member-initializers.cpp
nstantiate-member-pointers.cpp
nstantiate-member-template.cpp
nstantiate-method.cpp
nstantiate-non-type-template-parameter.cpp
nstantiate-objc-1.mm
nstantiate-overloaded-arrow.cpp
nstantiate-static-var.cpp
nstantiate-subscript.cpp
nstantiate-template-template-parm.cpp
nstantiate-try-catch.cpp
nstantiate-type.cpp
nstantiate-typedef.cpp
nstantiate-using-decl.cpp
nstantiation-backtrace.cpp
nstantiation-default-1.cpp
nstantiation-default-2.cpp
nstantiation-default-3.cpp
nstantiation-depth.cpp
ember-access-expr.cpp
ember-function-template.cpp
ember-initializers.cpp
ember-template-access-expr.cpp
etafun-apply.cpp
ested-linkage.cpp
ested-name-spec-template.cpp
ested-template.cpp
perator-function-id-template.cpp
perator-template.cpp
verload-uneval.cpp
artial-spec-instantiate.cpp
ualified-id.cpp
ualified-names-diag.cpp
ecursive-template-instantiation.cpp
emp.cpp
emp_arg.cpp
emp_arg_nontype.cpp
emp_arg_template.cpp
emp_arg_type.cpp
emp_class_order.cpp
emp_class_spec.cpp
emp_class_spec_blocks.cpp
emp_class_spec_neg.cpp
emp_explicit.cpp
emp_explicit_cxx0x.cpp
emp_func_order.cpp
emplate-class-traits.cpp
emplate-decl-fail.cpp
emplate-id-expr.cpp
emplate-id-printing.cpp
ypename-specifier-2.cpp
ypename-specifier-3.cpp
ypename-specifier-4.cpp
ypename-specifier.cpp
alue-dependent-null-pointer-constant.cpp
ariadic-class-template-1.cpp
ariadic-class-template-2.cpp
ariadic-parse.cpp
ariadic-unsupported.cpp
irtual-member-functions.cpp
e976ffe18ee60b81641423f42ff6feec2f5e3cb7 15-Dec-2009 John McCall <rjmccall@apple.com> Fix PR5716 by bandaging over the solution until we can come back to it.
I apologize for friend declarations.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91359 91177308-0d34-0410-b5e6-96231b3b80d8
riend-template.cpp
6eef519fc8a97bb7ca6066f23d35e10f06b2c1b5 14-Dec-2009 Douglas Gregor <dgregor@apple.com> Improve template instantiation for object constructions in several ways:

- During instantiation, drop default arguments from constructor and
call expressions; they'll be recomputed anyway, and we don't want
to instantiate them twice.
- Rewrote the instantiation of variable initializers to cope with
non-dependent forms properly.

Together, these fix a handful of problems I introduced with the switch
to always rebuild expressions from the source code "as written."



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91315 91177308-0d34-0410-b5e6-96231b3b80d8
onstructor-template.cpp
01ed063edbddd72c1b3f3f7b060bf9a0766e5d09 14-Dec-2009 Fariborz Jahanian <fjahanian@apple.com> Make tests use the new clang -cc1 flag.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91303 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-function-1.mm
nstantiate-objc-1.mm
668d6d9dc100b3ef28a9b8e6fe987c2f5b6edcc9 13-Dec-2009 Douglas Gregor <dgregor@apple.com> Fix template instantiation for non-dependent calls to overloaded call
operators. Fixes PR5266.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91252 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-1.cpp
a88cfbfac9bbcbb9858f048d6d73a48711d8e93d 12-Dec-2009 Douglas Gregor <dgregor@apple.com> Rework the way we handle template instantiation for
implicitly-generated AST nodes. We previously built instantiated nodes
for each of these AST nodes, then passed them on to Sema, which was
not prepared to see already-type-checked nodes (see PR5755). In some
places, we had ugly workarounds to try to avoid re-type-checking
(e.g., in VarDecl initializer instantiation).

Now, we skip implicitly-generated nodes when performing instantiation,
preferring instead to build just the AST nodes that directly reflect
what was written in the source code. This has several advantages:

- We don't need to instantiate anything that doesn't have a direct
correlation to the source code, so we can have better location
information.
- Semantic analysis sees the same thing at template instantiation
time that it would see for a non-template.
- At least one ugly hack (VarDecl initializers) goes away.

Fixes PR5755.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91218 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-4.cpp
4b6e90a0dd98b13c2d3ac34ee3eae3954dbb87c6 11-Dec-2009 John McCall <rjmccall@apple.com> Reorganize testcase.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91153 91177308-0d34-0410-b5e6-96231b3b80d8
riend-template.cpp
ed0716b7b79d8cdef34f3bd35776a91aa3c943e5 11-Dec-2009 Eli Friedman <eli.friedman@gmail.com> Fix the handling of dependent enums per C++ DR 502.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91089 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-enum-2.cpp
20093b4bf698f292c664676987541d5103b65b15 10-Dec-2009 Douglas Gregor <dgregor@apple.com> Reimplement reference initialization (C++ [dcl.init.ref]) using the
new notion of an "initialization sequence", which encapsulates the
computation of the initialization sequence along with diagnostic
information and the capability to turn the computed sequence into an
expression. At present, I've only switched one CheckReferenceInit
callers over to this new mechanism; more will follow.

Aside from (hopefully) being much more true to the standard, the
diagnostics provided by this reference-initialization code are a bit
better than before. Some examples:

p5-var.cpp:54:12: error: non-const lvalue reference to type 'struct
Derived'
cannot bind to a value of unrelated type 'struct Base'
Derived &dr2 = b; // expected-error{{non-const lvalue reference to
...
^ ~
p5-var.cpp:55:9: error: binding of reference to type 'struct Base' to
a value of
type 'struct Base const' drops qualifiers
Base &br3 = bc; // expected-error{{drops qualifiers}}
^ ~~

p5-var.cpp:57:15: error: ambiguous conversion from derived class
'struct Diamond' to base class 'struct Base':
struct Diamond -> struct Derived -> struct Base
struct Diamond -> struct Derived2 -> struct Base
Base &br5 = diamond; // expected-error{{ambiguous conversion from
...
^~~~~~~
p5-var.cpp:59:9: error: non-const lvalue reference to type 'long'
cannot bind to
a value of unrelated type 'int'
long &lr = i; // expected-error{{non-const lvalue reference to type
...
^ ~

p5-var.cpp:74:9: error: non-const lvalue reference to type 'struct
Base' cannot
bind to a temporary of type 'struct Base'
Base &br1 = Base(); // expected-error{{non-const lvalue reference to
...
^ ~~~~~~

p5-var.cpp:102:9: error: non-const reference cannot bind to bit-field
'i'
int & ir1 = (ib.i); // expected-error{{non-const reference cannot
...
^ ~~~~~~
p5-var.cpp:98:7: note: bit-field is declared here
int i : 17; // expected-note{{bit-field is declared here}}
^






git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90992 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-4.cpp
b6cc91be4da4f55c7e3dca87ecfdb532b33c83ca 09-Dec-2009 Anders Carlsson <andersca@mac.com> Pass the current SourceLocation to getAssignOperatorMethod, fixing a crash when the assign operator method needs to be instantiated. Doug, please review the updated default-assignment-operator.cpp change.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90935 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-default-assignment-operator.cpp
0ae7b3f1d5403265f693ed75384603ca8fbba74d 08-Dec-2009 Douglas Gregor <dgregor@apple.com> Implement template instantiation for exception specifications. Also,
print exception specifications on function types and
declarations. Fixes <rdar://problem/7450999>.

There is some poor source-location information here, because we don't
track locations of the types in exception specifications. Filed PR5719.

Failures during template instantiation of the signature of a function
or function template have wrong point-of-instantiation location
information. I'll tackle that with a separate commit.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90863 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-exception-spec.cpp
863dbcb45eb7b1e663f2d62be0fbdda6d9aa13ef 07-Dec-2009 Anders Carlsson <andersca@mac.com> Instantiated or specialized class templates never have a key function. This (and the previous check-in) fixes PR5557.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90753 91177308-0d34-0410-b5e6-96231b3b80d8
irtual-member-functions.cpp
d013733c73507674b5db55d1686339e45c9e6edf 06-Dec-2009 Eli Friedman <eli.friedman@gmail.com> Fix for PR5693: shift some code into SetClassDeclAttributesFromBase so that
it gets called during template instantiation.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90682 91177308-0d34-0410-b5e6-96231b3b80d8
emplate-class-traits.cpp
1f5f3a4d58a1c7c50c331b33329fc14563533c04 03-Dec-2009 Douglas Gregor <dgregor@apple.com> When we're building a CXXExprWithTemporaries, only include those
temporaries that are within our current evaluation context. That way,
nested evaluation contexts (e.g., within a sizeof() expression) won't
see temporaries from outer contexts. Also, make sure to push a new
evaluation context when instantiating the initializer of a variable;
this may be an unevaluated context or a potentially-evaluated context,
depending on whether it's an in-class initializer or not. Fixes PR5672.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90460 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-static-var.cpp
fda8e12774921e3cac3ebcba1148bcf4479ddd7a 03-Dec-2009 John McCall <rjmccall@apple.com> Stop stripping UnresolvedUsingDecls out of LookupResults that have other
results in them (which we were doing intentionally as a stopgap). Fix
an DeclContext lookup-table ordering problem which was causing UsingDecls to
show up incorrectly when looking for ordinary results. And oh hey
Clang-Code-Syntax passes now.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90367 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-using-decl.cpp
aa81e1658d87b9011125c632aa902d154ae4b02c 01-Dec-2009 John McCall <rjmccall@apple.com> Rework how we support C++ implicit member accesses. If we can resolve an
implicit member access to a specific declaration, go ahead and create
it as a DeclRefExpr or a MemberExpr (with implicit CXXThisExpr base) as
appropriate. Otherwise, create an UnresolvedMemberExpr or
DependentScopeMemberExpr with a null base expression.

By representing implicit accesses directly in the AST, we get the ability
to correctly delay the decision about whether it's actually an instance
member access or not until resolution is complete. This permits us
to correctly avoid diagnosing the 'problem' of 'MyType::foo()'
where the relationship to the type isn't really known until instantiation.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90266 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-method.cpp
ualified-id.cpp
9af2f52fbcb993350f54e57d498e7849ba29c75d 01-Dec-2009 Douglas Gregor <dgregor@apple.com> Don't automatically assume that an id-expression refers to a
ValueDecl, because that isn't always the case in ill-formed
code. Diagnose a common mistake (forgetting to provide a template
argument list for a class template, PR5655) and dyn_cast so that we
handle the general problem of referring to a non-value declaration
gracefully.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90239 91177308-0d34-0410-b5e6-96231b3b80d8
lass-template-id.cpp
e1599cee9310e523af40c3c8a5f21be6f7302981 01-Dec-2009 John McCall <rjmccall@apple.com> Fix and test for a problem caught by the clang-on-clang buildbot: qualified
IDs in dependent contexts are not dependent if the context names a namespace.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90171 91177308-0d34-0410-b5e6-96231b3b80d8
ualified-id.cpp
129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6 30-Nov-2009 John McCall <rjmccall@apple.com> Eliminate the use of OverloadedFunctionDecl in member expressions.
Create a new UnresolvedMemberExpr for these lookups. Assorted hackery
around qualified member expressions; this will all go away when we
implement the correct (i.e. extremely delayed) implicit-member semantics.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90161 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-method.cpp
78d5590d896cb95eea972754ad40735927ae585f 30-Nov-2009 Daniel Dunbar <daniel@zuster.org> Use '-FOO' 'BAR' instead of '-FOO=BAR' in tests.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90122 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiation-depth.cpp
a75a92dfffee2b34a43f1d0e9f8d1949feb190ad 29-Nov-2009 Daniel Dunbar <daniel@zuster.org> Remove unnecessary -fms-extensions=0 from tests (this command line syntax is going away).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90066 91177308-0d34-0410-b5e6-96231b3b80d8
ested-name-spec-template.cpp
2afce7248b7a362f1e322ad18e43484d575b9c9d 26-Nov-2009 Douglas Gregor <dgregor@apple.com> Refactor our handling of expression evaluation contexts, so that Sema
maintains a stack of evaluation contexts rather than having the parser
do it. This change made it simpler to track in which contexts
temporaries were created, so that we could...

"Forget" about temporaries created within unevaluated contexts, so
that we don't build a CXXExprWithTemporaries and, therefore, destroy
the integral-constness of our expressions. Fixes PR5609.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89908 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-static-var.cpp
d85b5b9b8fcf53906d9a61649b3657ca0d902017 25-Nov-2009 Douglas Gregor <dgregor@apple.com> Implement the rules in C++ [basic.link] and C99 6.2.2 for computing
the linkage of a declaration. Switch the lame (and completely wrong)
NamedDecl::hasLinkage() over to using the new NamedDecl::getLinkage(),
along with the "can this declaration be a template argument?" check
that started all of this.

Fixes -fsyntax-only for PR5597.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89891 91177308-0d34-0410-b5e6-96231b3b80d8
emp_arg_nontype.cpp
51ffb0c9d43b2d3fd210e51ecdd67ba5d1790d70 25-Nov-2009 Douglas Gregor <dgregor@apple.com> Implement support for default template arguments of function templates.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89874 91177308-0d34-0410-b5e6-96231b3b80d8
efault-arguments-cxx0x.cpp
04895d301e1107a8f03673c43c939a115c3c1195 24-Nov-2009 Douglas Gregor <dgregor@apple.com> "Do" loops cannot have condition variables, so don't parse them.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89801 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-function-1.cpp
26416068d3eb883a280fdceeffa74fffc9131031 24-Nov-2009 John McCall <rjmccall@apple.com> Fix some major problems dealing with dependently-qualified names in implicit
member-reference contexts. Fixes some clang-on-clang asserts.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89796 91177308-0d34-0410-b5e6-96231b3b80d8
ependent-names.cpp
ac564f3e8d79c44fefa5da5ab1b58484ae781051 23-Nov-2009 Douglas Gregor <dgregor@apple.com> Improve type-checking of templates by distinguishing between members
of the current instantiation and members of an unknown specialization
when type-checking a qualified-if expression.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89653 91177308-0d34-0410-b5e6-96231b3b80d8
urrent-instantiation.cpp
7edfb69ae192d9c1f5b1f32af30130f34f98386e 23-Nov-2009 Douglas Gregor <dgregor@apple.com> Do not mark declarations as used when performing overload resolution. Fixes PR5541

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89652 91177308-0d34-0410-b5e6-96231b3b80d8
verload-uneval.cpp
3ebd75399112dd9ad1c96ee5e7c59df580378cc8 23-Nov-2009 Douglas Gregor <dgregor@apple.com> Tolerate extraneous "template<>" headers better, downgrading the
complaint to a warning and providing a helpful node in the case where
the "template<>" header is redundant because the corresponding
template-id refers to an explicit specialization. C++0x might still
change this behavior, and existing practice is all over the place on
the number of "template<>" headers actually needed.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89651 91177308-0d34-0410-b5e6-96231b3b80d8
emp_explicit.cpp
31658dfe908d07666e2820ced8443a9a1988f1eb 20-Nov-2009 Douglas Gregor <dgregor@apple.com> When checking the base object of a member access expression (b.foo,
b->foo), don't look through pointers unless we have an -> operator.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89480 91177308-0d34-0410-b5e6-96231b3b80d8
estructor-template.cpp
699ee52b2f383b62865013c3575510b520055811 20-Nov-2009 Douglas Gregor <dgregor@apple.com> Teach FixOverloadedFunctionReference to build new expression ASTs rather
than tweaking existing ASTs, since we were (*gasp*) stomping on ASTs
within templates. I'm glad we found this little stick of TNT early...



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89475 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-member-template.cpp
f3c1f0e13614d384f77b2b1fdea386c74c407d0f 20-Nov-2009 Douglas Gregor <dgregor@apple.com> When we have a non-dependent expression such as

A::f

that occurs within a non-static member function with a type-dependent
"this", don't consider this to be a case for introduction of an
implicit "(*this)." to refer to a specific member function unless we
know (at template definition time) that A is a base class of *this.

There is some disagreement here between GCC, EDG, and Clang about the
handling of this case. I believe that Clang now has the correct,
literal interpretation of the standard, but have asked for
clarification (c++std-core-15483).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89425 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-method.cpp
73460a32bc5299a5927d23d2e464d72af796eabf 20-Nov-2009 Douglas Gregor <dgregor@apple.com> Deduce a ConstantArrayType from a value-dependent initializer list
rather than punting to a DependentSizedArrayType, tightening up our
type checking for template definitions. Thanks, John!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89407 91177308-0d34-0410-b5e6-96231b3b80d8
ependent-sized_array.cpp
cb78d8852a454684c987220132cdb5e54dd00121 19-Nov-2009 Douglas Gregor <dgregor@apple.com> Cope with an amusingly little anomaly with dependent types and
incomplete array initialization, where we have the following in a
template:

int a[] = { 1, 2, something-value-dependent };
// ...
sizeof(a);

The type of "a" appears to be a non-dependent IncompleteArrayType, but
treating it as such makes the sizeof(a) fail at template definition
time. We now correctly handle this by morphing the IncompleteArrayType
into a DependentSizedArrayType with a NULL expression, indicating that
its size has no corresponding expression (and, therefore, the type is
distinct from others).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89366 91177308-0d34-0410-b5e6-96231b3b80d8
ependent-sized_array.cpp
264c1f8ec895952466eab59b84b8b06801e721fa 19-Nov-2009 Eli Friedman <eli.friedman@gmail.com> The sub-statement of a case statement is not an unevaluated context!



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89303 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-case.cpp
cc5306ac8a39cdd5e7f83e597cba911e97c4a595 18-Nov-2009 Fariborz Jahanian <fjahanian@apple.com> Improve on diagnosing type mismatches because of
lack of viable convesion functions.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89216 91177308-0d34-0410-b5e6-96231b3b80d8
onstructor-template.cpp
8ee15dc2e2a9573b2852326650813111d7647909 17-Nov-2009 Daniel Dunbar <daniel@zuster.org> Use clang to run tests which include headers from the system.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89085 91177308-0d34-0410-b5e6-96231b3b80d8
xample-dynarray.cpp
48c32a7e7c977f317dc1dc19524c2f54d29c7270 17-Nov-2009 Douglas Gregor <dgregor@apple.com> Implement template instantiation for using directives, which is dead simple.

Also, make the "don't know how to instantiate a particular kind of
declaration" diagnostic nicer, so we don't have to trap Clang in a
debugger to figure out what went wrong.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89050 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-using-decl.cpp
03c5705a99a96a471b2868898ee9688a6721e02a 17-Nov-2009 Douglas Gregor <dgregor@apple.com> Require the object type of a member access expression ("." or "->") to
be complete.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89042 91177308-0d34-0410-b5e6-96231b3b80d8
lass-template-spec.cpp
ember-function-template.cpp
1a3c75f32f0d27de5f3f6b2ef4c6bbe7e18bddad 16-Nov-2009 Eli Friedman <eli.friedman@gmail.com> Fix PR5488: special-case the overloaded arrow operator so that we don't try to
treat it as a unary operator.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88938 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-overloaded-arrow.cpp
66724ea67d7d598b937d86fa66f03f09a1c758f3 14-Nov-2009 Douglas Gregor <dgregor@apple.com> If we attempt to add a constructor template specialization that looks
like a copy constructor to the overload set, just ignore it. This
ensures that we don't try to use such a constructor as a copy
constructor *without* triggering diagnostics at the point of
declaration.

Note that we *do* diagnose such copy constructors when explicitly
written by the user (e.g., as an explicit specialization).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88733 91177308-0d34-0410-b5e6-96231b3b80d8
onstructor-template.cpp
perator-template.cpp
fd47648b5d351ff6d1a3e886e1c3d10712ba4675 14-Nov-2009 Douglas Gregor <dgregor@apple.com> Revert r88718, which does NOT solve the constructor-template-as-copy-constructor issue. Big thanks to John for finding this

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88724 91177308-0d34-0410-b5e6-96231b3b80d8
onstructor-template.cpp
perator-template.cpp
15755cb8399afa702575a21915daf2f6e56b5ac1 14-Nov-2009 Douglas Gregor <dgregor@apple.com> Template argument deduction of a non-type template parameter from a
template argument.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88722 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-member-pointers.cpp
cad84b7c12564ff37feb66d6d004bb609bea8788 14-Nov-2009 Douglas Gregor <dgregor@apple.com> A constructor template cannot be instantiated to a copy
constructor. Make sure that such declarations can never be formed.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88718 91177308-0d34-0410-b5e6-96231b3b80d8
onstructor-template.cpp
perator-template.cpp
caddba07f82096ee0d0a0312727d4418ee7a8d36 12-Nov-2009 Douglas Gregor <dgregor@apple.com> Recognize (and check) pointer-to-member template arguments that are
non-type template parameters or constants of pointer-to-member
type. Once checked, be sure to retain those pointer-to-member
constants as expressions if they are dependent, or as declarations if
they are not dependent.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@87010 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-member-pointers.cpp
231edff7907cf151f1d046f287d3ee4ad90037cc 12-Nov-2009 Douglas Gregor <dgregor@apple.com> When instantiating a reference to a non-type template parameter of pointer to
member type (e.g., T Class::*Member), build a pointer-to-member
constant expression. Previously, we we just building a simple
declaration reference expression, which meant that the expression was
not treated as a pointer to member.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@87000 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-member-pointers.cpp
fb898e17cff919bd28b88e9d93301d6e2cc5cbd1 12-Nov-2009 Douglas Gregor <dgregor@apple.com> When comparing template parameter lists, distinguish between three cases:
- Comparing template parameter lists to determine if we have a redeclaration
- Comparing template parameter lists to determine if we have equivalent
template template parameters
- Comparing template parameter lists to determine whether a template
template argument is valid for a given template template parameter.

Previously, we did not distinguish between the last two cases, which
got us into trouble when we were looking for exact type matches
between the types of non-type template parameters that were dependent
types. Now we do, so we properly delay checking of template template
arguments until instantiation time.

Also, fix an accidental fall-through in a case statement that was
causing crashes.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86992 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-template-template-parm.cpp
8b13c08b1a181b290600814c765f9f199a74f414 12-Nov-2009 Douglas Gregor <dgregor@apple.com> Improve recovery in a wonky case where one tries to specialize a
template template parameter.

When building a template-id type, check whether the template-name
itself is dependent (even if the template arguments are not!) and
handle it as a template-id type.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86913 91177308-0d34-0410-b5e6-96231b3b80d8
lass-template-spec.cpp
eaf75f4e0f65444bb122ade7725a4a32badcbf77 12-Nov-2009 Douglas Gregor <dgregor@apple.com> Remove an overly-eager assertion when replacing tokens with an
annotation token, because some of the tokens we're annotating might
not be in the set of cached tokens (we could have consumed them
unconditionally).

Also, move the tentative parsing from ParseTemplateTemplateArgument
into the one caller that needs it, improving recovery.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86904 91177308-0d34-0410-b5e6-96231b3b80d8
efault-arguments.cpp
db0d4b751e83b8841b8f48f913f17e50467f13d4 12-Nov-2009 Douglas Gregor <dgregor@apple.com> Template argument deduction for template template parameters. This
permits, among other things, ripping apart and reconstructing
templates via partial specialization:

template<typename T>
struct DeepRemoveConst { typedef T type; };

template<typename T>
struct DeepRemoveConst<const T> {
typedef typename DeepRemoveConst<T>::type type;
};

template<template<typename> class TT, typename T>
struct DeepRemoveConst<TT<T> > {
typedef TT<typename DeepRemoveConst<T>::type> type;
};

Also, fix a longstanding thinko in the code handling partial ordering
of class template partial specializations. We were performing the
second deduction without clearing out the results of the first
deduction. It's amazing we got through so much code with such a
horrendous error :(



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86893 91177308-0d34-0410-b5e6-96231b3b80d8
eduction.cpp
f35f828f9883123772a9731af190a608f3236ef4 11-Nov-2009 Douglas Gregor <dgregor@apple.com> Improve diagnostics when a default template argument does not match
with its corresponding template parameter. This can happen when we
performed some substitution into the default template argument and
what we had doesn't match any more, e.g.,

template<int> struct A;
template<typename T, template<T> class X = A> class B;

B<long> b;

Previously, we'd emit a pretty but disembodied diagnostic showing how
the default argument didn't match the template parameter. The
diagnostic was good, but nothing tied it to the *use* of the default
argument in "B<long>". This commit fixes that.

Also, tweak the counting of active template instantiations to avoid
counting non-instantiation records, such as those we create for
(surprise!) checking default arguments, instantiating default
arguments, and performing substitutions as part of template argument
deduction.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86884 91177308-0d34-0410-b5e6-96231b3b80d8
efault-arguments.cpp
9148c3f5829f4d031249faeb1043e7be914539e8 11-Nov-2009 Douglas Gregor <dgregor@apple.com> Before checking a template template argument against its corresponding
template template parameter, substitute any prior template arguments
into the template template parameter. This, for example, allows us to
properly check the template template argument for a class such as:

template<typename T, template<T Value> class X> struct Foo;

The actual implementation of this feature was trivial; most of the
change is dedicated to giving decent diagnostics when this
substitution goes horribly wrong. We now get a note like:

note: while substituting prior template arguments into template
template parameter 'X' [with T = float]

As part of this change, enabled some very pedantic checking when
comparing template template parameter lists, which shook out a bug in
our overly-eager checking of default arguments of template template
parameters. We now perform only minimal checking of such default
arguments when they are initially parsed.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86864 91177308-0d34-0410-b5e6-96231b3b80d8
efault-arguments.cpp
nstantiate-template-template-parm.cpp
nstantiation-default-2.cpp
ested-template.cpp
9106ef78f8fcc9df1a60c7a5b64c7d967194207e 11-Nov-2009 Douglas Gregor <dgregor@apple.com> Instantiation of template template parameters for nested templates, e.g.,

template<typename T>
struct X {
template<template<T Value> class Y> struct Inner;
};



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86844 91177308-0d34-0410-b5e6-96231b3b80d8
ested-template.cpp
7bb87fca7d22a8a194d04188746b90f46512975f 11-Nov-2009 Douglas Gregor <dgregor@apple.com> Fix speculative parsing of dependent template names in
nested-name-specifiers so that they don't gobble the template name (or
operator-function-id) unless there is also a
template-argument-list. For example, given

T::template apply

we would previously consume both "template" and "apply" as part of
parsing the nested-name-specifier, then error when we see that there
is no "<" starting a template argument list. Now, we parse such
constructs tentatively, and back off if the "<" is not present. This
allows us to parse dependent template names as one would use them for,
e.g., template template parameters:

template<typename T, template<class> class X = T::template apply>
struct MetaSomething;

Also, test default arguments for template template parameters.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86841 91177308-0d34-0410-b5e6-96231b3b80d8
efault-arguments.cpp
ested-name-spec-template.cpp
788cd06cf8e868a67158aafec5de3a1f408d14f3 11-Nov-2009 Douglas Gregor <dgregor@apple.com> Introduce a new representation for template template
parameters. Rather than storing them as either declarations (for the
non-dependent case) or expressions (for the dependent case), we now
(always) store them as TemplateNames.

The primary change here is to add a new kind of TemplateArgument,
which stores a TemplateName. However, making that change ripples to
every switch on a TemplateArgument's kind, also affecting
TemplateArgumentLocInfo/TemplateArgumentLoc, default template
arguments for template template parameters, type-checking of template
template arguments, etc.

This change is light on testing. It should fix several pre-existing
problems with template template parameters, such as:
- the inability to use dependent template names as template template
arguments
- template template parameter default arguments cannot be
instantiation

However, there are enough pieces missing that more implementation is
required before we can adequately test template template parameters.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86777 91177308-0d34-0410-b5e6-96231b3b80d8
emp_arg_nontype.cpp
emp_arg_template.cpp
d47c47d65e339ab1f28e9f9365159cf1047ac1df 09-Nov-2009 Douglas Gregor <dgregor@apple.com> Make sure that we instantiate default function arguments for an
overloaded operator().


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86581 91177308-0d34-0410-b5e6-96231b3b80d8
efault-expr-arguments.cpp
0f8716b7bb25d61a82f699b3975167451f7b5a68 09-Nov-2009 Douglas Gregor <dgregor@apple.com> Improve instantiation of default template arguments for nested
templates. The instantiation of these default arguments must be (and
now, is) delayed until the template argument is actually used, at
which point we substitute all levels of template arguments
concurrently.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86578 91177308-0d34-0410-b5e6-96231b3b80d8
efault-arguments.cpp
11a82401eaf3396dfb6466fa691a606204c8ddb0 09-Nov-2009 Douglas Gregor <dgregor@apple.com> Slightly more testing for instantiation of non-type template parameters in nested templates, for my own sanity's sake

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86570 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-member-template.cpp
a29e51bb9874bb9ce442efa271e87da237e4ce2c 08-Nov-2009 Sebastian Redl <sebastian.redl@getdesigned.at> Special-case default argument expression in instantiation. This should fix PR4301. Doug, please double-check my assumptions. Read the PR for more details.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86465 91177308-0d34-0410-b5e6-96231b3b80d8
efault-expr-arguments.cpp
42dddbeadb82a918d83c14bdcce47ba8c0ed6fba 08-Nov-2009 Sebastian Redl <sebastian.redl@getdesigned.at> Don't reprocess non-dependent initializers of non-dependent VarDecls. Fixes PR5426.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86460 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-decl-init.cpp
4fcfde4d5c8f25e40720972a5543d538a0dcb220 08-Nov-2009 Daniel Dunbar <daniel@zuster.org> Eliminate &&s in tests.
- 'for i in $(find . -type f); do sed -e 's#\(RUN:.*[^ ]\) *&& *$#\1#g' $i | FileUpdate $i; done', for the curious.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86430 91177308-0d34-0410-b5e6-96231b3b80d8
alue-dependent-null-pointer-constant.cpp
3734c21b603ec8546613557a0e8a9f566f424324 07-Nov-2009 Douglas Gregor <dgregor@apple.com> Cope with calls to operator() templates. Fixes PR5419.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86387 91177308-0d34-0410-b5e6-96231b3b80d8
ember-function-template.cpp
d8fe2d56fb5463c9d109e8c6dab2e98b06bee186 07-Nov-2009 Anders Carlsson <andersca@mac.com> When instantiating a field decl, make sure to clone its attributes. With this change FileCheck no longer crashes when it's run without any arguments.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86344 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-attr.cpp
4912c347ce83e908c8a1a585260a32072eaf4ec6 06-Nov-2009 Douglas Gregor <dgregor@apple.com> Make sure that EnumConstantDecls always get a type, even when they have type-dependent initializers.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86197 91177308-0d34-0410-b5e6-96231b3b80d8
num-argument.cpp
c7621a64717203e1f7d5d79dbf548e590b32596c 05-Nov-2009 Douglas Gregor <dgregor@apple.com> Be a little more careful when trying to extract a TypeDecl from a enum/class/struct/union specifier; in invalid code, we may also see ClassTemplateDecls.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86171 91177308-0d34-0410-b5e6-96231b3b80d8
lass-template-decl.cpp
c2f38827ba0b868ec093741799ba74fa9ab6a16b 05-Nov-2009 Douglas Gregor <dgregor@apple.com> De-FIXME a test

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86166 91177308-0d34-0410-b5e6-96231b3b80d8
lass-template-decl.cpp
393896f49d5248435cf203cf1de60a86dc507c44 05-Nov-2009 Douglas Gregor <dgregor@apple.com> Fixed two places where we needed to force completion of a type
(without complaining if it fails) to get proper semantics: reference
binding with a derived-to-base conversion and the enumeration of
constructors for user-defined conversions. There are probably more
cases to fix, but my prior attempt at statically ensuring that
complete-type checking always happens failed. Perhaps I'll try again.

With this change, Clang can parse include/llvm/*.h!



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86129 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-complete.cpp
6ca7cfb3fbe4dc92e457fd303814d274176cf359 05-Nov-2009 Douglas Gregor <dgregor@apple.com> When instantiating a UnaryOperator, allow the resulting expression to
still be dependent or invoke an overloaded operator. Previously, we
only supported builtin operators.

BinaryOperator/CompoundAssignOperator didn't have this issue because
we always built a CXXOperatorCallExpr node, even when name lookup
didn't find any functions to save until instantiation time. Now, that
code builds a BinaryOperator or CompoundAssignOperator rather than a
CXXOperatorCallExpr, to save some space.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86087 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-1.cpp
b1c2ea5dddc9188e2ea30de7f6546f640b85dead 05-Nov-2009 Douglas Gregor <dgregor@apple.com> Make sure to grab CVR qualifiers from the canonical type. ARGH!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86079 91177308-0d34-0410-b5e6-96231b3b80d8
ember-access-expr.cpp
8a4386b3634065b96d08f94736bc1f953e385f50 05-Nov-2009 Douglas Gregor <dgregor@apple.com> When instantiating a MemberExpr, be sure to instantiate the
explicitly-specified template arguments, too!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86066 91177308-0d34-0410-b5e6-96231b3b80d8
emplate-id-expr.cpp
43d8863df9d02f81acdf5f73fbc288f285bf442e 04-Nov-2009 Douglas Gregor <dgregor@apple.com> When starting a C++ member access expression, make sure to compute the
type of the object even when it is dependent. Specifically, this makes
sure that we get the right type for "this->", which is important when
performing name lookup into this scope to determine whether an
identifier or operator-function-id is a template name.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86060 91177308-0d34-0410-b5e6-96231b3b80d8
ember-template-access-expr.cpp
4188aed02867010e5282e1611560963646e09e20 04-Nov-2009 John Thompson <John.Thompson.JTSoftware@gmail.com> Fixed for running on Windows.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86053 91177308-0d34-0410-b5e6-96231b3b80d8
xample-dynarray.cpp
ff5243981e2f6fb4a11ab7b81bf7accc226f2647 04-Nov-2009 Douglas Gregor <dgregor@apple.com> Fix a little canonical-types issue with non-type template arguments.
Fixes PR5349.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86052 91177308-0d34-0410-b5e6-96231b3b80d8
emp_arg_nontype.cpp
862354188764f4a20be21d103bc2abd074ad048a 04-Nov-2009 Douglas Gregor <dgregor@apple.com> Properly replace (cxxscope, template-id) annotation tokens with a
single typename annotation token when backtracing. Fixes PR5350.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86034 91177308-0d34-0410-b5e6-96231b3b80d8
emp_arg_nontype.cpp
1fe6b919f70bed58bd8bd43de1a79530b0d55a53 04-Nov-2009 Douglas Gregor <dgregor@apple.com> Don't try to check the initialization of fields with dependent
types. Fixes PR5352.

Fariborz, please review.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86031 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-deeply.cpp
c86a6e988184867b09aa17a619402d0e81d0fda0 04-Nov-2009 Douglas Gregor <dgregor@apple.com> When performing template instantiation (transformation) of
expressions, keep track of whether we are immediately taking the
address of the expression. Pass this flag when building a declaration
name expression so that we handle pointer-to-member constants
properly.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86017 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-declref.cpp
ca1bdd7c269a2390d43c040a60511edd017ee130 04-Nov-2009 Douglas Gregor <dgregor@apple.com> Implement support for parsing dependent template-ids that refer to
overloaded operators, e.g.,

p->template operator+<T>()




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85989 91177308-0d34-0410-b5e6-96231b3b80d8
perator-function-id-template.cpp
014e88d94ff83e3aad4e33b16413a2d1817ec208 04-Nov-2009 Douglas Gregor <dgregor@apple.com> Parsing and semantic analysis for template-ids that name overloaded
operators, e.g.,

operator+<int>

which now works in declarators, id-expressions, and member access
expressions. This commit only implements the non-dependent case, where
we can resolve the template-id to an actual declaration.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85966 91177308-0d34-0410-b5e6-96231b3b80d8
perator-function-id-template.cpp
d73902121a93c3135cf53e2d724361cec1037d7e 03-Nov-2009 Daniel Dunbar <daniel@zuster.org> Switch XFAIL format to match LLVM.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85880 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-function-1.mm
3f9a0566e6793151b99a65ab936220971cf96c1b 03-Nov-2009 Douglas Gregor <dgregor@apple.com> Introduce a new class, UnqualifiedId, that provides a parsed
representation of a C++ unqualified-id, along with a single parsing
function (Parser::ParseUnqualifiedId) that will parse all of the
various forms of unqualified-id in C++.

Replace the representation of the declarator name in Declarator with
the new UnqualifiedId class, simplifying declarator-id parsing
considerably and providing more source-location information to
Sema. In the future, I hope to migrate all of the other
unqualified-id-parsing code over to this single representation, then
begin to merge actions that are currently only different because we
didn't have a unqualified notion of the name in the parser.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85851 91177308-0d34-0410-b5e6-96231b3b80d8
onstructor-template.cpp
cf3293eaeb3853d12cff47e648bbe835004e929f 01-Nov-2009 Douglas Gregor <dgregor@apple.com> When determining whether a reference to a static data member is an
integral constant expression, make sure to find where the initializer
was provided---inside or outside the class definition---since that can
affect whether we have an integral constant expression (and, we need
to see the initializer itself).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85741 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-declref-ice.cpp
7a343142901f7f6bd1965051a24ae6a12c6f2148 01-Nov-2009 Douglas Gregor <dgregor@apple.com> Within a template, qualified name lookup can refer to a non-dependent type
that is not known to be a base class at template definition time due
to some dependent base class. Treat qualified name lookup that refers
to a non-static data member or function as implicit class member
access when the "this" type would be dependent.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85718 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-method.cpp
550d9b28fd586db541eb6dd36f3c10d114e483d8 31-Oct-2009 Douglas Gregor <dgregor@apple.com> Implement "incremental" template instantiation for non-type template
parameters and template type parameters, which occurs when
substituting into the declarations of member templates inside class
templates. This eliminates errors about our inability to "reduce
non-type template parameter depth", fixing PR5311.

Also fixes a bug when instantiating a template type parameter
declaration in a member template, where we weren't properly reducing
the template parameter's depth.

LLVM's StringSwitch header now parses.




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85669 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-non-type-template-parameter.cpp
ember-template-access-expr.cpp
682054c52e8e7ebd7280e13d2cb26f8a9a17485a 30-Oct-2009 Douglas Gregor <dgregor@apple.com> When looking for a copy-assignment operator to determine the cv-qualifiers on its argument type, ignore assignment operator templates

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85629 91177308-0d34-0410-b5e6-96231b3b80d8
opy-ctor-assign.cpp
259571e27e513cfaf691cc7447e09b31a47d5438 30-Oct-2009 Douglas Gregor <dgregor@apple.com> When a friend is declared in a dependent context, don't even try to
match it up with a declaration in the outer scope.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85628 91177308-0d34-0410-b5e6-96231b3b80d8
riend-template.cpp
e8c01bdb56549adcecd71ce39160eea54b2c51c8 30-Oct-2009 Douglas Gregor <dgregor@apple.com> Instantiate class template friends better; fixes PR5332.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85612 91177308-0d34-0410-b5e6-96231b3b80d8
riend-template.cpp
2685eab9d36a3568b5d58fba13f0ecef6a611cf9 30-Oct-2009 Douglas Gregor <dgregor@apple.com> We may need to instantiate a class template specialization as part of a derived-to-base pointer case

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85532 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-cast.cpp
f322ed6d39a30f509023cf88588c1e6514226127 29-Oct-2009 Sebastian Redl <sebastian.redl@getdesigned.at> Properly instantiate usage of overloaded operator []. Fixes PR5345.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85524 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-subscript.cpp
fd2300e1ee0eab6c51862a92d3f3c72540b36b23 29-Oct-2009 Douglas Gregor <dgregor@apple.com> Yet more instantiation-location information. Fixes PR5336.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85516 91177308-0d34-0410-b5e6-96231b3b80d8
emplate-id-expr.cpp
0ebb6d391d2e29ed48a880517e2ba919bf7016d9 29-Oct-2009 Anders Carlsson <andersca@mac.com> Make sure to call CompleteConstructorCall for bases and members that are initialized implicitly in constructors so that default arguments etc are set correctly. Fixes PR5283.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85510 91177308-0d34-0410-b5e6-96231b3b80d8
efault-expr-arguments.cpp
b3eca29e2b1f11d2daa06feb23e006f69be759c7 27-Oct-2009 John Thompson <John.Thompson.JTSoftware@gmail.com> Disabling some MS extensions which cause these tests to fail

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85236 91177308-0d34-0410-b5e6-96231b3b80d8
ested-name-spec-template.cpp
972e6ce33c7e307f4b0da12bd6079bbd6ef76948 27-Oct-2009 Douglas Gregor <dgregor@apple.com> Only set the point of instantiation for an implicit or explicit
instantiation once we have committed to performing the
instantiation. As part of this, make our makeshift
template-instantiation location information suck slightly less.

Fixes PR5264.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85209 91177308-0d34-0410-b5e6-96231b3b80d8
lass-template-spec.cpp
3eefb1c4bd2c562e43f25e0dba657bb32361dd14 24-Oct-2009 Douglas Gregor <dgregor@apple.com> Fix overload resolution when calling a member template or taking the
address of a member template when explicit template arguments are
provided.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84991 91177308-0d34-0410-b5e6-96231b3b80d8
ember-template-access-expr.cpp
33642df30088f2ddb0b22c609523ab8df9dff595 24-Oct-2009 Douglas Gregor <dgregor@apple.com> Implement template instantiation for non-type template
parameters. Fixes PR5103.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84979 91177308-0d34-0410-b5e6-96231b3b80d8
ested-template.cpp
097bfb11759be2187732329ecf4c0849609cdf57 24-Oct-2009 Douglas Gregor <dgregor@apple.com> Migrate Sema::ActOnCallExpr to Sema::FixOverloadedFunctionReference,
so that we maintain better source information after template argument
deduction and overloading resolves down to a specific
declaration. Found and dealt with a few more cases that
FixOverloadedFunctionReference didn't cope with.

(Finally) added a test case that puts together this change with the
DeclRefExpr change to (optionally) include nested-name-specifiers and
explicit template argument lists.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84974 91177308-0d34-0410-b5e6-96231b3b80d8
emplate-id-printing.cpp
eee91c3efbfc6a1509b42f39beb5533a9636fd70 23-Oct-2009 John McCall <rjmccall@apple.com> Rebuild dependently-sized ext vectors if either the element type or the size
changed under the transform.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84953 91177308-0d34-0410-b5e6-96231b3b80d8
xt-vector-type.cpp
a9e29aa4b1e5042a763240899d8b8cf1267c3ec5 22-Oct-2009 Douglas Gregor <dgregor@apple.com> When a template-id expression refers to a member function template, turn it into an (implicit) member access expression. Fixes PR5220

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84848 91177308-0d34-0410-b5e6-96231b3b80d8
ember-access-expr.cpp
6cd219879ffce00920189ec1dcea927a42602961 20-Oct-2009 Douglas Gregor <dgregor@apple.com> Handle substitutions into the "first qualifier in scope" of a
qualified member access expression (e.g., t->U::member) when that
first qualifier refers to a template parameters.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84612 91177308-0d34-0410-b5e6-96231b3b80d8
ember-template-access-expr.cpp
dd62b15665a4144c45c1f7c53665414ad5f7f4f2 20-Oct-2009 Douglas Gregor <dgregor@apple.com> Parse a simple-template-id following a '~' when calling a destructor, e.g.,

t->~T<A0, A1>()

Fixes PR5213.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84545 91177308-0d34-0410-b5e6-96231b3b80d8
ember-template-access-expr.cpp
089407be3fb616fb1246f2aee29b8a9c58ec7807 17-Oct-2009 Douglas Gregor <dgregor@apple.com> When type-checking a C++ "new" expression, don't type-check the actual
initialization if any of the constructor/initialization arguments are
type-dependent. Fixes PR5224.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84365 91177308-0d34-0410-b5e6-96231b3b80d8
un-template-def.cpp
nstantiate-expr-2.cpp
89a5bea02115795752475d985301ef83045bb577 16-Oct-2009 Douglas Gregor <dgregor@apple.com> Make the remaining explicit-instantiation semantic action use
CheckSpecializationInstantiationRedecl to check for
redeclarations/instantiations. Also fixes a longstanding issue where
our explicit-instantiation location information wasn't as good as it
could have been.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84216 91177308-0d34-0410-b5e6-96231b3b80d8
xtern-templates.cpp
ariadic-class-template-2.cpp
558c03222c77873a934b002073667a3c971fe8a9 15-Oct-2009 Douglas Gregor <dgregor@apple.com> Additional semantic checking for explicit template instantiations,
focusing on the scope- and qualifier-related semantic requirements in
C++ [temp.explicit]p2.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84154 91177308-0d34-0410-b5e6-96231b3b80d8
xplicit-instantiation.cpp
emp_explicit.cpp
542b548e041a6fab0fe06601ccc6b91a81bc217a 14-Oct-2009 Douglas Gregor <dgregor@apple.com> When mapping from an injected-class-name to its corresponding
template, make sure to get the template that corresponds to *this*
declaration of the class template or specialization, rather than the
canonical specialization. Fixes PR5187.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84119 91177308-0d34-0410-b5e6-96231b3b80d8
efault-arguments.cpp
d9842d0e6da0e28b6913b464e37d9a4dc5ec73b9 14-Oct-2009 Douglas Gregor <dgregor@apple.com> Implement support for overloaded operator uses that result to a call
to a member operator template. We missed updating this call site when
adding support for function templates; bug exposed by a test for
PR5072.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84111 91177308-0d34-0410-b5e6-96231b3b80d8
opy-ctor-assign.cpp
a786fdbf6c1d8ff08c3e61c7eb6bf2872895e2b4 14-Oct-2009 Douglas Gregor <dgregor@apple.com> Improve diagnostics when the parser encounters a declarator with an
unknown type name, e.g.,

foo::bar x;

when "bar" does not refer to a type in "foo".

With this change, the parser now calls into the action to perform
diagnostics and can try to recover by substituting in an appropriate
type. For example, this allows us to easily diagnose some missing
"typename" specifiers, which we now do:

test/SemaCXX/unknown-type-name.cpp:29:1: error: missing 'typename'
prior to dependent type name 'A<T>::type'
A<T>::type A<T>::f() { return type(); }
^~~~~~~~~~
typename

Fixes PR3990.





git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84053 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-typedef.cpp
ypename-specifier.cpp
3f09327b26033d0a9676d52d80cf92c48f581aff 13-Oct-2009 Douglas Gregor <dgregor@apple.com> Unify our diagnostic printing for errors of the form, "we didn't like
what we found when we looked into <blah>", where <blah> is a
DeclContext*. We can now format DeclContext*'s in nice ways, e.g.,
"namespace N", "the global namespace", "'class Foo'".

This is part of PR3990, but we're not quite there yet.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84028 91177308-0d34-0410-b5e6-96231b3b80d8
ypename-specifier.cpp
a735b206fdb5c15767a45289e1ffb3b568f70f2b 13-Oct-2009 Douglas Gregor <dgregor@apple.com> Improve the internal representation and semantic analysis of friend
function templates.

This commit ensures that friend function templates are constructed as
FunctionTemplateDecls rather than partial FunctionDecls (as they
previously were). It then implements template instantiation for friend
function templates, injecting the friend function template only when
no previous declaration exists at the time of instantiation.

Oh, and make sure that explicit specialization declarations are not
friends.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83970 91177308-0d34-0410-b5e6-96231b3b80d8
riend-template.cpp
b3ae4fcd4314a9c1c46d41b200883599c32025b4 12-Oct-2009 Douglas Gregor <dgregor@apple.com> Diagnose the declaration of explicit specializations after an implicit
instantiation has already been required. To do so, keep track of the
point of instantiation for anything that can be instantiated.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83890 91177308-0d34-0410-b5e6-96231b3b80d8
lass-template-spec.cpp
d7e5bdb23c6ba2786cf94788c9af555e2c1276ce 09-Oct-2009 Douglas Gregor <dgregor@apple.com> When declaring a friend class template, we may end up finding an
injected-class-name (e.g., when we're referring to other
specializations of the current class template). Make sure that we see
the template rather than the injected-class-name. Fixes PR4768.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83672 91177308-0d34-0410-b5e6-96231b3b80d8
riend-template.cpp
e9374d5e2c0915bd883dfa988db2451b844390d8 08-Oct-2009 Douglas Gregor <dgregor@apple.com> Make sure to set the template specialization kind of an explicit
template instantiation of a member function of a class template.
FIXME -= 2;


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83520 91177308-0d34-0410-b5e6-96231b3b80d8
xtern-templates.cpp
2db323294ac02296125e1e0beb4c3595992e75bb 08-Oct-2009 Douglas Gregor <dgregor@apple.com> Keep track of whether a member function instantiated from a member
function of a class template was implicitly instantiated, explicitly
instantiated (declaration or definition), or explicitly
specialized. The same MemberSpecializationInfo structure will be used
for static data members and member classes as well.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83509 91177308-0d34-0410-b5e6-96231b3b80d8
xtern-templates.cpp
1fef4e60e7e884803977a8376c172ea584f8a5d1 08-Oct-2009 Douglas Gregor <dgregor@apple.com> Type checking for specializations of member functions of class
templates. Previously, these weren't handled as specializations at
all. The AST for representing these as specializations is still a work
in progress.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83498 91177308-0d34-0410-b5e6-96231b3b80d8
lass-template-spec.cpp
d5cb8765ad3841ead8eaacb0360ac385f2f0e080 07-Oct-2009 Douglas Gregor <dgregor@apple.com> Refactor checking of the scope of explicit template specialization
declarations and explicit template instantiations, improving
diagnostics and making the code usable for function template
specializations (as well as class template specializations and partial
specializations).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83436 91177308-0d34-0410-b5e6-96231b3b80d8
lass-template-spec.cpp
emp_class_spec_neg.cpp
b2f81cf7f8445e0c65c0428f4fbb0442566916b8 02-Oct-2009 Douglas Gregor <dgregor@apple.com> Make sure to free the explicit template arguments provided for an
explicit instantiation. Also, tighten up reference-count checking to
help catch these issues earlier. Fixes PR5069.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83225 91177308-0d34-0410-b5e6-96231b3b80d8
xplicit-instantiation.cpp
3307475eb0dd6e5d88be9392ea8247d0b6b812df 30-Sep-2009 Douglas Gregor <dgregor@apple.com> When overload resolution fails for an overloaded operator, show the
overload candidates (but not the built-in ones). We still rely on the
underlying built-in semantic analysis to produce the initial
diagnostic, then print the candidates following that diagnostic.

One side advantage of this approach is that we can perform more validation
of C++'s operator overloading with built-in candidates vs. the
semantic analysis for those built-in operators: when there are no
viable candidates, we know to expect an error from the built-in
operator handling code. Otherwise, we are not modeling the built-in
semantics properly within operator overloading. This is checked as:

assert(Result.isInvalid() &&
"C++ binary operator overloading is missing
candidates!");
if (Result.isInvalid())
PrintOverloadCandidates(CandidateSet, /*OnlyViable=*/false);

The assert() catches cases where we're wrong in a +Asserts build. The
"if" makes sure that, if this happens in a production clang
(-Asserts), we still build the proper built-in operator and continue
on our merry way. This is effectively what happened before this
change, but we've added the assert() to catch more flies.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83175 91177308-0d34-0410-b5e6-96231b3b80d8
ualified-names-diag.cpp
483168227946f70e9dd7d12e7bf72bb1d76e0740 29-Sep-2009 Douglas Gregor <dgregor@apple.com> Slightly improve the semantics of extern templates for member functions of class templates

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83063 91177308-0d34-0410-b5e6-96231b3b80d8
xtern-templates.cpp
9d7b35303c6f1eaee85039d0f934c456e063cd0a 28-Sep-2009 Douglas Gregor <dgregor@apple.com> Parse a C++ scope specifier followed by a "typename" annotation token as a type name within the declaration specifiers. Fixes PR5061.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82974 91177308-0d34-0410-b5e6-96231b3b80d8
ualified-id.cpp
182ddf0e5dc5667e6683a58b483a2e52564f4303 28-Sep-2009 Douglas Gregor <dgregor@apple.com> Improve handling of friend function templates somewhat

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82950 91177308-0d34-0410-b5e6-96231b3b80d8
riend-template.cpp
fc9cd61f2372cd8f43f0d92be14fa75778de6be6 26-Sep-2009 Douglas Gregor <dgregor@apple.com> Simplify the handling of non-dependent friend class template
specializations such as:

friend class std::vector<int>;

by using the same code path as explicit specializations, customized to
reference an existing ClassTemplateSpecializationDecl (or build a new
"undeclared" one).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82875 91177308-0d34-0410-b5e6-96231b3b80d8
riend.cpp
d85bea2affdd59d83d1be7d24b97f436484c3625 26-Sep-2009 Douglas Gregor <dgregor@apple.com> Rework the Parse-Sema interaction for friends to better support friend
class templates. We now treat friend class templates much more like
normal class templates, except that they still get special name lookup
rules. Fixes PR5057 and eliminates a bunch of spurious diagnostics in
<iostream>.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82848 91177308-0d34-0410-b5e6-96231b3b80d8
riend-template.cpp
0b60d9e0097e2d6a1a5e62396967e207c4a772f2 26-Sep-2009 Douglas Gregor <dgregor@apple.com> Use explicitly-specified template argument lists to help naming
explicit template specializations, when available.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82824 91177308-0d34-0410-b5e6-96231b3b80d8
unction-template-specialization.cpp
db422dffb720ff41d0b60e228f45c685600ffa9e 25-Sep-2009 Douglas Gregor <dgregor@apple.com> Declarators can now properly represent template-ids, e.g., for

template void f<int>(int);
~~~~~~
Previously, we silently dropped the template arguments. With this
change, we now use the template arguments (when available) as the
explicitly-specified template arguments used to aid template argument
deduction for explicit template instantiations.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82806 91177308-0d34-0410-b5e6-96231b3b80d8
xplicit-instantiation.cpp
d5a423b279e787e9fdd8309fe52cb515388c54ea 25-Sep-2009 Douglas Gregor <dgregor@apple.com> WIP implementation of explicit instantiation of function templates,
member functions of class template specializations, and static data
members. The mechanics are (mostly) present, but the semantic analysis
is very weak.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82789 91177308-0d34-0410-b5e6-96231b3b80d8
xplicit-instantiation.cpp
ce94049b69f75b44c18584fe79cd238978b6b0d5 25-Sep-2009 Douglas Gregor <dgregor@apple.com> Fix checking for a null pointer constant when the expression itself is
value-dependent. Audit (and fixed) all calls to
Expr::isNullPointerConstant() to provide the correct behavior with
value-dependent expressions. Fixes PR5041 and a crash in libstdc++
<locale>.

In the same vein, properly compute value- and type-dependence for
ChooseExpr. Fixes PR4996.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82748 91177308-0d34-0410-b5e6-96231b3b80d8
alue-dependent-null-pointer-constant.cpp
7dfd0fb08300b60a9657748bda7d8b3ceb07babe 25-Sep-2009 Douglas Gregor <dgregor@apple.com> When entering the scope of a declarator, make sure that the scope is
complete (or, possibly causing template instantiation).

Test this via some explicit specializations of member functions.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82732 91177308-0d34-0410-b5e6-96231b3b80d8
xplicit-specialization-member.cpp
b9aa6b214c8fbc3e081dde575eef1f0913d48bdc 25-Sep-2009 Douglas Gregor <dgregor@apple.com> WIP implementation of explicit function template specialization. This
first implementation recognizes when a function declaration is an
explicit function template specialization (based on the presence of a
template<> header), performs template argument deduction + ambiguity
resolution to determine which template is being specialized, and hooks

There are many caveats here:
- We completely and totally drop any explicitly-specified template
arguments on the floor
- We don't diagnose any of the extra semantic things that we should
diagnose.
- I haven't looked to see that we're getting the right linkage for
explicit specializations

On a happy note, this silences a bunch of errors that show up in
libstdc++'s <iostream>, although Clang still can't get through the
entire header.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82728 91177308-0d34-0410-b5e6-96231b3b80d8
unction-template-specialization.cpp
d85cef5a54074a5f647f45c2218675f7774a909d 17-Sep-2009 Douglas Gregor <dgregor@apple.com> Merge uninstantiated default arguments more carefully, and try not to
complain about specializations of member functions that are not
definitions. Fixes PR4995.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82159 91177308-0d34-0410-b5e6-96231b3b80d8
efault-expr-arguments.cpp
e95b40961302c2130968ddfc3ba162e138f2118e 16-Sep-2009 Douglas Gregor <dgregor@apple.com> Teach Sema::FindInstantiatedDecl to find instantiated RecordDecls even
when we are not instantiating the corresponding "current
instantiation." This happens, e.g., when we are instantiating a
declaration reference that refers into the "current instantiation" but
occurs in a default function argument. The libstdc++ vector default
constructor now instantiates properly.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82069 91177308-0d34-0410-b5e6-96231b3b80d8
efault-expr-arguments.cpp
c7e406b2ec8ae95ff2f65215330b127c437472b9 15-Sep-2009 Douglas Gregor <dgregor@apple.com> Commit test case from PR4655, which tests the canonical-types fix in r81913

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81916 91177308-0d34-0410-b5e6-96231b3b80d8
onstructor-template.cpp
1fdd89ba1d14ee11fda5b9e1c171db428b1acb23 15-Sep-2009 Douglas Gregor <dgregor@apple.com> When printing an overload candidate that is a function template specialization,
point at the template and print out its template arguments, e.g.,

ambiguous-ovl-print.cpp:5:8: note: candidate function template specialization
[with T = int]
void f(T*, long);




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81907 91177308-0d34-0410-b5e6-96231b3b80d8
mbiguous-ovl-print.cpp
f882574cf640d5c8355965e1c486f9d8d8ffcf47 15-Sep-2009 Douglas Gregor <dgregor@apple.com> Add an assertion and a test case, in a fruitless attempt to track down an existing bug

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81885 91177308-0d34-0410-b5e6-96231b3b80d8
onstructor-template.cpp
bf4ea56cdc376cef5a12abf6bf18dc34805c2226 15-Sep-2009 Douglas Gregor <dgregor@apple.com> Implement partial ordering of class template partial specializations
(C++ [temp.class.order]).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81866 91177308-0d34-0410-b5e6-96231b3b80d8
emp_class_order.cpp
emp_class_spec.cpp
5d7d37506319d432f8f5e3952b7427e1e4aacd2e 15-Sep-2009 Douglas Gregor <dgregor@apple.com> Implement partial ordering of function templates when calling a
conversion function.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81807 91177308-0d34-0410-b5e6-96231b3b80d8
emp_func_order.cpp
8a51491d936d8c50480f3c3ca6647be12a7ad51f 14-Sep-2009 Douglas Gregor <dgregor@apple.com> Implement partial ordering of function template specializations
(C++ [temp.func.order]).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81777 91177308-0d34-0410-b5e6-96231b3b80d8
emp_func_order.cpp
255d6415a692e8384971755f91541497d54b3193 14-Sep-2009 Anders Carlsson <andersca@mac.com> Fix a bug in getFriendObjectKind where we would clear out all mask bits except IDNS_TagFriend and IDNS_OrdinaryFriend but then check for IDNS_Tag and IDNS_Ordinary.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81730 91177308-0d34-0410-b5e6-96231b3b80d8
riend.cpp
52604ab71a74b8ec481255dfeea7dc9dba63b1a5 11-Sep-2009 Douglas Gregor <dgregor@apple.com> Slight improvement for extern templates, so that an explicit
instantiation definition can follow an explicit instantiation
declaration. This is as far as I want to go with extern templates now,
but they will still need quite a bit more work to get all of the C++0x
semantics right.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81573 91177308-0d34-0410-b5e6-96231b3b80d8
xtern-templates.cpp
678119abd43401c8dc5480f8315b37fa093a4d21 11-Sep-2009 Douglas Gregor <dgregor@apple.com> Improve testing for extern temp templates, slightly. We are (properly) suppressing the implicit instantiation of members of extern templates

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81567 91177308-0d34-0410-b5e6-96231b3b80d8
xtern-templates.cpp
6cc1518b9f15ca846b8c35518eeae9557935678d 11-Sep-2009 Douglas Gregor <dgregor@apple.com> Cleanup and test C++ default arguments. Improvements include:

- Diagnose attempts to add default arguments to templates (or member
functions of templates) after the initial declaration (DR217).
- Improve diagnostics when a default argument is redefined. Now, the
note will always point at the place where the default argument was
previously defined, rather than pointing to the most recent
declaration of the function.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81548 91177308-0d34-0410-b5e6-96231b3b80d8
efault-expr-arguments.cpp
9cc7807e1622c2f945b607bdd39dd283df5e7bb5 11-Sep-2009 John McCall <rjmccall@apple.com> Track a class template specialization's point of instantiation separately
from its location. Initialize appropriately.

When implicitly creating a declaration of a class template specialization
after encountering the first reference to it, use the pattern class's
location instead of the location of the first reference.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81515 91177308-0d34-0410-b5e6-96231b3b80d8
emp_class_spec.cpp
1cdcc579df30dba1b2e1e9909125bb9c61898e05 10-Sep-2009 Douglas Gregor <dgregor@apple.com> When re-entering a template scope, we may be entering a class template
partial specialization rather than a subclass of TemplateDecl. Fixes a
crash in libstdc++ 4.2's <map>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81407 91177308-0d34-0410-b5e6-96231b3b80d8
ested-template.cpp
3b6afbb99a1c44b4076f8e15fb7311405941b306 09-Sep-2009 Douglas Gregor <dgregor@apple.com> Initial stab at implement dependent member references to member
templates, e.g.,

x.template get<T>

We can now parse these, represent them within an UnresolvedMemberExpr
expression, then instantiate that expression node in simple cases.

This allows us to stumble through parsing LLVM's Casting.h.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81300 91177308-0d34-0410-b5e6-96231b3b80d8
ember-template-access-expr.cpp
21e1c4ea0a96bcecfe5976304d84779949058648 06-Sep-2009 Anders Carlsson <andersca@mac.com> Reapply 81096, now with a fix. Spot the bug:

for (unsigned i = numargs; i < NumArgs; ++i)
Args[0] = 0;

;)


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81123 91177308-0d34-0410-b5e6-96231b3b80d8
efault-expr-arguments.cpp
4355be0758856cf7645e264d4813831dc27ce78c 06-Sep-2009 Daniel Dunbar <daniel@zuster.org> Revert "Initialize default CXXConstructExpr arguments to 0. Fixes a crash when
destroying the CXXConstructExpr.", this is causing test failures across the
board.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81100 91177308-0d34-0410-b5e6-96231b3b80d8
efault-expr-arguments.cpp
657bff7ff399d08812a3b3324dbbebf68b0df07d 06-Sep-2009 Anders Carlsson <andersca@mac.com> Initialize default CXXConstructExpr arguments to 0. Fixes a crash when destroying the CXXConstructExpr.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81096 91177308-0d34-0410-b5e6-96231b3b80d8
efault-expr-arguments.cpp
6bc107b49862418bf3f64f74f17e472b4c13aa71 05-Sep-2009 Anders Carlsson <andersca@mac.com> Report errors for member functions correctly.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81063 91177308-0d34-0410-b5e6-96231b3b80d8
efault-expr-arguments.cpp
25cae7f4b1155b1a6ca959ea5143ea39eae656cd 05-Sep-2009 Anders Carlsson <andersca@mac.com> Use a separate diagnostic for default function argument expressions.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81062 91177308-0d34-0410-b5e6-96231b3b80d8
efault-expr-arguments.cpp
4fe95f99a2693f1145785ea5835ba6937e49c730 04-Sep-2009 Douglas Gregor <dgregor@apple.com> Don't generate any code for an explicit call to a trivial destructor.

Now that parsing, semantic analysis, and (I think) code generation of
pseudo-destructor expressions and explicit destructor calls works,
update the example-dynarray.cpp test to destroy the objects it
allocates and update the test to actually compile + link.
The code seems correct, but the Clang-compiled version dies with a
malloc error. Time to debug!



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81025 91177308-0d34-0410-b5e6-96231b3b80d8
xample-dynarray.cpp
a71d819bb8f50c28938db0f2867d3fb6e2ce5910 04-Sep-2009 Douglas Gregor <dgregor@apple.com> Implement AST, semantics, and CodeGen for C++ pseudo-destructor
expressions, e.g.,

p->~T()

when p is a pointer to a scalar type.

We don't currently diagnose errors when pseudo-destructor expressions
are used in any way other than by forming a call.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81009 91177308-0d34-0410-b5e6-96231b3b80d8
ember-access-expr.cpp
45f965581935791a018df829a14dff53c1dd8f47 04-Sep-2009 Douglas Gregor <dgregor@apple.com> Parse extern templates, pass that information all the way to Sema,
then drop it on the floor.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80989 91177308-0d34-0410-b5e6-96231b3b80d8
xtern-templates.cpp
81499bbeb2bd157a77b60364676ac434aca7a4df 04-Sep-2009 Douglas Gregor <dgregor@apple.com> Implement tree transformations for DeclarationNames. Among other
things, this means that we can properly cope with member access
expressions such as

t->operator T()

where T is a template parameter (or other dependent type).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80957 91177308-0d34-0410-b5e6-96231b3b80d8
ember-access-expr.cpp
c68afe2cbe7f875a9243c411077602fb5f5dc74b 03-Sep-2009 Douglas Gregor <dgregor@apple.com> Improve template instantiation for member access expressions that
involve qualified names, e.g., x->Base::f. We now maintain enough
information in the AST to compare the results of the name lookup of
"Base" in the scope of the postfix-expression (determined at template
definition time) and in the type of the object expression.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80953 91177308-0d34-0410-b5e6-96231b3b80d8
ember-access-expr.cpp
2700dcde044893642b9b77638e052aa90be7cd51 03-Sep-2009 Douglas Gregor <dgregor@apple.com> Add a wicked little test-case that illustrates what we have to deal
with to properly support member access expressions in templates. This
test is XFAIL'd, because we get it completely wrong, but I've made the
minimal changes to the representation to at least avoid a crash.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80856 91177308-0d34-0410-b5e6-96231b3b80d8
ember-access-expr.cpp
2dd078ae50ff7be1fb25ebeedde45e9ab691a4f0 03-Sep-2009 Douglas Gregor <dgregor@apple.com> Rewrite of our handling of name lookup in C++ member access expressions, e.g.,

x->Base::f

We no longer try to "enter" the context of the type that "x" points
to. Instead, we drag that object type through the parser and pass it
into the Sema routines that need to know how to perform lookup within
member access expressions.

We now implement most of the crazy name lookup rules in C++
[basic.lookup.classref] for non-templated code, including performing
lookup both in the context of the type referred to by the member
access and in the scope of the member access itself and then detecting
ambiguities when the two lookups collide (p1 and p4; p3 and p7 are
still TODO). This change also corrects our handling of name lookup
within template arguments of template-ids inside the
nested-name-specifier (p6; we used to look into the scope of the
object expression for them) and fixes PR4703.

I have disabled some tests that involve member access expressions
where the object expression has dependent type, because we don't yet
have the ability to describe dependent nested-name-specifiers starting
with an identifier.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80843 91177308-0d34-0410-b5e6-96231b3b80d8
ember-function-template.cpp
ae4406744024feee732cb8742572377e9646cd5b 02-Sep-2009 Douglas Gregor <dgregor@apple.com> Add a few more typename-specifier tests that involve simple-template-ids in the nested-name-specifier

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80784 91177308-0d34-0410-b5e6-96231b3b80d8
ypename-specifier-4.cpp
6946baf3542dcb1ed0d98d0fdda451d1c39a49c2 02-Sep-2009 Douglas Gregor <dgregor@apple.com> When parsing typename specifiers (with either the identifier or
simple-template-id form), check whether the scope specifier is
computable as a declaration context rather than checking whether it is
dependent, so that we properly cope with members of the current
instantiation.

Improve testing for typename specifiers that terminate in a
simpe-template-id.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80783 91177308-0d34-0410-b5e6-96231b3b80d8
ypename-specifier-4.cpp
44c73848d5d5bd34c05582dc8398a20bea7cd971 01-Sep-2009 Douglas Gregor <dgregor@apple.com> Implement proper substitution for OverloadedFunctionDecls, but substituting each of the functions in the overload set

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80692 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-2.cpp
8f1d89e40ac853903916b88b850fb9638609173d 01-Sep-2009 Douglas Gregor <dgregor@apple.com> Fix a crasher involving template instantiation of non-dependent
expressions making use of an overloaded operator. Thanks for the test
case, Anders!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80679 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-2.cpp
cdc83c777973fa56b6f828bfe88210290ca58d62 01-Sep-2009 Anders Carlsson <andersca@mac.com> Don't assume that a base is always a RecordType, it can also be a TemplateSpecializationType. Also, make sure to get the instantiated union member.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80662 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-anonymous-union.cpp
9988d5d9ad0850e455bd413b03ba7dc8ecee5999 01-Sep-2009 Anders Carlsson <andersca@mac.com> Handle member initializers that point to fields in anonymous structs.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80659 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-anonymous-union.cpp
d8b285fee4471f393da8ee30f552ceacdc362afa 01-Sep-2009 Anders Carlsson <andersca@mac.com> Don't assert when instantiating member references to fields in anonymous structs.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80657 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-anonymous-union.cpp
c4bf26fbdff42967d660f505a83f75a4df2cc752 01-Sep-2009 Douglas Gregor <dgregor@apple.com> Preliminary AST representation and semantic analysis for
explicitly-specified template argument lists in member reference
expressions, e.g.,

x->f<int>()



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80646 91177308-0d34-0410-b5e6-96231b3b80d8
ember-function-template.cpp
f328a2857d6dc397ec7a304b07d40893891f7f98 31-Aug-2009 Douglas Gregor <dgregor@apple.com> Add parsing for references to member function templates with explicit
template argument lists, e.g., x.f<int>().

Semantic analysis will be a separate commit.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80624 91177308-0d34-0410-b5e6-96231b3b80d8
ember-function-template.cpp
017dde547d359a66ec38b80a098a5ddbef087048 31-Aug-2009 Douglas Gregor <dgregor@apple.com> Implement template instantiation for member operator access.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80609 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-2.cpp
c5573a81a83c4173c92c7e91b01371b7223d88c4 30-Aug-2009 Eli Friedman <eli.friedman@gmail.com> Make instantiating initializers for classes with a dependent base type
work correctly.

The change in lib/AST/DeclCXX.cpp is mostly a large reindentation; I
couldn't figure out a good way to avoid it.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80446 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-member-initializers.cpp
0d8df780aef1acda5962347a32591efc629b6748 29-Aug-2009 Anders Carlsson <andersca@mac.com> Improve instantiation of UnresolvedUsingDecls.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80434 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-using-decl.cpp
d0b7839f8a82141193e578d9eb1bc168dda9c8df 29-Aug-2009 John McCall <rjmccall@apple.com> Test case.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80426 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-deeply.cpp
090253155017b7eec031bbd7bf07824a448e1d7a 29-Aug-2009 Anders Carlsson <andersca@mac.com> Instantiate member and base initializers. Patch by Anders Johnsen! (tweaked slightly by me)


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80422 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-member-initializers.cpp
a5bf7f13d7772b164750997f95ab18487bbc4114 29-Aug-2009 Douglas Gregor <dgregor@apple.com> Don't crash when instantiating templates containing anonymous structs/unions

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80397 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-anonymous-union.cpp
3cd4d1ece34d36317ec5352855d86e256cb6aa27 28-Aug-2009 Douglas Gregor <dgregor@apple.com> Test instantiation of static data members that live within nested
member templates.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80396 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-member-template.cpp
8320ad400439def135a75aa1dd0cafbcc1c9e5e0 28-Aug-2009 Douglas Gregor <dgregor@apple.com> Test instantiations of out-of-line member definitions of nested templates.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80395 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-member-template.cpp
5ec178ff237d77e7acf5e747c19bf4f2de77a779 28-Aug-2009 Douglas Gregor <dgregor@apple.com> Fix and test template instantiation for nested member templates.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80394 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-member-template.cpp
357bbd022c1d340c8e255aea7a684ddb34bc76e5 28-Aug-2009 Douglas Gregor <dgregor@apple.com> Tighten up the conversion from a single-level template argument list
to a multi-level template argument list by making it explicit. The
forced auditing of callers found a bug in the instantiation of member
classes inside member templates.

I *love* static type systems.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80391 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-member-template.cpp
d6350aefb1396b299e199c7f1fe51bb40c12e75e 28-Aug-2009 Douglas Gregor <dgregor@apple.com> Implement template instantiation for member class templates.

When performing template instantiation of the definitions of member
templates (or members thereof), we build a data structure containing
the template arguments from each "level" of template
instantiation. During template instantiation, we substitute all levels
of template arguments simultaneously.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80389 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-member-template.cpp
d1102433214bd33b5bef5b493944292a1e82c2fb 28-Aug-2009 Douglas Gregor <dgregor@apple.com> Collect multiple levels of template arguments into a new type,
MultiLevelTemplateArgumentList. This is a baby step toward
instantiating member templates; no intended functionality change yet.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80380 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-member-template.cpp
4fc7ab364110d6ad1c10dd38dbeb0597fed7e2f5 28-Aug-2009 Fariborz Jahanian <fjahanian@apple.com> ir-gen related patch for type conversion
with class type conversion methods. WIP.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80365 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-cast.cpp
eaba1af8529c381d7bfd4dd0a8b48d2c01647972 27-Aug-2009 Eli Friedman <eli.friedman@gmail.com> Fix for PR4794 (instantiating friend class decl); this version shouldn't
cause any regressions.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80277 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-friend-class.cpp
56bea43ac127367e34a4732b20f4c8a4c6a5fe05 27-Aug-2009 Eli Friedman <eli.friedman@gmail.com> Back out bad piece of r80272. Will look at fixing this a different way.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80273 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-friend-class.cpp
c5c54f2c7bbc000dbcaee5e0acec2dbb0c0f0cf8 27-Aug-2009 Eli Friedman <eli.friedman@gmail.com> PR4794: Make instantiating friend class decls not crash.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80272 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-friend-class.cpp
d60e105e6d1624da647ef7dd35a9cf6fad1b763e 27-Aug-2009 Douglas Gregor <dgregor@apple.com> Implement instantiation of the declarations of member function
templates within class templates, producing a member function template
of a class template specialization. If you can parse that, I'm
sorry. Example:

template<typename T>
struct X {
template<typename U> void f(T, U);
};

When we instantiate X<int>, we now instantiate the declaration
X<int>::f, which looks like this:

template<typename U> void X<int>::f(int, U);

The path this takes through
TemplateDeclInstantiator::VisitCXXMethodDecl is convoluted and
ugly, but I don't know how to improve it yet. I'm resting my hopes on
the multi-level substitution required to instantiate definitions of
nested templates, which may simplify this code as well.

More testing to come...



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80252 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-member-template.cpp
8d4c5ea0ee899d3e916d79cde98f16fb47810c4f 27-Aug-2009 Anders Carlsson <andersca@mac.com> Don't check member and base initializers if the constructor is dependent.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80211 91177308-0d34-0410-b5e6-96231b3b80d8
ember-initializers.cpp
83ddad3ab513f5d73698cf9fbeb4ed3f011bc3b9 26-Aug-2009 Douglas Gregor <dgregor@apple.com> Implement support for C++ direct initializers that involve dependent
types or type-dependent expressions.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80143 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-init.cpp
db3a0f543e9a120d37823c6f2a2f1c693b69f2a1 26-Aug-2009 Douglas Gregor <dgregor@apple.com> Make sure to compare primary declaration contexts when determining whether a declaration is in scope

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80126 91177308-0d34-0410-b5e6-96231b3b80d8
lass-template-spec.cpp
42c39f39184c5ce9d7f489e5dcb7eec770728a9a 26-Aug-2009 Douglas Gregor <dgregor@apple.com> When we know that we are parsing a class-name, implicitly construct a
TypenameType if getTypeName is looking at a member of an unknown
specialization. This allows us to properly parse class templates that
derived from type that could only otherwise be described by a typename type,
e.g.,

template<class T> struct X {};
template<typename T> struct Y : public X<T>::X { };

Fixes PR4381.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80123 91177308-0d34-0410-b5e6-96231b3b80d8
ependent-base-member-init.cpp
dacd434c49658286c380c7b4c357d76d53cb4aa1 26-Aug-2009 Douglas Gregor <dgregor@apple.com> Improve diagnostics and recovery when the nested-name-specifier of a
qualified name does not actually refer into a class/class
template/class template partial specialization.

Improve printing of nested-name-specifiers to eliminate redudant
qualifiers. Also, make it possible to output a nested-name-specifier
through a DiagnosticBuilder, although there are relatively few places
that will use this leeway.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80056 91177308-0d34-0410-b5e6-96231b3b80d8
ested-template.cpp
bc047ba73376ac6ef78b3fba0efb8493f7843138 26-Aug-2009 Douglas Gregor <dgregor@apple.com> Test out-of-line definition of a static data member of a member class of a nested class template. Phew

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80046 91177308-0d34-0410-b5e6-96231b3b80d8
ested-template.cpp
c131ebb5cb509838462f9dcf680948dbfaf89d0f 26-Aug-2009 Douglas Gregor <dgregor@apple.com> Test out-of-line definitions of static data members of nested member class templates

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80045 91177308-0d34-0410-b5e6-96231b3b80d8
ested-template.cpp
495c35d291da48c4f5655bbb54d15128ddde0d4d 26-Aug-2009 Douglas Gregor <dgregor@apple.com> Improve support for out-of-line definitions of nested templates and
their members, including member class template, member function
templates, and member classes and functions of member templates.

To actually parse the nested-name-specifiers that qualify the name of
an out-of-line definition of a member template, e.g.,

template<typename X> template<typename Y>
X Outer<X>::Inner1<Y>::foo(Y) {
return X();
}

we need to look for the template names (e.g., "Inner1") as a member of
the current instantiation (Outer<X>), even before we have entered the
scope of the current instantiation. Since we can't do this in general
(i.e., we should not be looking into all dependent
nested-name-specifiers as if they were the current instantiation), we
rely on the parser to tell us when it is parsing a declaration
specifier sequence, and, therefore, when we should consider the
current scope specifier to be a current instantiation.

Printing of complicated, dependent nested-name-specifiers may be
somewhat broken by this commit; I'll add tests for this issue and fix
the problem (if it still exists) in a subsequent commit.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80044 91177308-0d34-0410-b5e6-96231b3b80d8
ependent-type-identity.cpp
ested-template.cpp
05396e20d68535612f58c84e0dfc7647c75a7da1 25-Aug-2009 Douglas Gregor <dgregor@apple.com> Implement out-of-line definitions of nested class templates. Most of
the logic is there for out-of-line definitions with multiple levels of
nested templates, but this is still a work-in-progress: we're having
trouble determining when we should look into a dependent
nested-name-specifier.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80003 91177308-0d34-0410-b5e6-96231b3b80d8
ested-template.cpp
c87efbd2cbd13e68ea771275f03d1bbd1b741e47 25-Aug-2009 Fariborz Jahanian <fjahanian@apple.com> Skip over bases/fields with dependent types.
Fixes pr4771.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79999 91177308-0d34-0410-b5e6-96231b3b80d8
estructor-template.cpp
0b84a53412a6acac38e2d647d220ce7af851395e 25-Aug-2009 Douglas Gregor <dgregor@apple.com> Add a little more testing for default arguments of constructors in a class template

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79989 91177308-0d34-0410-b5e6-96231b3b80d8
efault-expr-arguments.cpp
5653ca5088b799ada71b5043a0a2cd71c727da83 25-Aug-2009 Anders Carlsson <andersca@mac.com> If a parameter has a default argument expression, make sure to instantiate the parameter type before checking that the expression is a valid initializer.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79986 91177308-0d34-0410-b5e6-96231b3b80d8
efault-expr-arguments.cpp
8644aecd4383ce829d1eed81e96399904a948362 25-Aug-2009 Anders Carlsson <andersca@mac.com> Improved support for default arguments in constructors for class templates.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79984 91177308-0d34-0410-b5e6-96231b3b80d8
efault-expr-arguments.cpp
9351c173cd538f7f7c28af1494ac7e68b815b0e8 25-Aug-2009 Anders Carlsson <andersca@mac.com> Basic support for default argument expressions for function templates.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79972 91177308-0d34-0410-b5e6-96231b3b80d8
efault-expr-arguments.cpp
c3058338075a2132e057f1249a13b55a81fe021c 25-Aug-2009 Douglas Gregor <dgregor@apple.com> Keep track of the template parameter depth properly when we have
member templates declared inside other templates. This allows us to
match out-of-line definitions of member function templates within
class templates to the declarations within the class template. We
still can't handle out-of-line definitions for member class templates,
however.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79955 91177308-0d34-0410-b5e6-96231b3b80d8
ested-template.cpp
9983cc110422a2e976191a0ce6ac4f1d7b634cc0 24-Aug-2009 Douglas Gregor <dgregor@apple.com> Don't try to evaluate an expression that is type- or value-dependent while building the CFG

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79941 91177308-0d34-0410-b5e6-96231b3b80d8
un-template-def.cpp
77a2b4f3618608be3e93b12df898d088f8e38337 24-Aug-2009 Fariborz Jahanian <fjahanian@apple.com> Fixes pr4763.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79923 91177308-0d34-0410-b5e6-96231b3b80d8
ependent-base-member-init.cpp
5842ba9fd482bb2fe5198b32c2ae549cd5474e6d 24-Aug-2009 Douglas Gregor <dgregor@apple.com> Try to complete a type before looking for conversion functions within
that type. Note that we do not produce a diagnostic if the type is
incomplete; rather, we just don't look for conversion functions. Fixes PR4660.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79919 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-method.cpp
efd5bdad3c2b746db46452c6b13bd3c462dd761d 24-Aug-2009 Douglas Gregor <dgregor@apple.com> Make sure to adjust function template declarations to their templated
declarations (e.g., FunctionTemplateDecl -> CXXConstructorDecl) before
performing semantic analysis on the declarations. Fixes PR4761.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79911 91177308-0d34-0410-b5e6-96231b3b80d8
onstructor-template.cpp
d83d04041f64a2c89123d227fa8003b482391279 22-Aug-2009 Douglas Gregor <dgregor@apple.com> Implement delayed parsing for member function templates. Fixes PR4608.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79709 91177308-0d34-0410-b5e6-96231b3b80d8
ember-function-template.cpp
1561248f6cc4ee6dd2d227bd4586fa0054c69614 22-Aug-2009 Douglas Gregor <dgregor@apple.com> Add test taking the address of a member function template and converting it to a member pointer.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79699 91177308-0d34-0410-b5e6-96231b3b80d8
ember-function-template.cpp
dec06664a1c4d8984251083db2215875aea1c80d 21-Aug-2009 Douglas Gregor <dgregor@apple.com> Introduce support for constructor templates, which can now be declared
and will participate in overload resolution. Unify the instantiation
of CXXMethodDecls and CXXConstructorDecls, which had already gotten
out-of-sync.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79658 91177308-0d34-0410-b5e6-96231b3b80d8
onstructor-template.cpp
ember-function-template.cpp
6b906869527be40b0d38d755e9ef51b331b88162 21-Aug-2009 Douglas Gregor <dgregor@apple.com> Implement support for calling member function templates, which involves:
- Allowing one to name a member function template within a class
template and on the right-hand side of a member access expression.
- Template argument deduction for calls to member function templates.
- Registering specializations of member function templates (and
finding them later).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79581 91177308-0d34-0410-b5e6-96231b3b80d8
ember-function-template.cpp
37b372b76a3fafe77186d7e6079e5642e2017478 21-Aug-2009 Douglas Gregor <dgregor@apple.com> Initial support for parsing and representation of member function templates.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79570 91177308-0d34-0410-b5e6-96231b3b80d8
ember-function-template.cpp
d1067e5a0a6e2aee7260c392452df9553034c92b 06-Aug-2009 Douglas Gregor <dgregor@apple.com> Implement transformation of template names within the generic tree
transform, then use the result for template instantiation. The generic
transformation fixes a few issues:

- It copes better with template template parameters and member
templates (when they're implemented).
- The logic used to replace template template parameters with their
arguments is now centralized in TransformDecl, so that it will apply
for other declaration-instantiation steps.
- The error-recovery strategy is normalized now, so that any error
results in a NULL TemplateName.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78292 91177308-0d34-0410-b5e6-96231b3b80d8
etafun-apply.cpp
37d93e9252026d4fb836d9c05d0122a2d46e56be 03-Aug-2009 Douglas Gregor <dgregor@apple.com> Keep track of the template arguments deduced when matching a class
template partial specialization. Then, use those template arguments
when instantiating members of that class template partial
specialization. Fixes PR4607.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77925 91177308-0d34-0410-b5e6-96231b3b80d8
artial-spec-instantiate.cpp
c9c88b4159791c48e486ca94e3743b5979e2b7a6 31-Jul-2009 Owen Anderson <resistor@mac.com> Update for LLVM API change.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77722 91177308-0d34-0410-b5e6-96231b3b80d8
anonical-expr-type-0x.cpp
6f2c46b58894d5a81ad7ed7654e3768c72aa0d74 31-Jul-2009 Douglas Gregor <dgregor@apple.com> Make canonicalization of overloaded function declarations match the
Itanium C++ ABI's name mangling, since both are related to the notion
of "equivalent" function templates.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77678 91177308-0d34-0410-b5e6-96231b3b80d8
anonical-expr-type.cpp
4a3f780f4f74a80f9b4bc42e38ad60170d5ebd0c 31-Jul-2009 Douglas Gregor <dgregor@apple.com> Canonicalize function parameters

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77676 91177308-0d34-0410-b5e6-96231b3b80d8
anonical-expr-type.cpp
6ebd15e81a4d44ac51c24bffe2705586d5edffee 31-Jul-2009 Douglas Gregor <dgregor@apple.com> Canonicalization and profiling for overloaded function declarations,
for those extra-esoteric cases. Not that any two given C++ compilers
agree on this test case, but this change gives us a strong definition
of equivalent types.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77664 91177308-0d34-0410-b5e6-96231b3b80d8
anonical-expr-type.cpp
2ec09f1dc123e1942ed756e8ee4fef86451eac9e 31-Jul-2009 Douglas Gregor <dgregor@apple.com> Canonicalize dependent extended vector types.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77663 91177308-0d34-0410-b5e6-96231b3b80d8
anonical-expr-type.cpp
1503f777d94fc05a89c7305651d4b0221c63f586 31-Jul-2009 Eli Friedman <eli.friedman@gmail.com> Make the check for the linkage of a template handle the case of nested
linkage specifications correctly.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77653 91177308-0d34-0410-b5e6-96231b3b80d8
ested-linkage.cpp
04d4beee4b86af20a9e4457023d3925cab8f9908 31-Jul-2009 Douglas Gregor <dgregor@apple.com> Build canonical types for dependently-sized array types.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77647 91177308-0d34-0410-b5e6-96231b3b80d8
anonical-expr-type.cpp
9d702ae1cd5cfa19d884cbef77e1df99395138bb 31-Jul-2009 Douglas Gregor <dgregor@apple.com> Canonicalization of dependent C++0x decltype types.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77643 91177308-0d34-0410-b5e6-96231b3b80d8
anonical-expr-type-0x.cpp
b197572cf1cd70a817a1f546478cb2cb9112c48e 31-Jul-2009 Douglas Gregor <dgregor@apple.com> Canonicalization for dependent typeof(expr) types.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77639 91177308-0d34-0410-b5e6-96231b3b80d8
anonical-expr-type.cpp
c5b8c9b6607de7ce25a28f26a34f43efa5728cb7 30-Jul-2009 Douglas Gregor <dgregor@apple.com> What luck! Clang obtains support for refering to members of the
current instantiation when that current instantiation is a class
template partial specialization.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77609 91177308-0d34-0410-b5e6-96231b3b80d8
urrent-instantiation.cpp
59c04373c6a4fef5c6341a21ac847d4b3a25ee36 29-Jul-2009 Eli Friedman <eli.friedman@gmail.com> Refactor base/member initializers, and construct them correctly in cases
with dependent types. Fixes PR4621 and PR4627.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77498 91177308-0d34-0410-b5e6-96231b3b80d8
ependent-base-member-init.cpp
1f27ac6a52075f9a717f649dd778270916864e0e 29-Jul-2009 Douglas Gregor <dgregor@apple.com> Remove an obsolete kludge based on the previous, completely broken handling of function templates

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77464 91177308-0d34-0410-b5e6-96231b3b80d8
emp_class_spec.cpp
f61ef4fb9f69892badf0be98e7f03e2497299001 29-Jul-2009 Douglas Gregor <dgregor@apple.com> Test redefinition of class template partial specializations

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77463 91177308-0d34-0410-b5e6-96231b3b80d8
emp_class_spec.cpp
828e226ab7ed08b3eb766549e9d3306432137460 29-Jul-2009 Douglas Gregor <dgregor@apple.com> Use the new statement/expression profiling code to unique dependent
template arguments, as in template specialization types. This permits
matching out-of-line definitions of members for class templates that
involve non-type template parameters.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77462 91177308-0d34-0410-b5e6-96231b3b80d8
njected-class-name.cpp
ef0cb8e62d090ad88a01ca9fa89e48d7416f0ac7 29-Jul-2009 Sebastian Redl <sebastian.redl@getdesigned.at> Make functional-style casts emit correct messages, and fix a crash-on-invalid.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77451 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-cast.cpp
08e252425ca2cbdc44ba65d9a657ed5398014e36 28-Jul-2009 Owen Anderson <resistor@mac.com> Update for LLVM API change.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77267 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-static-var.cpp
bc0a2226c7fcd18b29b6846049e2cfcb872d3593 27-Jul-2009 Owen Anderson <resistor@mac.com> Update for LLVM API change.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77249 91177308-0d34-0410-b5e6-96231b3b80d8
mplicit-instantiation-1.cpp
65b90055dd30cfb83d8344ff62ed428257431be4 27-Jul-2009 Douglas Gregor <dgregor@apple.com> When instantiating a variable without an initializer, call
ActOnUninitializedDecl.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77211 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-static-var.cpp
9cc11e70031365972424b43f439021d88096b146 25-Jul-2009 Sebastian Redl <sebastian.redl@getdesigned.at> Implement C++ semantics for C-style and functional-style casts. This regresses Clang extension conversions, like vectors, but allows conversions via constructors and conversion operators.
Add custom conversions to static_cast.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77076 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-cast.cpp
8bf0ccd4c7e23a329f150323e2f9b474ff15c66c 25-Jul-2009 Daniel Dunbar <daniel@zuster.org> Make having no RUN line a failure.

Doug, please look at decltype-crash and instantiate-function-1.mm, I'm not sure
if they are actually testing the right thing / anything.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77070 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-function-1.mm
de99a45c1295ec8e2eea20d35906178ff10722b5 23-Jul-2009 Eli Friedman <eli.friedman@gmail.com> Slight code reorganization to allow instantiating post-inc/dec.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76807 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-5.cpp
f290e0db835a619014538c41ed552696efc0e977 22-Jul-2009 Douglas Gregor <dgregor@apple.com> Fix the problems with template argument deduction and array types for
real. It turns out that we need to actually move all of the qualifiers
up to the array type itself, then recanonicalize the deduced template
argument type.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76788 91177308-0d34-0410-b5e6-96231b3b80d8
emp_class_spec.cpp
b084a05b3546137c71bed3cdf469b85e56deac75 22-Jul-2009 Douglas Gregor <dgregor@apple.com> Canonicalize the types produced by template argument deduction.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76777 91177308-0d34-0410-b5e6-96231b3b80d8
emp_class_spec.cpp
1f618a070121cf30bfe9b615c19df88c73248956 22-Jul-2009 Douglas Gregor <dgregor@apple.com> Slighty more testing for template argument deduction with array arguments

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76774 91177308-0d34-0410-b5e6-96231b3b80d8
emp_class_spec.cpp
9e9fae4b8af47c15696da4ea3c30102e3a035179 22-Jul-2009 Douglas Gregor <dgregor@apple.com> Improve template argument deduction for array types, so that a parameter

const T

can be matched with, e.g.,

volatile int [5]




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76773 91177308-0d34-0410-b5e6-96231b3b80d8
emp_class_spec.cpp
5c7e281d368601858f9f5e5fe11734eea10b9523 22-Jul-2009 Douglas Gregor <dgregor@apple.com> Test template instantiation for member functions of class templates defined
out of line.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76740 91177308-0d34-0410-b5e6-96231b3b80d8
xample-dynarray.cpp
d1969d803cfcc65f1c334df4cc89c7fdd33ee4c9 22-Jul-2009 Mike Stump <mrs@apple.com> Prep for new warning.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76709 91177308-0d34-0410-b5e6-96231b3b80d8
xt-vector-type.cpp
e7f38406a38f453e83000a1e52a5ec0aada66e51 18-Jul-2009 Argyrios Kyrtzidis <akyrtzi@gmail.com> Re-enable 'test/SemaTemplate/temp_class_spec_neg.cpp', after commenting out the cause of the crash.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76337 91177308-0d34-0410-b5e6-96231b3b80d8
emp_class_spec_neg.cpp
fb8e7a63054eb4d1954753f626140fb2c3cad67a 18-Jul-2009 Daniel Dunbar <daniel@zuster.org> Disable this test for now, it has been crashing on linux for weeks.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76328 91177308-0d34-0410-b5e6-96231b3b80d8
emp_class_spec_neg.cpp
839fbc52fad8683c1f7d3a12ac4e09e2e5daa42d 12-Jul-2009 Daniel Dunbar <daniel@zuster.org> The -disable-free hack didn't work...


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@75401 91177308-0d34-0410-b5e6-96231b3b80d8
emp_class_spec_neg.cpp
70b8742bd0fa6a90be08b1150fa315fe893e7854 12-Jul-2009 Daniel Dunbar <daniel@zuster.org> Fix comment, and reduce computational expense of this test.
- I don't see any need for it to be this expensive.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@75395 91177308-0d34-0410-b5e6-96231b3b80d8
ckermann.cpp
e2a3e9a851f9820ad18e7397cb1122e18fde06d8 12-Jul-2009 Daniel Dunbar <daniel@zuster.org> Add -disable-free to this test in the hopes if having it pass on Linux for now.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@75390 91177308-0d34-0410-b5e6-96231b3b80d8
emp_class_spec_neg.cpp
4e579922ada4e19618710878c32543322f86c9c8 10-Jul-2009 Anders Carlsson <andersca@mac.com> Fix type of 'this' and add a decltype test.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@75291 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-function-1.cpp
cca9e9674a5e50a283185d8e9d8a5c3414eb008e 02-Jul-2009 Douglas Gregor <dgregor@apple.com> Keep track of more information within the template instantiation stack, e.g.,
by distinguishing between substitution that occurs for template
argument deduction vs. explicitly-specifiad template arguments. This
is used both to improve diagnostics and to make sure we only provide
SFINAE in those cases where SFINAE should apply.

In addition, deal with the sticky issue where SFINAE only considers
substitution of template arguments into the *type* of a function
template; we need to issue hard errors beyond this point, as
test/SemaTemplate/operator-template.cpp illustrates.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74651 91177308-0d34-0410-b5e6-96231b3b80d8
perator-template.cpp
961743326fd18776f897bf4461345dba680ef637 01-Jul-2009 Fariborz Jahanian <fjahanian@apple.com> Patch to implement template types in ctor-initializer list.
Also has fix for bugzilla-4469.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74631 91177308-0d34-0410-b5e6-96231b3b80d8
lass-template-ctor-initializer.cpp
b33fe2ff12676bff9db595fdf77e29014d7ba397 30-Jun-2009 Douglas Gregor <dgregor@apple.com> When recursively instantiating function templates, keep track of the
instantiation stack so that we provide a full instantiation
backtrace. Previously, we performed all of the instantiations implied
by the recursion, but each looked like a "top-level" instantiation.

The included test case tests the previous fix for the instantiation of
DeclRefExprs. Note that the "instantiated from" diagnostics still
don't tell us which template arguments we're instantiating with.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74540 91177308-0d34-0410-b5e6-96231b3b80d8
ecursive-template-instantiation.cpp
364e021e8cbbeebd4d2544053268a008cf9ee5a9 27-Jun-2009 Douglas Gregor <dgregor@apple.com> Improve support for overloaded operator templates.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74390 91177308-0d34-0410-b5e6-96231b3b80d8
perator-template.cpp
5d39dee0cca8d675120791234cd39a622b986f1b 27-Jun-2009 Eli Friedman <eli.friedman@gmail.com> Fix a bogus error overloading an operator where the only class
parameter has a dependent type.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74380 91177308-0d34-0410-b5e6-96231b3b80d8
perator-template.cpp
1637be727f2a0434c1ed7aa385ea1c18328b0ccd 26-Jun-2009 Douglas Gregor <dgregor@apple.com> Implicit instantiation for function template specializations.

For a FunctionDecl that has been instantiated due to template argument
deduction, we now store the primary template from which it was
instantiated and the deduced template arguments. From this
information, we can instantiate the body of the function template.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74232 91177308-0d34-0410-b5e6-96231b3b80d8
mplicit-instantiation-1.cpp
e53060fa78ad7e98352049f72787bdb7543e2a48 26-Jun-2009 Douglas Gregor <dgregor@apple.com> Improved semantic analysis and AST respresentation for function
templates.

For example, this now type-checks (but does not instantiate the body
of deref<int>):

template<typename T> T& deref(T* t) { return *t; }

void test(int *ip) {
int &ir = deref(ip);
}

Specific changes/additions:
* Template argument deduction from a call to a function template.
* Instantiation of a function template specializations (just the
declarations) from the template arguments deduced from a call.
* FunctionTemplateDecls are stored directly in declaration contexts
and found via name lookup (all forms), rather than finding the
FunctionDecl and then realizing it is a template. This is
responsible for most of the churn, since some of the core
declaration matching and lookup code assumes that all functions are
FunctionDecls.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74213 91177308-0d34-0410-b5e6-96231b3b80d8
emp_arg_template.cpp
e542c862bdf9a9bcb4f468be8fa6561372430611 24-Jun-2009 Douglas Gregor <dgregor@apple.com> Start propagating template parameter lists to the right places to
handle function templates. There's no actual code for function
templates yet, but at least we complain about typedef templates.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74021 91177308-0d34-0410-b5e6-96231b3b80d8
emplate-decl-fail.cpp
d7b9e9fe547579d5ad751fdac25b337ea236f2f2 23-Jun-2009 Douglas Gregor <dgregor@apple.com> Some semantic tests for implicit instantiations

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73924 91177308-0d34-0410-b5e6-96231b3b80d8
mplicit-instantiation-1.cpp
4c4f7cb3a5b692bbc28ff6c5042f540a8e2bf6ac 23-Jun-2009 Douglas Gregor <dgregor@apple.com> Robustify a bunch of C++-related declaration actions.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73918 91177308-0d34-0410-b5e6-96231b3b80d8
lass-template-decl.cpp
d7f37bf8b9a211455c5037df7b7e88e5a9510119 23-Jun-2009 Douglas Gregor <dgregor@apple.com> Implement implicit instantiation of the member functions of a class template
specialization. At present, all implicit instantiations occur at the
end of the translation unit.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73915 91177308-0d34-0410-b5e6-96231b3b80d8
xample-dynarray.cpp
c19ee3eb08ce1d77504d5fc27f7c44b94543221b 18-Jun-2009 Douglas Gregor <dgregor@apple.com> Diagnose class members that shadow a template parameter. Fixes
<rdar://problem/6952203>.

To do this, we actually remove a not-quite-correct optimization in the
C++ name lookup routines. We'll revisit this optimization for the
general case once more C++ is working.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73659 91177308-0d34-0410-b5e6-96231b3b80d8
ested-template.cpp
9cdda0cf8528e3d595be9bfa002f0450074beb4d 17-Jun-2009 Douglas Gregor <dgregor@apple.com> Support dependent extended vector types and template instantiation
thereof. Patch by Anders Johnsen!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73641 91177308-0d34-0410-b5e6-96231b3b80d8
xt-vector-type.cpp
5e9f35c7cb61aea46f56d46c77cbcf47c0cf28ba 14-Jun-2009 Douglas Gregor <dgregor@apple.com> Update LLVM.

Implement support for C++ Substitution Failure Is Not An Error
(SFINAE), which says that errors that occur during template argument
deduction do *not* produce diagnostics and do not necessarily make a
program ill-formed. Instead, template argument deduction silently
fails. This is currently implemented for template argument deduction
during matching of class template partial specializations, although
the mechanism will also apply to template argument deduction for
function templates. The scheme is simple:

- If we are in a template argument deduction context, any diagnostic
that is considered a SFINAE error (or warning) will be
suppressed. The error will be propagated up the call stack via the
normal means.
- By default, all warnings and errors are SFINAE errors. Add the
NoSFINAE class to a diagnostic in the .td file to make it a hard
error (e.g., for access-control violations).

Note that, to make this fully work, every place in Sema that emits an
error *and then immediately recovers* will need to check
Sema::isSFINAEContext() to determine whether it must immediately
return an error rather than recovering.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73332 91177308-0d34-0410-b5e6-96231b3b80d8
emp_class_spec.cpp
247baca66ca998de9c415c19019e199f4895e81c 13-Jun-2009 Douglas Gregor <dgregor@apple.com> Move a bunch of tests into temp.param, and write a few tests for paragraphs that hadn't been touched before

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73288 91177308-0d34-0410-b5e6-96231b3b80d8
ight-angle-brackets-0x.cpp
ight-angle-brackets-98.cpp
emp_param.cpp
923f7534c529be478826f3d390d70dd8575dfd72 13-Jun-2009 Eli Friedman <eli.friedman@gmail.com> Fix for PR4382: allow instantiating dependent nested name specifiers.
I'm not completely sure this is the right way to fix this issue, but it seems
reasonable, and it's consistent with the non-template code for this
construct.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73285 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-dependent-nested-name.cpp
etafun-apply.cpp
31a08752eda39ca17154538e2f2587f8d339a1fa 13-Jun-2009 Anders Carlsson <andersca@mac.com> If a CXXRecordDecl is a class template, the 'this' type should be the injected class name type. Fixes pr4383.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73284 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-function-1.cpp
0ceffb51b28b09db67404058c642dcb1f877f6e8 13-Jun-2009 Anders Carlsson <andersca@mac.com> More work on type parameter packs.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73281 91177308-0d34-0410-b5e6-96231b3b80d8
ariadic-class-template-2.cpp
031a5880e19d06624551aed9d74594356f4f9db1 13-Jun-2009 Douglas Gregor <dgregor@apple.com> When some template parameters of a class template partial
specialization cannot be deduced, produce a warning noting that the
affected class template partial specialization will never be used.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73274 91177308-0d34-0410-b5e6-96231b3b80d8
emp_class_spec_neg.cpp
49d2557addafd2f43b6d2ff54cf77b4f250d1544 13-Jun-2009 Anders Carlsson <andersca@mac.com> A parameter pack must always come last in a class template.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73269 91177308-0d34-0410-b5e6-96231b3b80d8
ariadic-class-template-1.cpp
ce5635a1008b3aedaecb1a3b29bb77e1b71080d1 13-Jun-2009 Anders Carlsson <andersca@mac.com> Address more comments from Doug.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73267 91177308-0d34-0410-b5e6-96231b3b80d8
ariadic-unsupported.cpp
9c4c5c8e174e203da5f841f187bd290a76b34710 13-Jun-2009 Anders Carlsson <andersca@mac.com> Parameter packs can't have default arguments.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73262 91177308-0d34-0410-b5e6-96231b3b80d8
ariadic-class-template-1.cpp
16df850bb73e8e2a3dece830b59785ff167428bc 13-Jun-2009 Douglas Gregor <dgregor@apple.com> Finish implementing checking of class template partial specializations

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73260 91177308-0d34-0410-b5e6-96231b3b80d8
emp_class_spec.cpp
emp_class_spec_neg.cpp
6aa75cfbdd473cb8fb2a2261abf7e9d3c8389bca 13-Jun-2009 Douglas Gregor <dgregor@apple.com> Diagnose C++ [temp.class.spec]p9b3, where a class template partial
specialization's arguments are identical to the implicit template
arguments of the primary template. Typically, this is meant to be a
declaration/definition of the primary template, so we give that
advice.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73259 91177308-0d34-0410-b5e6-96231b3b80d8
emp_class_spec_neg.cpp
e94866ffc12d33d30b351f30aac4aa3828bc05d7 12-Jun-2009 Douglas Gregor <dgregor@apple.com> Diagnose the incorrect use of non-type template arguments for class
template partial specializations.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73254 91177308-0d34-0410-b5e6-96231b3b80d8
emp_class_spec.cpp
emp_class_spec_neg.cpp
941df7dac2c733bad57342a01ca4c8dac956ef63 12-Jun-2009 Anders Carlsson <andersca@mac.com> Parse support for C++0x type parameter packs.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73247 91177308-0d34-0410-b5e6-96231b3b80d8
ariadic-parse.cpp
ba1ecb564c05c2b749193e8deef1df3b69ea3f54 12-Jun-2009 Douglas Gregor <dgregor@apple.com> Verify that the template parameters of a class template partial
specialization do not have default arguments
(C++ [temp.class.spec]p10).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73245 91177308-0d34-0410-b5e6-96231b3b80d8
emp_class_spec_neg.cpp
1d79faf915cc01739664c3817220ed25ad08a367 12-Jun-2009 Anders Carlsson <andersca@mac.com> Fix PR4365.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73240 91177308-0d34-0410-b5e6-96231b3b80d8
ependent-names.cpp
859ba504e754436e1ccf81f50800e5d2ea647447 12-Jun-2009 Anders Carlsson <andersca@mac.com> Deducation and instantiation of block types.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73232 91177308-0d34-0410-b5e6-96231b3b80d8
emp_class_spec_blocks.cpp
02cbbd2d945e466174bee536758e5a2e6a1c0ea2 11-Jun-2009 Douglas Gregor <dgregor@apple.com> Once we have deduced the template arguments of a class template
partial specialization, substitute those template arguments back into
the template arguments of the class template partial specialization to
see if the results still match the original template arguments.

This code is more general than it needs to be, since we don't yet
diagnose C++ [temp.class.spec]p9. However, it's likely to be needed
for function templates.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73196 91177308-0d34-0410-b5e6-96231b3b80d8
emp_class_spec.cpp
3b56c002591b59c6c257951f6613b44de83fa860 11-Jun-2009 Anders Carlsson <andersca@mac.com> Add a null check that fixes the crash in PR4362, and make sure to instantiate non-type template arguments.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73193 91177308-0d34-0410-b5e6-96231b3b80d8
efault-arguments.cpp
c149412d3adfc28ce1f1c0cf6d3701f9491adaf0 11-Jun-2009 Eli Friedman <eli.friedman@gmail.com> Make sure to calculate value-dependence correctly when deal with ICEs.
(Actually, this isn't precisely correct, but it doesn't make
sense to query whether an expression that isn't an ICE is
value-dependent anyway.)



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73179 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-declref-ice.cpp
3c94374c4b7a3ce800bf2b991518d61b04b67f21 11-Jun-2009 Eli Friedman <eli.friedman@gmail.com> Move test to be with the other typename tests.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73178 91177308-0d34-0410-b5e6-96231b3b80d8
ypename-specifier-3.cpp
637a4097f61b09d6ccf619298d9d121fafa044e4 11-Jun-2009 Douglas Gregor <dgregor@apple.com> Template argument deduction for member pointers.

Also, introduced some of the framework for performing instantiation as
part of template argument deduction.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73175 91177308-0d34-0410-b5e6-96231b3b80d8
emp_class_spec.cpp
949bf69136e07fb7968d84bc21d9272ff343ffdb 10-Jun-2009 Douglas Gregor <dgregor@apple.com> Handle member pointer types with dependent class types (e.g., int
T::*) and implement template instantiation for member pointer types.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73151 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-member-pointers.cpp
emp_class_spec.cpp
6d968e89411406f0fd22ae69c77c79a425e2de6f 09-Jun-2009 Douglas Gregor <dgregor@apple.com> Example metaprogram for reversing and searching in a type list

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73147 91177308-0d34-0410-b5e6-96231b3b80d8
xample-typelist.cpp
d708c72e3e5186662fb0045d2bd666bfd93a013d 09-Jun-2009 Douglas Gregor <dgregor@apple.com> Implement template argument deduction for class template
specialization types. As the example shows, we can now compute the
length of a type-list using a template metaprogram and class template
partial specialization.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73136 91177308-0d34-0410-b5e6-96231b3b80d8
xample-typelist.cpp
994b6cb65c9daba2128366bc4c64be6dbf953528 08-Jun-2009 Anders Carlsson <andersca@mac.com> Address comments from Doug.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73077 91177308-0d34-0410-b5e6-96231b3b80d8
emp_class_spec.cpp
1fe067ab2168addd672c08b0b57bded3d155f073 08-Jun-2009 Douglas Gregor <dgregor@apple.com> Test template argument deduction on function types a little more

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73072 91177308-0d34-0410-b5e6-96231b3b80d8
emp_class_spec.cpp
a27fad59dc760252af025ef6a86d31bb7d11a44a 08-Jun-2009 Anders Carlsson <andersca@mac.com> Template argument deduction for function types.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73070 91177308-0d34-0410-b5e6-96231b3b80d8
emp_class_spec.cpp
02d95baf23cbb29ea4ca58b3e8f54f92f845b900 07-Jun-2009 Anders Carlsson <andersca@mac.com> Instantiation support for more Obj-C expressions, string literals, @selector and @protocol expressions.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73036 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-objc-1.mm
fc0f021b492cf28ee7b3a6bd4445ae569e6f15de 07-Jun-2009 Anders Carlsson <andersca@mac.com> Template instantiation support for Obj-C @encode expressions.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73034 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-objc-1.mm
f4e2a2ce1101d875c4b69294416438007947daeb 05-Jun-2009 Anders Carlsson <andersca@mac.com> Fix another crash and actually make the test case work.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72913 91177308-0d34-0410-b5e6-96231b3b80d8
efault-arguments.cpp
9bff9a91fbd6213e2d042aadd8ede92bed6be666 05-Jun-2009 Anders Carlsson <andersca@mac.com> Fix a case when the TemplateArgs vector can be empty.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72911 91177308-0d34-0410-b5e6-96231b3b80d8
efault-arguments.cpp
199d99192fbcca9f043596c40ead4afab4999dba 05-Jun-2009 Douglas Gregor <dgregor@apple.com> Several improvements to template argument deduction:
- Once we have deduced template arguments for a class template partial
specialization, we use exactly those template arguments for instantiating
the definition of the class template partial specialization.
- Added template argument deduction for non-type template parameters.
- Added template argument deduction for dependently-sized array types.

With these changes, we can now implement, e.g., the remove_reference
type trait. Also, Daniel's Ackermann template metaprogram now compiles
properly.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72909 91177308-0d34-0410-b5e6-96231b3b80d8
ckermann.cpp
emp_class_spec.cpp
4d6fb501ffc0568ca5ca7266005e96a6f1273845 04-Jun-2009 Anders Carlsson <andersca@mac.com> Template argument deduction for incomplete and constant array types. Doug, please review.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72844 91177308-0d34-0410-b5e6-96231b3b80d8
emp_class_spec.cpp
d560d5025a0e5b1942d99d5f39005337b03a64c2 04-Jun-2009 Douglas Gregor <dgregor@apple.com> Template argument deduction for references

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72822 91177308-0d34-0410-b5e6-96231b3b80d8
emp_class_spec.cpp
0b9247f129401b4849682b2e2bcdea8fc977068a 04-Jun-2009 Douglas Gregor <dgregor@apple.com> When performing template argument deduction, ensure that multiple
deductions of the same template parameter are equivalent. This allows
us to implement the is_same type trait (!).

Also, move template argument deduction into its own file and update a
few build systems with this change (grrrr).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72819 91177308-0d34-0410-b5e6-96231b3b80d8
emp_class_spec.cpp
7c94c4bb7b875dc1a2b23f77f1ed8013cf94abdb 03-Jun-2009 Argyrios Kyrtzidis <akyrtzi@gmail.com> Use "()" instead of "(void)" when pretty-printing a parameter-less function type for C++.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72747 91177308-0d34-0410-b5e6-96231b3b80d8
emp_arg_nontype.cpp
a53f93be9846a6345b97ce6e6f0b7a0da6da25eb 01-Jun-2009 Anders Carlsson <andersca@mac.com> After spending 15 minutes trying to figure out why this was crashing, I realized it was a bug in the test case :)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72680 91177308-0d34-0410-b5e6-96231b3b80d8
xample-dynarray.cpp
c8ab2563ac8f7dcc4fdc518b5cc7015ecbb2f003 31-May-2009 Douglas Gregor <dgregor@apple.com> Initial infrastructure for class template partial specialization. Here
we have the basics of declaring and storing class template partial
specializations, matching class template partial specializations at
instantiation time via (limited) template argument deduction, and
using the class template partial specialization's pattern for
instantiation.

This patch is enough to make a simple is_pointer type trait work, but
not much else.




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72662 91177308-0d34-0410-b5e6-96231b3b80d8
lass-template-spec.cpp
nstantiation-default-1.cpp
emp_class_spec.cpp
d249e1d1f1498b81314459ceda19d6ff25c278ad 29-May-2009 Douglas Gregor <dgregor@apple.com> Create a new PrintingPolicy class, which we pass down through the AST
printing logic to help customize the output. For now, we use this
rather than a special flag to suppress the "struct" when printing
"struct X" and to print the Boolean type as "bool" in C++ but "_Bool"
in C.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72590 91177308-0d34-0410-b5e6-96231b3b80d8
ypename-specifier-2.cpp
e47590e17725cd37e84bd959d42ea0505b5f1b0d 29-May-2009 Sebastian Redl <sebastian.redl@getdesigned.at> Fix usage of placement new. Placement new is not actually declared implicitly.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72576 91177308-0d34-0410-b5e6-96231b3b80d8
xample-dynarray.cpp
7b0a5723d6851a6f0365536508c2e4db678812b3 29-May-2009 Douglas Gregor <dgregor@apple.com> Follow-on test case for template instantiation of interesting DeclGroups

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72569 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-declref.cpp
8e92bf33baa91a8d97cbd4859648af149d5b5e74 29-May-2009 Douglas Gregor <dgregor@apple.com> Now that we have declared/defined tag types within DeclGroups,
instantiation of tags local to member functions of class templates
(and, eventually, function templates) works when the tag is defined as
part of the decl-specifier-seq, e.g.,

struct S { T x, y; } s1;

Also, make sure that we don't try to default-initialize a dependent
type.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72568 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-declref.cpp
c177aa2516511c26aacbd6fa6546b897bb8dd023 28-May-2009 Douglas Gregor <dgregor@apple.com> Add the missing public: thanks, Fariborz

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72528 91177308-0d34-0410-b5e6-96231b3b80d8
xample-dynarray.cpp
bc221637f5ed3538b8495dd13b831c11e821c712 28-May-2009 Douglas Gregor <dgregor@apple.com> Introduced DeclContext::isDependentContext, which determines whether a
given DeclContext is dependent on type parameters. Use this to
properly determine whether a TagDecl is dependent; previously, we were
missing the case where the TagDecl is a local class of a member
function of a class template (phew!).

Also, make sure that, when we instantiate declarations within a member
function of a class template (or a function template, eventually),
that we add those declarations to the "instantiated locals" map so
that they can be found when instantiating declaration references.

Unfortunately, I was not able to write a useful test for this change,
although the assert() that fires when uncommenting the FIXME'd line in
test/SemaTemplate/instantiate-declref.cpp tells the "experienced user"
that we're now doing the right thing.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72526 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-declref.cpp
6569d68745c8213709740337d2be52b031384f58 28-May-2009 Douglas Gregor <dgregor@apple.com> Reimplement much of the way that we track nested classes in the
parser. Rather than placing all of the delayed member function
declarations and inline definitions into a single bucket corresponding
to the top-level class, we instead mirror the nesting structure of the
nested classes and place the delayed member functions into their
appropriate place. Then, when we actually parse the delayed member
function declarations, set up the scope stack the same way as it was
when we originally saw the declaration, so that we can find, e.g.,
template parameters that are in scope.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72502 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-declref.cpp
599fe7ccc0cbfe761b54039fcc2a7c62d7f84934 27-May-2009 Sebastian Redl <sebastian.redl@getdesigned.at> Fix the type of a enum non-type template argument within the instantiation.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72489 91177308-0d34-0410-b5e6-96231b3b80d8
num-argument.cpp
ed961e7fffc268eeace169869f5a059bcbd5fcbd 27-May-2009 Douglas Gregor <dgregor@apple.com> Simplify, and improve the performance of, template instantiation for
declaration references. The key realization is that dependent Decls,
which actually require instantiation, can only refer to the current
instantiation or members thereof. And, since the current context
during instantiation contains all of those members of the current
instantiation, we can simply find the real instantiate that matches up
with the "current instantiation" template.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72486 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-declref.cpp
d0c873799614d32c9c11280878ac1a856f92f707 27-May-2009 Douglas Gregor <dgregor@apple.com> Add some more tests for instantiation of declaration references. Also,
improve some error recovery with explicit template instantiation.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72484 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-declref.cpp
8dbc3c64965f99e48830885835b7d2fc26ec3cf5 27-May-2009 Douglas Gregor <dgregor@apple.com> Enumeration declarations that were instantiated from an enumeration
within a template now have a link back to the enumeration from which
they were instantiated. This means that we can now find the
instantiation of an anonymous enumeration.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72482 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-declref.cpp
2bba76b0ec4c2f2134eebb1a2bbfe102f36c2f6e 27-May-2009 Douglas Gregor <dgregor@apple.com> Improve name lookup for and template instantiation of declaration
references. There are several smallish fixes here:

- Make sure we look through template parameter scope when
determining whether we're parsing a nested class (or nested class
*template*). This makes sure that we delay parsing the bodies of
inline member functions until after we're out of the outermost
class (template) scope.
- Since the bodies of member functions are always parsed
"out-of-line", even when they were declared in-line, teach
unqualified name lookup to look into the (semantic) parents.
- Use the new InstantiateDeclRef to handle the instantiation of a
reference to a declaration (in DeclRefExpr), which drastically
simplifies template instantiation for DeclRefExprs.
- When we're instantiating a ParmVarDecl, it must be in the current
instantiation scope, so only look there.

Also, remove the #if 0's and FIXME's from the dynarray example, which
now compiles and executes thanks to Anders and Eli.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72481 91177308-0d34-0410-b5e6-96231b3b80d8
xample-dynarray.cpp
nstantiate-declref.cpp
815215daf8f642b53a28212313fca7b9f77e5b9d 27-May-2009 Douglas Gregor <dgregor@apple.com> Initial stab at a generalized operation for determining the
instantiation of a declaration from the template version (or version
that lives in a template) and a given set of template arguments. This
needs much, much more testing, but it suffices for simple examples
like

typedef T* iterator;
iterator begin();




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72461 91177308-0d34-0410-b5e6-96231b3b80d8
xample-dynarray.cpp
5f8bd59b448576e0ac5996b5247f653b7476ad3e 27-May-2009 Douglas Gregor <dgregor@apple.com> Template instantiation for "typeof" for both types and expressions.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72440 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-type.cpp
2f1735c643abfc7c18bf7d0ad95b716099d43ccf 26-May-2009 Douglas Gregor <dgregor@apple.com> A simple dynamic array class template, to be used as a test-bed for template instantiation

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72437 91177308-0d34-0410-b5e6-96231b3b80d8
xample-dynarray.cpp
e30d0bdda24708e9a667722a56b9c96153fe8b4d 23-May-2009 Douglas Gregor <dgregor@apple.com> Template instantiation for qualified declaration reference
expressions. We are now missing template instantiation logic for only
three classes of expressions:
- Blocks-related expressions (BlockExpr, BlockDeclRefExpr)
- C++ default argument expressions
- Objective-C expressions

Additionally, our handling of DeclRefExpr is still quite poor, since
it cannot handle references to many kinds of declarations.

As part of this change, converted the TemplateExprInstantiator to use
iteration through all of the expressions via clang/AST/StmtNodes.def,
ensuring that we don't forget to add template instantiation logic for
any new expression node kinds.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72303 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-4.cpp
76658235f9e350eab68bfbb4e88d0be2ad48e102 23-May-2009 Douglas Gregor <dgregor@apple.com> Template instantiation for the GNU address-of-label extension.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72301 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-function-1.cpp
bec53e7ef3ad39242209a0c7765ca333dd3af8fe 23-May-2009 Douglas Gregor <dgregor@apple.com> Template instantiation for ExtVectorElementExpr.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72299 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-clang.cpp
nstantiate-expr-3.cpp
08d3e7c9ccbed9b26c301390d5997871b2dd41b7 22-May-2009 Douglas Gregor <dgregor@apple.com> Add a few tests to ensure that member functions of class templates can
call other member functions of class templates, including after
template instantiation. No functionality change.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72282 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-4.cpp
1c0ca59416999129d0439c2661d137ef38e86209 22-May-2009 Douglas Gregor <dgregor@apple.com> Representation of and template instantiation for member
expressions. This change introduces another AST node,
CXXUnresolvedMemberExpr, that captures member references (x->m, x.m)
when the base of the expression (the "x") is type-dependent, and we
therefore cannot resolve the member reference yet.

Note that our parsing of member references for C++ is still quite
poor, e.g., we don't handle x->Base::m or x->operator int.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72281 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-4.cpp
690dc7f4f2c0fe87409839b7560c19dee7832195 22-May-2009 Douglas Gregor <dgregor@apple.com> Template instantiation for C99 compound literals

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72236 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-c99.cpp
c4bb7bfe8328f79004517dd268f6146c8066c205 22-May-2009 Douglas Gregor <dgregor@apple.com> Template instantiation for GNU array-range designators.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72234 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-c99.cpp
9ea62768fca25d829d80199cf4f8cf0f4dd39251 22-May-2009 Douglas Gregor <dgregor@apple.com> Template instantiation for C99 designated initializers, because we
can. Also, delay semantic analysis of initialization for
value-dependent as well as type-dependent expressions, since we can't
always properly type-check a value-dependent expression.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72233 91177308-0d34-0410-b5e6-96231b3b80d8
un-template-def.cpp
nstantiate-c99.cpp
ccb97f52afeb4ce5b239a6f3b44956d9e220e5e3 21-May-2009 Douglas Gregor <dgregor@apple.com> Template instantiation for initializer lists

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72229 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-4.cpp
36bb03b86ab6f905b336ee9ec11f288291b22b45 21-May-2009 Douglas Gregor <dgregor@apple.com> Template instantiation for unary type traits, e.g., __is_pod

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72220 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-4.cpp
12d0c307369e4a523e2e40025bf124c310f98dff 21-May-2009 Douglas Gregor <dgregor@apple.com> Template instantiation for C++ "typeid" expressions.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72218 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-4.cpp
42e5b50f4dc897f252e0d476063a7f9846d96624 21-May-2009 Douglas Gregor <dgregor@apple.com> Template instantiation for C++ throw expressions

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72217 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-4.cpp
d0c02674e32cea54e386a52094f89abb71b274da 21-May-2009 Douglas Gregor <dgregor@apple.com> Template instantiation for C++ delete expression

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72216 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-4.cpp
8593c7810fba6548679e7c89d8eaccebf4d5ec20 21-May-2009 Sebastian Redl <sebastian.redl@getdesigned.at> Avoid using the built-in type checker for assignment in C++ when classes are involved. Patch by Vyacheslav Kononenko.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72212 91177308-0d34-0410-b5e6-96231b3b80d8
ualified-names-diag.cpp
3433cf7dfda405bf51bba914a338adf645a87e3b 21-May-2009 Douglas Gregor <dgregor@apple.com> Template instantiation for C++ "new" expressions.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72199 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-4.cpp
66b46be52f82addd4edab3a54928e111dfa09de7 21-May-2009 Douglas Gregor <dgregor@apple.com> Fix template instantiation for compound statements so that it properly
passes the "isStmtExpr" flag, to suppress warnings about unused
expressions.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72190 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-3.cpp
d7e2705961bacb9df5d9119403c01c9b04aff97f 21-May-2009 Douglas Gregor <dgregor@apple.com> Introduce a new kind of RAII class, ASTOwningVector, which is an
llvm::SmallVector that owns all of the AST nodes inside of it. This
RAII class is used to ensure proper destruction of AST nodes when
template instantiation fails.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72186 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-function-1.cpp
e06274d5c5c6b2decc9f217a8913b28f846bfcfa 20-May-2009 Douglas Gregor <dgregor@apple.com> Template instantiation for CXXExprWithTemporaries, which occurs when
temporaries are generated for some object-constructing expressions in
templates that are not type-dependent.

Also, be sure to introduce the variable from a CXXConditionDeclExpr
into the set of instantiated local variables.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72185 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-4.cpp
nstantiate-function-1.cpp
d94546a0a1deef7286c13e49b9584621ae81cc9a 20-May-2009 Douglas Gregor <dgregor@apple.com> Template instantiation for the various kinds of AST nodes that occur
due to C++ type construction of the form T(a1, a2, ..., aN).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72183 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-4.cpp
0db2272aad16a09b8338626282b2ceb78645f205 20-May-2009 Douglas Gregor <dgregor@apple.com> Tweak test case so that the expected-error text matches on both i686 and x86-64.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72181 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-3.cpp
96cff5955952ededa8e2199f38a6f110db38b2e4 20-May-2009 Douglas Gregor <dgregor@apple.com> Add a va_list/template instantiation test suggested by Eli

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72178 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-3.cpp
0529519a9feb1995ba88d179197454103b758866 20-May-2009 Douglas Gregor <dgregor@apple.com> Add FIXMEs for the remaining C and C++ expression types that still
need template instantiation logic. Remove one FIXME by instantiating
the callee in a non-type-dependent CXXOperatorCallExpr.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72145 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-3.cpp
dd0273078111ec7312172c456a01ff86bff83b23 20-May-2009 Douglas Gregor <dgregor@apple.com> Template instantiation for __builtin_va_arg.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72144 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-3.cpp
c9ecc57d6d1fd4a96c748e52958d70be3b3da9fb 20-May-2009 Douglas Gregor <dgregor@apple.com> Template instantiation for __builtin_choose_expr.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72143 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-3.cpp
c12a9c5e552825c2b7d2e4352a9f70e061ebb367 20-May-2009 Douglas Gregor <dgregor@apple.com> Ban the use of __builtin_types_compatible_p in C++; g++ doesn't support it,
and it isn't clear exactly what it's supposed to mean. Thanks Eli!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72142 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-3.cpp
cde01739dffe574c53a6ba1def1a57a2cc7b4a8b 20-May-2009 Douglas Gregor <dgregor@apple.com> Template instantiation for __builtin_shufflevector.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72139 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-3.cpp
dc241b42c7588f99027b035a09b71557a6db219e 19-May-2009 Douglas Gregor <dgregor@apple.com> Template instantiation for __builtin_types_compatible_p.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72134 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-3.cpp
cd938172a40c6f1aca357cf7bad3cf6c208b6136 19-May-2009 Douglas Gregor <dgregor@apple.com> Template instantiation for GNU statement expressions

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72129 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-3.cpp
d5f3a0fde43bca9f3738aed931b0f13ca73a9f11 19-May-2009 Douglas Gregor <dgregor@apple.com> Fix handling of the GNU "t ? : f" extension to the conditional
operator in C++, and verify that template instantiation for the
condition operator does the right thing.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72127 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-3.cpp
6731c31150524b365138e5b8f46e6a4751a7c391 19-May-2009 Douglas Gregor <dgregor@apple.com> Template instantiation for compound assignment operators.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72126 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-3.cpp
a3a7b8eea87c90a5a257f685749222b212ddaf36 19-May-2009 Douglas Gregor <dgregor@apple.com> Template instantiation for cast expressions.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72119 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-cast.cpp
4a2487aeacf9f35ce553318c2eb39c20ec23845e 19-May-2009 Douglas Gregor <dgregor@apple.com> Template instantiation for call expressions.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72081 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-call.cpp
3384c9c1882bab002971f59a31b1da47b13c818c 19-May-2009 Douglas Gregor <dgregor@apple.com> Template instantiation for array subscript expressions. This was far
easier than expected because of the limitation that subscript
operators must be member functions.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72076 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-subscript.cpp
d8ac436c8c10c52c937ba323db582259ceb06197 19-May-2009 Douglas Gregor <dgregor@apple.com> Template instantiation for imaginary literals, because they were next in Expr.h

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72058 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-3.cpp
2f2433f2c4965640e3eea62c87deb7292492b10f 18-May-2009 Douglas Gregor <dgregor@apple.com> Deal with an icky corner case where we were complaining that a catch
statement was using an rvalue reference during the template
definition. However, template instantiations based on an lvalue
reference type are well-formed, so we delay checking of these property
until template instantiation time.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72041 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-try-catch.cpp
d308e6201afd3a8a198c52ba034d35ed19d4bafe 18-May-2009 Douglas Gregor <dgregor@apple.com> Template instantiation for C++ try/catch statements.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72035 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-function-1.cpp
1393d5e2df57667cef07caeba8b7daf6c74cd561 18-May-2009 Douglas Gregor <dgregor@apple.com> Oops, dropped a -verify

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72016 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-function-1.cpp
f3e7ce4bd9837cdab6a096235922865f95467d3d 18-May-2009 Douglas Gregor <dgregor@apple.com> When instantiating the definition of a member function of a class
template, introduce that member function into the template
instantiation stack. Also, add diagnostics showing the member function
within the instantiation stack and clean up the qualified-name
printing so that we get something like:

note: in instantiation of member function 'Switch1<int, 2, 2>::f'
requested here

in the template instantiation backtrace.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72015 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-function-1.cpp
emp_explicit.cpp
4ef2770ee522048a19311d13ccd3b9605297ec58 16-May-2009 Anders Carlsson <andersca@mac.com> Improve checking of member expressions where the base type is a dependent type.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71956 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-function-1.mm
15853a1403d0e938296584ad1cc348a4a08df2cd 16-May-2009 Sebastian Redl <sebastian.redl@getdesigned.at> Test case for previous commit. Explicit instantiation does the trick. (Thanks, Anders.)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71954 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-basic.cpp
5f1b9e689fa5c101512aef99225f2afea1673449 16-May-2009 Douglas Gregor <dgregor@apple.com> Template instantiation for IndirectGotoStmt. Now my life is complete.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71917 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-function-1.cpp
dbb26db1d426fb6caaaf1b4fa47b46d1947c12c9 16-May-2009 Douglas Gregor <dgregor@apple.com> Template instantiation for switch statements


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71916 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-function-1.cpp
ffce2df6ae280d354d51371282a579df1eb86876 16-May-2009 Anders Carlsson <andersca@mac.com> Basic support for member exprs where the base expr type is dependent.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71907 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-function-1.cpp
861ce3178c70cfb0fa50baf685e1ad363538eaa9 16-May-2009 Douglas Gregor <dgregor@apple.com> Template instantiation for break and continue statements.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71903 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-function-1.cpp
5831c6a1efc47e6a19d82fe3dd25b5b8fef6979d 16-May-2009 Douglas Gregor <dgregor@apple.com> Template instantiation for "for" loops

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71901 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-function-1.cpp
9f3ca2a7747bd47f14d7693f333103fac29a24d2 15-May-2009 Douglas Gregor <dgregor@apple.com> Template instantiation for do-while statements.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71899 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-function-1.cpp
4a2e2041edc63db687677325e113b39b9d123c40 15-May-2009 Douglas Gregor <dgregor@apple.com> Template instantiation for WhileStmt and CXXConditionDeclExpr.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71896 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-function-1.cpp
49f25ecf7ff358039ce4c9254b867f32110e660e 15-May-2009 Douglas Gregor <dgregor@apple.com> Make sure that we use the canonical type for the names of instantiated
constructors and destructors. This is a requirement of
DeclarationNameTable::getCXXSpecialName that we weren't assert()'ing,
so it should have been caught much earlier :(

Big thanks to Anders for the test case.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71895 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-function-1.cpp
nstantiate-function-2.cpp
0712d29123215e00b9e5b3c89746c90d9624830f 15-May-2009 Anders Carlsson <andersca@mac.com> Instantiation support for 'this'

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71886 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-function-1.cpp
d06f6ca61062f85926eb9d409eb3d4f8afcf93c7 15-May-2009 Douglas Gregor <dgregor@apple.com> Template instantiation for "if" statements. Also:

- Skip semantic analysis of the "if" condition if it is type-dependent.
- Added the location of the "else" keyword into IfStmt, so that we can
provide it for type-checking after template instantiation.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71875 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-function-1.cpp
e2c31ff0bc622e6fd7d47d7e08b53840f3be6c89 15-May-2009 Douglas Gregor <dgregor@apple.com> Call ActOnStartOfFunctionDecl/ActOnFinishFunctionBody when
instantiating the definition of a function from a template.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71869 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-function-1.cpp
03d77760a5db7990724b6901cea958a673ce0b39 15-May-2009 Anders Carlsson <andersca@mac.com> Instantiate return statements.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71825 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-function-1.cpp
137fa562caedf11df4bb10f2657651a785769ca7 15-May-2009 Anders Carlsson <andersca@mac.com> Instantiate goto and label statements. (Very useful, I know)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71822 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-function-1.cpp
b9f1b8d877541e76390cd3807c2dcff2f950360a 15-May-2009 Douglas Gregor <dgregor@apple.com> Implement template instantiation for DeclStmt

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71818 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-function-1.cpp
e7a18c88b77523cf1085d239fd373770ba5791f1 15-May-2009 Douglas Gregor <dgregor@apple.com> Template instantiation for the NULL statement. Lame, I know

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71816 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-function-1.cpp
54dabfca850ca9e60e9ffb60003529f868d4d127 15-May-2009 Douglas Gregor <dgregor@apple.com> Introduce basic support for instantiating the definitions of member
functions of class templates. Only compound statements and expression
statements are currently implemented.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71814 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-2.cpp
nstantiate-function-1.cpp
48dd19b19ddb9e105f8cf0bf6f0732ca4e6a385b 14-May-2009 Douglas Gregor <dgregor@apple.com> Introduce a stack of instantiation scopes that are used to store the mapping from variable declarations that occur within templates to their instantiated counterparts

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71799 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-2.cpp
1eee0e753fb390b04848846e837714ec774b7bfd 14-May-2009 Douglas Gregor <dgregor@apple.com> Link FunctionDecls instantiated from the member functions of a class
template to the FunctionDecls from which they were instantiated. This
is a necessary first step to support instantiation of the definitions
of such functions, but by itself does essentially nothing.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71792 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-2.cpp
3f5b61c394f4f205bcb4d316eb2a7a0a68b8af86 14-May-2009 Douglas Gregor <dgregor@apple.com> Implement explicit instantiations of member classes of class templates, e.g.,

template<typename T>
struct X {
struct Inner;
};

template struct X<int>::Inner;

This change is larger than it looks because it also fixes some
a problem with nested-name-specifiers and tags. We weren't requiring
the DeclContext associated with the scope specifier of a tag to be
complete. Therefore, when looking for something like "struct
X<int>::Inner", we weren't instantiating X<int>.

This, naturally, uncovered a problem with member pointers, where we
were requiring the left-hand side of a member pointer access
expression (e.g., x->*) to be a complete type. However, this is wrong:
the semantics of this expression does not require a complete type (EDG
agrees).

Stuart vouched for me. Blame him.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71756 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-complete.cpp
nstantiate-typedef.cpp
emp_explicit.cpp
a58861f6490780baec50689e06ca65f7438b85dc 13-May-2009 Douglas Gregor <dgregor@apple.com> Explicit instantiations of templates now instantiate the definitions
of class members (recursively). Only member classes are actually
instantiated; the instantiation logic for member functions and
variables are just stubs.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71713 91177308-0d34-0410-b5e6-96231b3b80d8
emp_explicit.cpp
ff66803b43f2ea9206637dceb793e9505f3b9c48 13-May-2009 Douglas Gregor <dgregor@apple.com> Improve the semantic checking for explicit instantiations of
templates. In particular:
- An explicit instantiation can follow an implicit instantiation (we
were improperly diagnosing this as an error, previously).
- In C++0x, an explicit instantiation that follows an explicit
specialization of the same template specialization is ignored. In
C++98, we just emit an extension warning.
- In C++0x, an explicit instantiation must be in a namespace
enclosing the original template. C++98 has no such requirement.

Also, fixed a longstanding FIXME regarding the integral type that is
used for the size of a constant array type when it is being instantiated.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71689 91177308-0d34-0410-b5e6-96231b3b80d8
emp_explicit.cpp
emp_explicit_cxx0x.cpp
93dfdb1299ef740df854f4a745dc87e5e43f0c30 13-May-2009 Douglas Gregor <dgregor@apple.com> Semantic analysis for explicit instantiation of class templates. We
still aren't instantiating the definitions of class template members,
and core issues 275 and 259 will both affect the checking that we do
for explicit instantiations (but are not yet implemented).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71613 91177308-0d34-0410-b5e6-96231b3b80d8
emp_explicit.cpp
4d9a16f36d3b768672d50e6d02000f982ae448d7 13-May-2009 Douglas Gregor <dgregor@apple.com> Implement parsing for explicit instantiations of class templates, e.g.,

template class X<int>;

This also cleans up the propagation of template information through
declaration parsing, which is used to improve some diagnostics.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71608 91177308-0d34-0410-b5e6-96231b3b80d8
emp_explicit.cpp
709131972f67190edd310ef72bd5e8c9a7764823 12-May-2009 Douglas Gregor <dgregor@apple.com> Parser::ParseDeclarationOrFunctionDefinition no longer needs to accept
template parameters.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71598 91177308-0d34-0410-b5e6-96231b3b80d8
emp.cpp
1426e534b4fca6a05b1120d634aae46be79ca17c 12-May-2009 Douglas Gregor <dgregor@apple.com> Refactor the parsing of declarations so that template declarations can
parse just a single declaration and provide a reasonable diagnostic
when the "only one declarator per template declaration" rule is
violated. This eliminates some ugly, ugly hackery where we used to
require thatn the layout of a DeclGroup of a single element be the
same as the layout of a single declaration.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71596 91177308-0d34-0410-b5e6-96231b3b80d8
emp.cpp
42af25f865a82022a04bedeb483ac251c4412e29 11-May-2009 Douglas Gregor <dgregor@apple.com> Implement the notions of the "current instantiation" and "unknown
specialization" within a C++ template, and permit name lookup into the
current instantiation. For example, given:

template<typename T, typename U>
struct X {
typedef T type;

X* x1; // current instantiation
X<T, U> *x2; // current instantiation
X<U, T> *x3; // not current instantiation
::X<type, U> *x4; // current instantiation
X<typename X<type, U>::type, U>: *x5; // current instantiation
};



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71471 91177308-0d34-0410-b5e6-96231b3b80d8
urrent-instantiation.cpp
ependent-type-identity.cpp
040867836278659d02baa18e044bd996155ec3b5 11-May-2009 Douglas Gregor <dgregor@apple.com> Add a test for canonicalization of template arguments

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71436 91177308-0d34-0410-b5e6-96231b3b80d8
emp_arg_nontype.cpp
7da97d0f31e1ec16998d3de2cfd2e88fe3736673 11-May-2009 Douglas Gregor <dgregor@apple.com> Implement the semantics of the injected-class-name within a class
template. The injected-class-name is either a type or a template,
depending on whether a '<' follows it. As a type, the
injected-class-name's template argument list contains its template
parameters in declaration order.

As part of this, add logic for canonicalizing declarations, and be
sure to canonicalize declarations used in template names and template
arguments.

A TagType is dependent if the declaration it references is dependent.

I'm not happy about the rather complicated protocol needed to use
ASTContext::getTemplateSpecializationType.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71408 91177308-0d34-0410-b5e6-96231b3b80d8
njected-class-name.cpp
a6c0e07df204c5719aa6ef12456830a9af2c7fbe 07-May-2009 Douglas Gregor <dgregor@apple.com> Document the dependent type equivalence test case's purpose.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71162 91177308-0d34-0410-b5e6-96231b3b80d8
ependent-type-identity.cpp
6bbf646ffcb407a26755a01bef44d294310001e2 07-May-2009 Douglas Gregor <dgregor@apple.com> Test a few more variants of dependent type names

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71161 91177308-0d34-0410-b5e6-96231b3b80d8
ependent-type-identity.cpp
45fbaf02fb94a9bc6a108c9621d3db0092d11e94 07-May-2009 Douglas Gregor <dgregor@apple.com> Compute the canonical template name when building a template
specialization type for a dependent template name.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71153 91177308-0d34-0410-b5e6-96231b3b80d8
ependent-type-identity.cpp
25a3ef7cc5fd55dc8cc67c6e6770c8595657e082 07-May-2009 Douglas Gregor <dgregor@apple.com> Start canonicalizing template names. This is not yet complete, but it
improves type identity with dependent types.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71152 91177308-0d34-0410-b5e6-96231b3b80d8
ependent-type-identity.cpp
ed4ec8f6d183c247a4528ff846669b02f2326185 03-May-2009 Douglas Gregor <dgregor@apple.com> One can use "class" and "struct" interchangeably to refer to a class
in C++. Fixes <rdar://problem/6815995>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70784 91177308-0d34-0410-b5e6-96231b3b80d8
lass-template-decl.cpp
f4382f50b7ab9f445c3f5b3ddaa59e6da25ea3bb 15-Apr-2009 Chris Lattner <sabre@nondot.org> Make the implicit-int handling error recovery stuff handle C++
nested name specifiers. Now we emit stuff like:

t.cpp:8:13: error: unknown type name 'X'
static foo::X P;
~~~~ ^

instead of:

t.cpp:8:16: error: invalid token after top level declarator
static foo::X P;
^

This is inspired by a really awful error message I got from
g++ when I misspelt diag::kind as diag::Kind.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69086 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-typedef.cpp
ested-name-spec-template.cpp
ypename-specifier.cpp
31a19b6989bbf326d2de5ae12e712e2a65ca9c34 01-Apr-2009 Douglas Gregor <dgregor@apple.com> Make parsing a semantic analysis a little more robust following Sema
failures that involve malformed types, e.g., "typename X::foo" where
"foo" isn't a type, or "std::vector<void>" that doens't instantiate
properly.

Similarly, be a bit smarter in our handling of ambiguities that occur
in Sema::getTypeName, to eliminate duplicate error messages about
ambiguous name lookup.

This eliminates two XFAILs in test/SemaCXX, one of which was crying
out to us, trying to tell us that we were producing repeated error
messages.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68251 91177308-0d34-0410-b5e6-96231b3b80d8
ested-name-spec-template.cpp
969c689d893a248eca4f049f5b89f747e66e4bff 01-Apr-2009 Douglas Gregor <dgregor@apple.com> Give Type::getDesugaredType a "for-display" mode that can apply more
heuristics to determine when it's useful to desugar a type for display
to the user. Introduce two C++-specific heuristics:

- For a qualified type (like "foo::bar"), only produce a new
desugred type if desugaring the qualified type ("bar", in this
case) produces something interesting. For example, if "foo::bar"
refers to a class named "bar", don't desugar. However, if
"foo::bar" refers to a typedef of something else, desugar to that
something else. This gives some useful desugaring such as
"foo::bar (aka 'int')".
- Don't desugar class template specialization types like
"basic_string<char>" down to their underlying "class
basic_string<char, char_traits<char>, allocator<char>>, etc.";
it's better just to leave such types alone.

Update diagnostics.html with some discussion and examples of type
preservation in C++, showing qualified names and class template
specialization types.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68207 91177308-0d34-0410-b5e6-96231b3b80d8
ualified-names-diag.cpp
1734317845d60307d474b5da8a8d33adbaf5e723 01-Apr-2009 Douglas Gregor <dgregor@apple.com> Parsing, semantic analysis, and template instantiation for typename
specifiers that terminate in a simple-template-id, e.g.,

typename MetaFun::template apply<T1, T2>

Also, implement template instantiation for dependent
nested-name-specifiers that involve unresolved identifiers, e.g.,

typename T::type::type





git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68166 91177308-0d34-0410-b5e6-96231b3b80d8
ypename-specifier-2.cpp
3244780a0fb49898f1ffd1982135c38f28789170 31-Mar-2009 Douglas Gregor <dgregor@apple.com> Improve the dependent nested-name-specifier test a bit

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68136 91177308-0d34-0410-b5e6-96231b3b80d8
etafun-apply.cpp
de650ae96b53eb6109f29fdb5ee51c514259e6e4 31-Mar-2009 Douglas Gregor <dgregor@apple.com> Implement template instantiation for template names, including both
template template parameters and dependent template names. For
example, the oft-mentioned

typename MetaFun::template apply<T1, T2>::type

can now be instantiated, with the appropriate name lookup for "apply".



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68128 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-template-template-parm.cpp
etafun-apply.cpp
c45c232440dfafedca1a3773b904fb42609b1b19 31-Mar-2009 Douglas Gregor <dgregor@apple.com> Parsing and AST representation for dependent template names that occur
within nested-name-specifiers, e.g., for the "apply" in

typename MetaFun::template apply<T1, T2>::type

At present, we can't instantiate these nested-name-specifiers, so our
testing is sketchy.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68081 91177308-0d34-0410-b5e6-96231b3b80d8
etafun-apply.cpp
ested-name-spec-template.cpp
d57959af02b4af695276f4204443afe6e5d86bd8 28-Mar-2009 Douglas Gregor <dgregor@apple.com> Initial implementation of parsing, semantic analysis, and template
instantiation for C++ typename-specifiers such as

typename T::type

The parsing of typename-specifiers is relatively easy thanks to
annotation tokens. When we see the "typename", we parse the
typename-specifier and produce a typename annotation token. There are
only a few places where we need to handle this. We currently parse the
typename-specifier form that terminates in an identifier, but not the
simple-template-id form, e.g.,

typename T::template apply<U, V>

Parsing of nested-name-specifiers has a similar problem, since at this
point we don't have any representation of a class template
specialization whose template-name is unknown.

Semantic analysis is only partially complete, with some support for
template instantiation that works for simple examples.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67875 91177308-0d34-0410-b5e6-96231b3b80d8
ypename-specifier.cpp
551f48c2d96c8a519feb195d34a691c8b97b3994 27-Mar-2009 Douglas Gregor <dgregor@apple.com> Tests and fixes for templates declared within (non-template)
classes. Test case from Anders Carlsson, fix from Piotr Rak!



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67817 91177308-0d34-0410-b5e6-96231b3b80d8
ested-template.cpp
befc20e1dc869edb0e7b560e69f32d5c71f867ab 26-Mar-2009 Douglas Gregor <dgregor@apple.com> The injected-class-name of class templates and class template
specializations can be treated as a template. Finally, we can parse
and process the first implementation of Fibonacci I wrote!

Note that this code does not handle all of the cases where
injected-class-names can be treated as templates. In particular,
there's an ambiguity case that we should be able to handle (but
can't), e.g.,

template <class T> struct Base { };
template <class T> struct Derived : Base<int>, Base<char> {
typename Derived::Base b; // error: ambiguous
typename Derived::Base<double> d; // OK
};




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67720 91177308-0d34-0410-b5e6-96231b3b80d8
ibonacci.cpp
njected-class-name.cpp
3d7a12a50558c31d4351e923c15ab57688f4fdf2 26-Mar-2009 Douglas Gregor <dgregor@apple.com> Implement template instantiation for static data members of class
templates, including in-class initializers. For example:

template<typename T, T Divisor>
class X {
public:
static const T value = 10 / Divisor;
};

instantiated with, e.g.,

X<int, 5>::value

to get the value '2'.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67715 91177308-0d34-0410-b5e6-96231b3b80d8
ibonacci.cpp
nstantiate-static-var.cpp
d048bb79f5c3b3751878aec038bce28a5ce0f439 25-Mar-2009 Douglas Gregor <dgregor@apple.com> Fix notes regarding the instantiation of member classes (and test 'em).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67708 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-member-class.cpp
d475b8d9e6f5ff0e6ab8d15667ce8a64c7cb9a4d 25-Mar-2009 Douglas Gregor <dgregor@apple.com> Instantiation for member classes of class templates. Note that only
the declarations of member classes are instantiated when the owning
class template is instantiated. The definitions of such member classes
are instantiated when a complete type is required.

This change also introduces the injected-class-name into a class
template specialization.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67707 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-member-class.cpp
9135c72fd17bf313072fa12cfe66eb2437ef8e9d 25-Mar-2009 Douglas Gregor <dgregor@apple.com> Fix parsing of template classes prefixed by nested-name-specifiers

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67685 91177308-0d34-0410-b5e6-96231b3b80d8
lass-template-id.cpp
bb969ed4193e2eadabfaa0dfd0b94312b6146349 25-Mar-2009 Douglas Gregor <dgregor@apple.com> Template instantiation for conversion functions

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67664 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-method.cpp
e7450f5dbd5bed63b8ef9db86350a8fc3db011e8 24-Mar-2009 Douglas Gregor <dgregor@apple.com> Make sure to use RequireCompleteType rather than testing for
incomplete types. RequireCompleteType is needed when the type may be
completed by instantiating a template.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67643 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-complete.cpp
615c5d4674355ba830b9978f462ca7a8c5d15f85 24-Mar-2009 Douglas Gregor <dgregor@apple.com> Template instantiation for constructors

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67623 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-method.cpp
d7d5f0223bd30dfd618762349c6209dd1d5ea3e6 24-Mar-2009 Daniel Dunbar <daniel@zuster.org> Rename clang to clang-cc.

Tests and drivers updated, still need to shuffle dirs.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67602 91177308-0d34-0410-b5e6-96231b3b80d8
lass-template-decl.cpp
lass-template-id-2.cpp
lass-template-id.cpp
lass-template-spec.cpp
efault-arguments.cpp
ibonacci.cpp
un-template-def.cpp
nstantiate-array.cpp
nstantiate-enum.cpp
nstantiate-expr-1.cpp
nstantiate-expr-2.cpp
nstantiate-field.cpp
nstantiate-method.cpp
nstantiate-typedef.cpp
nstantiation-backtrace.cpp
nstantiation-default-1.cpp
nstantiation-default-2.cpp
nstantiation-default-3.cpp
nstantiation-depth.cpp
ested-name-spec-template.cpp
ualified-names-diag.cpp
ight-angle-brackets-0x.cpp
ight-angle-brackets-98.cpp
emp_arg.cpp
emp_arg_nontype.cpp
emp_arg_template.cpp
emp_arg_type.cpp
emp_param.cpp
5545e166a956a20d7a6b58408e251a1119025485 24-Mar-2009 Douglas Gregor <dgregor@apple.com> Cleanup template instantiation for methods, destructors

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67585 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-method.cpp
03b2b07aaef3a585aec13048a33356c7f635de72 24-Mar-2009 Douglas Gregor <dgregor@apple.com> Template instantiation for destructors. This is somewhat repetitive;
eliminating the duplication is next on the list.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67579 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-method.cpp
2dc0e64e57b2a1786fa53a7dbd1d5c8e255eadb0 24-Mar-2009 Douglas Gregor <dgregor@apple.com> Template instantiation for the declarations of member functions within
a class template. At present, we can only instantiation normal
methods, but not constructors, destructors, or conversion operators.

As ever, this contains a bit of refactoring in Sema's type-checking. In
particular:

- Split ActOnFunctionDeclarator into ActOnFunctionDeclarator
(handling the declarator itself) and CheckFunctionDeclaration
(checking for the the function declaration), the latter of which
is also used by template instantiation.
- We were performing the adjustment of function parameter types in
three places; collect those into a single new routine.
- When the type of a parameter is adjusted, allocate an
OriginalParmVarDecl to keep track of the type as it was written.
- Eliminate a redundant check for out-of-line declarations of member
functions; hide more C++-specific checks on function declarations
behind if(getLangOptions().CPlusPlus).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67575 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-method.cpp
5953d8b37f92f0cf548941f617c9b0a7703df33b 19-Mar-2009 Douglas Gregor <dgregor@apple.com> Introduce a new expression type, UnresolvedDeclRefExpr, that describes
dependent qualified-ids such as

Fibonacci<N - 1>::value

where N is a template parameter. These references are "unresolved"
because the name is dependent and, therefore, cannot be resolved to a
declaration node (as we would do for a DeclRefExpr or
QualifiedDeclRefExpr). UnresolvedDeclRefExprs instantiate to
DeclRefExprs, QualifiedDeclRefExprs, etc.

Also, be a bit more careful about keeping only a single set of
specializations for a class template, and instantiating from the
definition of that template rather than a previous declaration. In
general, we need a better solution for this for all TagDecls, because
it's too easy to accidentally look at a declaration that isn't the
definition.

We can now process a simple Fibonacci computation described as a
template metaprogram.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67308 91177308-0d34-0410-b5e6-96231b3b80d8
ibonacci.cpp
24c46b3133b03e254877a680f92f035e56058a39 19-Mar-2009 Douglas Gregor <dgregor@apple.com> Print the context of tag types as part of pretty-printing, e.g.,

struct N::M::foo



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67284 91177308-0d34-0410-b5e6-96231b3b80d8
lass-template-id-2.cpp
ualified-names-diag.cpp
e6258936178b4c52b43b3b9dbec13552961cd645 19-Mar-2009 Douglas Gregor <dgregor@apple.com> Extend the use of QualifiedNameType to the creation of class template
specialization names. This way, we keep track of sugared types like

std::vector<Real>

I believe we are now using QualifiedNameTypes everywhere we can. Next
step: QualifiedDeclRefExprs.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67268 91177308-0d34-0410-b5e6-96231b3b80d8
ualified-names-diag.cpp
e4e5b054b4917f0ee493bb2fda5b1ec749bfb9a1 19-Mar-2009 Douglas Gregor <dgregor@apple.com> Introduce a representation for types that we referred to via a
qualified name, e.g.,

foo::x

so that we retain the nested-name-specifier as written in the source
code and can reproduce that qualified name when printing the types
back (e.g., in diagnostics). This is PR3493, which won't be complete
until finished the other tasks mentioned near the end of this commit.

The parser's representation of nested-name-specifiers, CXXScopeSpec,
is now a bit fatter, because it needs to contain the scopes that
precede each '::' and keep track of whether the global scoping
operator '::' was at the beginning. For example, we need to keep track
of the leading '::', 'foo', and 'bar' in

::foo::bar::x

The Action's CXXScopeTy * is no longer a DeclContext *. It's now the
opaque version of the new NestedNameSpecifier, which contains a single
component of a nested-name-specifier (either a DeclContext * or a Type
*, bitmangled).

The new sugar type QualifiedNameType composes a sequence of
NestedNameSpecifiers with a representation of the type we're actually
referring to. At present, we only build QualifiedNameType nodes within
Sema::getTypeName. This will be extended to other type-constructing
actions (e.g., ActOnClassTemplateId).

Also on the way: QualifiedDeclRefExprs will also store a sequence of
NestedNameSpecifiers, so that we can print out the property
nested-name-specifier. I expect to also use this for handling
dependent names like Fibonacci<I - 1>::value.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67265 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-typedef.cpp
a88620c0d15d380975eb2c4c9251cd6ff8d2aa64 18-Mar-2009 Gabor Greif <ggreif@gmail.com> added type dependent testcase

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67230 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-2.cpp
6c473c8ce72634b0ee07fb06ad6392317bf94ae3 18-Mar-2009 Gabor Greif <ggreif@gmail.com> cleanup instantiation code, tighten testcase

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67148 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-2.cpp
087edcfb1d6dcb500675cac1636dca2219cb2b75 18-Mar-2009 Gabor Greif <ggreif@gmail.com> instantiate ?: expressions

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67145 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-2.cpp
a35b1d5f1d02c19d44d7a41b1971b97eefb79d41 18-Mar-2009 Douglas Gregor <dgregor@apple.com> Small sanity-checking testcase

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67133 91177308-0d34-0410-b5e6-96231b3b80d8
lass-template-id.cpp
879fd49f99742e61965f7fefecf1f3b4ba90e197 17-Mar-2009 Douglas Gregor <dgregor@apple.com> Implement instantiation of enums within class templates. This isn't
quite as great as it sounds, because, while we can refer to the
enumerator values outside the template, e.g.,

adder<long, 3, 4>::value

we can't yet refer to them with dependent names, so no Fibonacci
(yet).

InstantiateClassTemplateSpecialization is getting messy; next commit
will put it into a less-ugly state.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67092 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-enum.cpp
76b1c842c3932d3f83b3abf999dd9622e3e5fb12 15-Mar-2009 Anders Carlsson <andersca@mac.com> (Hopefully) instantiate dependent array types correctly.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67032 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-array.cpp
f80a9d5c2ccc465211178223799217f7a42774ae 14-Mar-2009 Douglas Gregor <dgregor@apple.com> Check for overflow and signedness problems with template
arguments. Eliminates a FIXME.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66993 91177308-0d34-0410-b5e6-96231b3b80d8
emp_arg_nontype.cpp
bc736fceca6f0bca31d16003a7587857190408fb 14-Mar-2009 Douglas Gregor <dgregor@apple.com> Implement template instantiation for the prefix unary operators. As
always, refactored the existing logic to tease apart the parser action
and the semantic analysis shared by the parser and template
instantiation.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66987 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-1.cpp
nstantiate-expr-2.cpp
940bd834cd5419f8a8b6ae3c871fb1f8275a06fc 13-Mar-2009 Douglas Gregor <dgregor@apple.com> Devious test-case involved overload resolution and ADL during template instantiation.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66951 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-2.cpp
ba49817c5b9f502602672861cf369fd0e53966e8 13-Mar-2009 Douglas Gregor <dgregor@apple.com> Implement template instantiation for several more kinds of expressions:
- C++ function casts, e.g., T(foo)
- sizeof(), alignof()

More importantly, this allows us to verify that we're performing
overload resolution during template instantiation, with
argument-dependent lookup and the "cached" results of name lookup from
the template definition.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66947 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-1.cpp
df0325110bb07ab62b808c8db8be2f6eee9b3476 12-Mar-2009 Douglas Gregor <dgregor@apple.com> Implement template instantiation for builtin binary operators

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66835 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-1.cpp
a0e500db61f5fcf3ff6de6af1494f0cea9f6f8db 12-Mar-2009 Douglas Gregor <dgregor@apple.com> Straw man for instantiation of expressions. Use it to instantiate the
width of bitfields.

I'll be burning this down and replacing it with a properly-dispatched
implementation like the one used for types.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66796 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-expr-1.cpp
656de633acefb7ced01a4b573dbd4f70b4300097 12-Mar-2009 Douglas Gregor <dgregor@apple.com> Fix various problems with matching out-of-line definitions of static
class members to the corresponding in-class declaration.

Diagnose the erroneous use of 'static' on out-of-line definitions of
class members.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66740 91177308-0d34-0410-b5e6-96231b3b80d8
ested-name-spec-template.cpp
3cf538d5c49bbebac1afa6f4a5010e3d877440bb 11-Mar-2009 Douglas Gregor <dgregor@apple.com> Implement basic template instantiation for fields. Reshuffle checking
for FieldDecls so that the parser and the template instantiation make
use of the same semantic checking module.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66685 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-field.cpp
4fdf1faedbca40787fd277a6fbd5061fd69b2708 11-Mar-2009 Douglas Gregor <dgregor@apple.com> Add basic, hackish support for instantiation of typedefs in a class
template. More importantly, start to sort out the issues regarding
complete types and nested-name-specifiers, especially the question of:
when do we instantiate a class template specialization that occurs to
the left of a '::' in a nested-name-specifier?




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66662 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiate-typedef.cpp
df667e71b1daadeacb230cf94fc717843f1a138a 10-Mar-2009 Douglas Gregor <dgregor@apple.com> Extend the notion of active template instantiations to include the
context of a template-id for which we need to instantiate default
template arguments.

In the TextDiagnosticPrinter, don't suppress the caret diagnostic if
we are producing a non-note diagnostic that follows a note diagnostic
with the same location, because notes are (conceptually) a part of the
warning or error that comes before them.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66572 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiation-default-1.cpp
nstantiation-default-2.cpp
27b152fa7443f4e24630b997c07def6b0c23925a 10-Mar-2009 Douglas Gregor <dgregor@apple.com> If we run into multiple errors within the same template instantiation,
only print the template instantiation backtrace for the first error.

Also, if a base class has failed to type-check during instantiation,
just drop that base class and continue on to check other base classes.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66563 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiation-backtrace.cpp
98137534e612c274ba270af99d73429043957e53 10-Mar-2009 Douglas Gregor <dgregor@apple.com> Add pretty-printing for class template specializations, e.g.,

'struct A<double, int>'

In the "template instantiation depth exceeded" message, print
"-ftemplate-depth-N" rather than "-ftemplate-depth=N".

An unnamed tag type that is declared with a typedef, e.g.,

typedef struct { int x, y; } Point;

can be used as a template argument. Allow this, and check that we get
sensible pretty-printing for such things.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66560 91177308-0d34-0410-b5e6-96231b3b80d8
lass-template-id-2.cpp
lass-template-spec.cpp
nstantiation-backtrace.cpp
nstantiation-depth.cpp
ee1828a6b5ae1bc4ea300e48f3840ac1ec5be295 10-Mar-2009 Douglas Gregor <dgregor@apple.com> Add a notion of "post-diagnostic hooks", which are callbacks attached
to a diagnostic that will be invoked after the diagnostic (if it is
not suppressed). The hooks are allowed to produce additional
diagnostics (typically notes) that provide more information. We should
be able to use this to help diagnostic clients link notes back to the
diagnostic they clarify. Comments welcome; I'll write up documentation
and convert other clients (e.g., overload resolution failures) if
there are no screams of protest.

As the first client of post-diagnostic hooks, we now produce a
template instantiation backtrace when a failure occurs during template
instantiation. There's still more work to do to make this output
pretty, if that's even possible.




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66557 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiation-backtrace.cpp
nstantiation-depth.cpp
26dce44534602660ea9f4152bffc5436fc5fe3b2 10-Mar-2009 Douglas Gregor <dgregor@apple.com> Limit the template instantiation depth to some user-configurable value
(default: 99). Beyond this limit, produce an error and consider the
current template instantiation a failure.

The stack we're building to track the instantiations will, eventually,
be used to produce instantiation backtraces from diagnostics within
template instantiation. However, we're not quite there yet.

This adds a new Clang driver option -ftemplate-depth=NNN, which should
eventually be generated from the GCC command-line operation
-ftemplate-depth-NNN (note the '-' rather than the '='!). I did not
make the driver changes to do this mapping.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66513 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiation-depth.cpp
1a873ae65f8814eae6c9b8786f164ce70c645a21 10-Mar-2009 Douglas Gregor <dgregor@apple.com> Add a test case that goes with the last commit

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66510 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiation-default-3.cpp
40808ce6ac04b102c3b56244a635d6b98eed6d97 10-Mar-2009 Douglas Gregor <dgregor@apple.com> Implement template instantiation for ClassTemplateSpecializationTypes,
such as replacing 'T' in vector<T>. There are a few aspects to this:

- Extend TemplateArgument to allow arbitrary expressions (an
Expr*), and switch ClassTemplateSpecializationType to store
TemplateArguments rather than it's own type-or-expression
representation.

- ClassTemplateSpecializationType can now store dependent types. In
that case, the canonical type is another
ClassTemplateSpecializationType (with default template arguments
expanded) rather than a declaration (we don't build Decls for
dependent types).

- Split ActOnClassTemplateId into ActOnClassTemplateId (called from
the parser) and CheckClassTemplateId (called from
ActOnClassTemplateId and InstantiateType). They're smart enough to
handle dependent types, now.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66509 91177308-0d34-0410-b5e6-96231b3b80d8
emp_arg_type.cpp
2943aed177b33ae3f14273b11a7b398e5276ec62 03-Mar-2009 Douglas Gregor <dgregor@apple.com> Implement the basics of implicit instantiation of class templates, in
response to attempts to diagnose an "incomplete" type. This will force
us to use DiagnoseIncompleteType more regularly (rather than looking at
isIncompleteType), but that's also a good thing.

Implicit instantiation is still very simplistic, and will create a new
definition for the class template specialization (as it should) but it
only actually instantiates the base classes and attaches
those. Actually instantiating class members will follow.

Also, instantiate the types of non-type template parameters before
checking them, allowing, e.g.,

template<typename T, T Value> struct Constant;

to work properly.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65924 91177308-0d34-0410-b5e6-96231b3b80d8
lass-template-id-2.cpp
lass-template-spec.cpp
nstantiation-default-2.cpp
724651c3523e25fbf2f6cd0419bc3466e0afdb07 28-Feb-2009 Douglas Gregor <dgregor@apple.com> Template instantiation for function types

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65668 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiation-default-1.cpp
cd281c3ded486ced5aad29dd7c3fa22b7514c3d8 28-Feb-2009 Douglas Gregor <dgregor@apple.com> Implement template instantiation for pointer, reference, and (some)
array types. Semantic checking for the construction of these types has
been factored out of GetTypeForDeclarator and into separate
subroutines (BuildPointerType, BuildReferenceType,
BuildArrayType). We'll be doing the same thing for all other types
(and declarations and expressions).

As part of this, moved the type-instantiation functions into a class
in an anonymous namespace.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65663 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiation-default-1.cpp
99ebf651f1c3fd11eb648dc8d736c192c753f2cf 27-Feb-2009 Douglas Gregor <dgregor@apple.com> Implement the basic approach for instantiating types, with a lot of FIXME'd
stubs for those types we don't yet know how to instantiate (everything
that isn't a template parameter!).

We now instantiate default arguments for template type parameters when
needed. This will be our testbed while I fill out the remaining
type-instantiation logic.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65649 91177308-0d34-0410-b5e6-96231b3b80d8
nstantiation-default-1.cpp
4b2d3f7bcc4df31157df443af1b80bcaa9b58bba 26-Feb-2009 Douglas Gregor <dgregor@apple.com> Introduce code modification hints into the diagnostics system. When we
know how to recover from an error, we can attach a hint to the
diagnostic that states how to modify the code, which can be one of:

- Insert some new code (a text string) at a particular source
location
- Remove the code within a given range
- Replace the code within a given range with some new code (a text
string)

Right now, we use these hints to annotate diagnostic information. For
example, if one uses the '>>' in a template argument in C++98, as in
this code:

template<int I> class B { };
B<1000 >> 2> *b1;

we'll warn that the behavior will change in C++0x. The fix is to
insert parenthese, so we use code insertion annotations to illustrate
where the parentheses go:

test.cpp:10:10: warning: use of right-shift operator ('>>') in template
argument will require parentheses in C++0x
B<1000 >> 2> *b1;
^
( )


Use of these annotations is partially implemented for HTML
diagnostics, but it's not (yet) producing valid HTML, which may be
related to PR2386, so it has been #if 0'd out.

In this future, we could consider hooking this mechanism up to the
rewriter to actually try to fix these problems during compilation (or,
after a compilation whose only errors have fixes). For now, however, I
suggest that we use these code modification hints whenever we can, so
that we get better diagnostics now and will have better coverage when
we find better ways to use this information.

This also fixes PR3410 by placing the complaint about missing tokens
just after the previous token (rather than at the location of the next
token).




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65570 91177308-0d34-0410-b5e6-96231b3b80d8
ight-angle-brackets-98.cpp
emp_arg_nontype.cpp
2850784bda09416fc7e9d57f5baa36c9351c757c 26-Feb-2009 Sebastian Redl <sebastian.redl@getdesigned.at> Make more AST nodes and semantic checkers dependent-expression-aware.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65529 91177308-0d34-0410-b5e6-96231b3b80d8
un-template-def.cpp
65100792a69a16895bd80f1d639b99e7ad903386 26-Feb-2009 Douglas Gregor <dgregor@apple.com> Use RecordFirst/RecordLast range checks in DeclContext

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65489 91177308-0d34-0410-b5e6-96231b3b80d8
lass-template-spec.cpp
7f43d6764797ab21216421aeb00f4ec314d503d1 26-Feb-2009 Douglas Gregor <dgregor@apple.com> Implementing parsing of template-ids as class-names, so that we can
derive from a class template specialization, e.g.,

class B : public A<int> { };



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65488 91177308-0d34-0410-b5e6-96231b3b80d8
lass-template-id-2.cpp
3965b7be250de002d8744331631b9901941666a0 26-Feb-2009 Douglas Gregor <dgregor@apple.com> Cope with use of the token '>>' inside a template argument list, e.g.,

vector<vector<double>> Matrix;

In C++98/03, this token always means "right shift". However, if we're in
a context where we know that it can't mean "right shift", provide a
friendly reminder to put a space between the two >'s and then treat it
as two >'s as part of recovery.

In C++0x, this token is always broken into two '>' tokens.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65484 91177308-0d34-0410-b5e6-96231b3b80d8
ight-angle-brackets-0x.cpp
ight-angle-brackets-98.cpp
6bc9f7e286913fb1df95fa3fdcac7aab2628eaeb 25-Feb-2009 Douglas Gregor <dgregor@apple.com> Improve location information on "reused" class template specialization
decls. Test and document the semantic location of class template
specialization definitions that occur within a scope enclosing the
scope of the class template.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65478 91177308-0d34-0410-b5e6-96231b3b80d8
lass-template-spec.cpp
88b7094185b9d4fe9820c731b6936d8d37f6143e 25-Feb-2009 Douglas Gregor <dgregor@apple.com> Perform additional semantic checking of class template
specializations. In particular:

- Make sure class template specializations have a "template<>"
header, and complain if they don't.
- Make sure class template specializations are declared/defined
within a valid context. (e.g., you can't declare a specialization
std::vector<MyType> in the global namespace).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65476 91177308-0d34-0410-b5e6-96231b3b80d8
lass-template-spec.cpp
ac1afdc58e6ad5c969f45fd2ff6d140d3b4dd862 25-Feb-2009 Douglas Gregor <dgregor@apple.com> Include the appropriate header for malloc

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65471 91177308-0d34-0410-b5e6-96231b3b80d8
lass-template-spec.cpp
39a8de10c18365bde7062d8959b7ed525449c561 25-Feb-2009 Douglas Gregor <dgregor@apple.com> Implement parsing of nested-name-specifiers that involve template-ids, e.g.,

std::vector<int>::allocator_type

When we parse a template-id that names a type, it will become either a
template-id annotation (which is a parsed representation of a
template-id that has not yet been through semantic analysis) or a
typename annotation (where semantic analysis has resolved the
template-id to an actual type), depending on the context. We only
produce a type in contexts where we know that we only need type
information, e.g., in a type specifier. Otherwise, we create a
template-id annotation that can later be "upgraded" by transforming it
into a typename annotation when the parser needs a type. This occurs,
for example, when we've parsed "std::vector<int>" above and then see
the '::' after it. However, it means that when writing something like
this:

template<> class Outer::Inner<int> { ... };

We have two tokens to represent Outer::Inner<int>: one token for the
nested name specifier Outer::, and one template-id annotation token
for Inner<int>, which will be passed to semantic analysis to define
the class template specialization.

Most of the churn in the template tests in this patch come from an
improvement in our error recovery from ill-formed template-ids.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65467 91177308-0d34-0410-b5e6-96231b3b80d8
lass-template-spec.cpp
efault-arguments.cpp
ested-name-spec-template.cpp
emp_arg.cpp
emp_arg_nontype.cpp
emp_arg_template.cpp
emp_arg_type.cpp
d0344a4a6182ad704881cbbaa21cca14913d2296 20-Feb-2009 Chris Lattner <sabre@nondot.org> Fix a long standard problem with clang retaining "too much" sugar
information about types. We often print diagnostics where we say
"foo_t" is bad, but the user doesn't know how foo_t is declared
(because it is a typedef). Fix this by expanding sugar when present
in a diagnostic (and not one of a few special cases, like vectors).

Before:
t.m:5:2: error: invalid operands to binary expression ('typeof(P)' and 'typeof(F)')
MAX(P, F);
^~~~~~~~~
t.m:1:78: note: instantiated from:
#define MAX(A,B) ({ __typeof__(A) __a = (A); __typeof__(B) __b = (B); __a < __b ? __b : __a; })
^

After:
t.m:5:2: error: invalid operands to binary expression ('typeof(P)' (aka 'struct mystruct') and 'typeof(F)' (aka 'float'))
MAX(P, F);
^~~~~~~~~
t.m:1:78: note: instantiated from:
#define MAX(A,B) ({ __typeof__(A) __a = (A); __typeof__(B) __b = (B); __a < __b ? __b : __a; })
^




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65081 91177308-0d34-0410-b5e6-96231b3b80d8
lass-template-decl.cpp
611a8c49c6a5848aed17eced8f2f3f7b1b7577a1 19-Feb-2009 Douglas Gregor <dgregor@apple.com> Provide a proper source location when building an implicit dereference. Fixes PR3600

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64993 91177308-0d34-0410-b5e6-96231b3b80d8
lass-template-spec.cpp
cc636688c4fd10b1732ce3e33b2b106024d545ca 18-Feb-2009 Douglas Gregor <dgregor@apple.com> Implement basic parsing and semantic analysis for explicit
specialization of class templates, e.g.,

template<typename T> class X;

template<> class X<int> { /* blah */ };

Each specialization is a different *Decl node (naturally), and can
have different members. We keep track of forward declarations and
definitions as for other class/struct/union types.

This is only the basic framework: we still have to deal with checking
the template headers properly, improving recovery when there are
failures, handling nested name specifiers, etc.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64848 91177308-0d34-0410-b5e6-96231b3b80d8
lass-template-spec.cpp
3e00bad490f1bae8a2c60f934e7eb5dbb9752c5d 17-Feb-2009 Douglas Gregor <dgregor@apple.com> Added ClassTemplateSpecializationDecl, which is a subclass of
CXXRecordDecl that is used to represent class template
specializations. These are canonical declarations that can refer to
either an actual class template specialization in the code, e.g.,

template<> class vector<bool> { };

or to a template instantiation. However, neither of these features is
actually implemented yet, so really we're just using (and uniqing) the
declarations to make sure that, e.g., A<int> is a different type from
A<float>. Note that we carefully distinguish between what the user
wrote in the source code (e.g., "A<FLOAT>") and the semantic entity it
represents (e.g., "A<float, int>"); the former is in the sugared Type,
the latter is an actual Decl.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64716 91177308-0d34-0410-b5e6-96231b3b80d8
lass-template-id.cpp
cc45cb3630b42c5245e26593e385097c220bc859 11-Feb-2009 Douglas Gregor <dgregor@apple.com> Finished semantic analysis of non-type template arguments, to check
for non-external names whose address becomes the template
argument. This completes C++ [temp.arg.nontype]p1.

Note that our interpretation of C++ [temp.arg.nontype]p1b3 differs
from EDG's interpretation (we're stricter, and GCC agrees with
us). They're opening a core issue about the matter.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64317 91177308-0d34-0410-b5e6-96231b3b80d8
emp_arg_nontype.cpp
62cb18dd11472965e03374d40bc27d650bc331b6 11-Feb-2009 Douglas Gregor <dgregor@apple.com> Allow the use of default template arguments when forming a class
template specialization (e.g., std::vector<int> would now be
well-formed, since it relies on a default argument for the Allocator
template parameter).

This is much less interesting than one might expect, since (1) we're
not actually using the default arguments for anything important, such
as naming an actual Decl, and (2) we'll often need to instantiate the
default arguments to check their well-formedness. The real fun will
come later.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64310 91177308-0d34-0410-b5e6-96231b3b80d8
efault-arguments.cpp
emp_arg.cpp
658bbb5e8072ccd68b5ddc299d1b868aa047a746 11-Feb-2009 Douglas Gregor <dgregor@apple.com> Implement semantic checking for template arguments that correspond to
pointer-to-member-data non-type template parameters. Also, get
consistent about what it means to returned a bool from
CheckTemplateArgument.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64305 91177308-0d34-0410-b5e6-96231b3b80d8
emp_arg.cpp
emp_arg_nontype.cpp
emp_arg_template.cpp
emp_arg_type.cpp
b86b0579c5805c8ecaedd2d676e06bf8c2bf7f79 11-Feb-2009 Douglas Gregor <dgregor@apple.com> Add semantic checking for template arguments that correspond to
non-type template parameters that are references to functions or
pointers to member functions. Did a little bit of refactoring so that
these two cases, along with the handling of non-type template
parameters that are pointers to functions, are handled by the same
path.

Also, tweaked FixOverloadedFunctionReference to cope with member
function pointers. This is a necessary step for getting all of the fun
member pointer conversions working outside of template arguments, too.




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64277 91177308-0d34-0410-b5e6-96231b3b80d8
emp_arg_nontype.cpp
f684e6e793a336f52138a2609b207e6eef3c3022 11-Feb-2009 Douglas Gregor <dgregor@apple.com> Semantic checking for template arguments that correspond to non-type
template parameters that have reference type. Effectively, we're doing
a very limited form of reference binding here.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64270 91177308-0d34-0410-b5e6-96231b3b80d8
emp_arg_nontype.cpp
a35284bba5db7a6179d70fcce8fbe66481058698 11-Feb-2009 Douglas Gregor <dgregor@apple.com> Add partial semantic checking of template arguments that are meant for
non-type template parameters of pointer-to-object and
pointer-to-function type. The most fun part of this is the use of
overload resolution to pick a function from the set of overloaded
functions that comes in as a template argument.

Also, fixed two minor bugs in this area:
- We were allowing non-type template parameters of type pointer to
void.
- We weren't patching up an expression that refers to an overloaded
function set via "&f" properly.

We're still not performing complete checking of the expression to be
sure that it is referring to an object or function with external
linkage (C++ [temp.arg.nontype]p1).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64266 91177308-0d34-0410-b5e6-96231b3b80d8
emp_arg_nontype.cpp
emp_param.cpp
6ae5e6649f5d01a1b593f4db755bfcb42e095700 11-Feb-2009 Douglas Gregor <dgregor@apple.com> Add type-checking and implicit conversions for template parameters of
integral or enumeration type.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64256 91177308-0d34-0410-b5e6-96231b3b80d8
emp_arg_nontype.cpp
68c69931412548fa89117e9b12633f84a8e74010 10-Feb-2009 Douglas Gregor <dgregor@apple.com> Fix a problem with bogus template shadowing warnings

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64230 91177308-0d34-0410-b5e6-96231b3b80d8
emp_param.cpp
d684b0027e16163c4bdba3e2f8bfadda7d62a0d3 10-Feb-2009 Douglas Gregor <dgregor@apple.com> Implement parsing, semantic analysis and ASTs for default template
arguments. This commit covers checking and merging default template
arguments from previous declarations, but it does not cover the actual
use of default template arguments when naming class template
specializations.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64229 91177308-0d34-0410-b5e6-96231b3b80d8
emp_param.cpp
5d290d584a82bb1cbfffa1b9a9a278538970e1b9 10-Feb-2009 Douglas Gregor <dgregor@apple.com> Semantic analysis for non-type template parameter declarations.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64223 91177308-0d34-0410-b5e6-96231b3b80d8
emp_param.cpp
8b642592a35167a3780074e78674e0bece87c40c 10-Feb-2009 Douglas Gregor <dgregor@apple.com> Teach the type-id/expression disambiguator about different
disambiguation contexts, so that we properly parse template arguments
such as

A<int()>

as type-ids rather than as expressions. Since this can be confusing
(especially when the template parameter is a non-type template
parameter), we try to give a friendly error message.

Almost, eliminate a redundant error message (that should have been a
note) and add some ultra-basic checks for non-type template
arguments.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64189 91177308-0d34-0410-b5e6-96231b3b80d8
emp_arg_nontype.cpp
emp_arg_type.cpp
dd0574e76439f31c02ba54bd7708725176f9531f 10-Feb-2009 Douglas Gregor <dgregor@apple.com> Check template template arguments against their corresponding template
template parameters.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64188 91177308-0d34-0410-b5e6-96231b3b80d8
emp_arg_template.cpp
c15cb38a4ff717097b32532fbf761c71b1376a02 10-Feb-2009 Douglas Gregor <dgregor@apple.com> Rudimentary checking of template arguments against their corresponding
template parameters when performing semantic analysis of a template-id
naming a class template specialization.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64185 91177308-0d34-0410-b5e6-96231b3b80d8
emp_arg.cpp
emp_arg_type.cpp
55f6b14230c94272efbbcdd89a92224c8db9f225 09-Feb-2009 Douglas Gregor <dgregor@apple.com> Start processing template-ids as types when the template-name refers
to a class template. For example, the template-id 'vector<int>' now
has a nice, sugary type in the type system. What we can do now:

- Parse template-ids like 'vector<int>' (where 'vector' names a
class template) and form proper types for them in the type system.
- Parse icky template-ids like 'A<5>' and 'A<(5 > 0)>' properly,
using (sadly) a bool in the parser to tell it whether '>' should
be treated as an operator or not.

This is a baby-step, with major problems and limitations:
- There are currently two ways that we handle template arguments
(whether they are types or expressions). These will be merged, and,
most likely, TemplateArg will disappear.
- We don't have any notion of the declaration of class template
specializations or of template instantiations, so all template-ids
are fancy names for 'int' :)



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64153 91177308-0d34-0410-b5e6-96231b3b80d8
lass-template-id.cpp
ddc29e116db3c3f4144355e67a0137b38b6bb6d1 06-Feb-2009 Douglas Gregor <dgregor@apple.com> Semantic checking for class template declarations and
redeclarations. For example, checks that a class template
redeclaration has the same template parameters as previous
declarations.

Detangled class-template checking from ActOnTag, whose logic was
getting rather convoluted because it tried to handle C, C++, and C++
template semantics in one shot.

Made some inroads toward eliminating extraneous "declaration does not
declare anything" errors by adding an "error" type specifier.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63973 91177308-0d34-0410-b5e6-96231b3b80d8
lass-template-decl.cpp