Douglas Gregor [Thu, 12 Nov 2009 18:38:13 +0000 (18:38 +0000)]
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.
Devang Patel [Thu, 12 Nov 2009 18:21:39 +0000 (18:21 +0000)]
"Attach debug info with llvm instructions" mode was enabled a month ago. Now make it permanent and remove old way of inserting intrinsics to encode debug info for locations and types.
Douglas Gregor [Thu, 12 Nov 2009 17:40:13 +0000 (17:40 +0000)]
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.
Douglas Gregor [Thu, 12 Nov 2009 16:20:59 +0000 (16:20 +0000)]
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.
Chris Lattner [Thu, 12 Nov 2009 08:08:27 +0000 (08:08 +0000)]
Generalize stdint.h for non-8-bit-multiple types, patch by
Ken Dyck!
"This adds definitions for types of 8-bit multiples
from 8 to 64 to stdint.h and rationalizes the selection of types
for the exact-width definitions in InitPreprocessor.cpp."
Chris Lattner [Thu, 12 Nov 2009 08:04:33 +0000 (08:04 +0000)]
do not store wchar/char16/char32/intmax width/alignment info
into TargetInfo, just derive this based on the underlying type.
This prevents them from getting out of synch, patch by Ken Dyck!
Ted Kremenek [Thu, 12 Nov 2009 06:17:47 +0000 (06:17 +0000)]
Add most of the boilerplate logic for a simple pthread_mutux_lock() -> pthread_mutex_unlock() checker. We need to add a visitor method to Checker for handling dead symbols in order to detect locks that are not unlocked.
Daniel Dunbar [Thu, 12 Nov 2009 02:53:27 +0000 (02:53 +0000)]
clang-cc: Refactor ParseInputFollow to clearly split on the two primary cases,
when we are running an AST consumer and when we are just running the
preprocessor or parser alone.
Daniel Dunbar [Thu, 12 Nov 2009 01:36:27 +0000 (01:36 +0000)]
clang-cc: Move non-Consumer action handling to common location, to expose the massive amount of redundancy we have introduced through blind copy-and-paste.
Douglas Gregor [Thu, 12 Nov 2009 00:46:20 +0000 (00:46 +0000)]
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.
John McCall [Thu, 12 Nov 2009 00:06:05 +0000 (00:06 +0000)]
Add <foo> = [<bar> nextObject] to the -Widiomatic-parentheses category,
and give that category an explicit test. Generalize the internal diagnostic
name.
Douglas Gregor [Thu, 12 Nov 2009 00:03:40 +0000 (00:03 +0000)]
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.
Douglas Gregor [Wed, 11 Nov 2009 23:06:43 +0000 (23:06 +0000)]
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; };
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 :(
Douglas Gregor [Wed, 11 Nov 2009 21:54:23 +0000 (21:54 +0000)]
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.
Douglas Gregor [Wed, 11 Nov 2009 19:41:09 +0000 (19:41 +0000)]
Move handling of template parameter packs out of the
template-type-parameter specific template argument checking code and
up to the template argument checking loop. In theory, this should make
variadic templates work better; in practice, they don't well enough
for us to care anyway (YET!), so this is mostly a re-organization to
simplify CheckTemplateArgument.
Douglas Gregor [Wed, 11 Nov 2009 19:13:48 +0000 (19:13 +0000)]
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.
Devang Patel [Wed, 11 Nov 2009 19:10:19 +0000 (19:10 +0000)]
Do not eagerly set stop point for arguments. This misleads the debugger in identifying beginning of function body. Instead, create new location to attach with llvm.dbg.declare. This location is only used to find the context of the variable by the code generator, and it is not used to emit line number info.
Douglas Gregor [Wed, 11 Nov 2009 16:39:34 +0000 (16:39 +0000)]
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.