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.
Ted Kremenek [Wed, 11 Nov 2009 06:43:42 +0000 (06:43 +0000)]
CastToStructChecker: use 'isStructureType()' instead of 'isRecordType()' to determine if a pointer is casted to a struct pointer. This fixes an observed false positive when a value is casted to a union.
Ted Kremenek [Wed, 11 Nov 2009 06:28:42 +0000 (06:28 +0000)]
Fix display of "ANALYZE" statements in AnalysisConsumer by correctly resetting the flag indicating that the current Decl* has not yet been displayed. Also move this out of AnalysisManager, since AnalysisManager should not handle text output to the user.
Daniel Dunbar [Wed, 11 Nov 2009 05:29:04 +0000 (05:29 +0000)]
Redo how PCH handles its implicit include. Instead of treating this specially in
the front-end (as far as the preprocessor goes), follow the usual logic of
inserting the (original include path) name into the predefines buffer. This
pushes the responsibility for handling this to PCH instead of the front-end. In
PCH this requires being a little more clever when we diff the predefines
buffers.
Neither of these solutions are particularly great, I think what we eventually
should do is something like gcc where we insert a special marker to indicate the
PCH file, but then run the preprocessor as usual. This would be clearer and
would allow us to drop the overly clever predefines handling.
Daniel Dunbar [Wed, 11 Nov 2009 03:48:26 +0000 (03:48 +0000)]
Fix some tests in -Asserts mode.
- FileCheck is a *huuuuge* improvement here.
- Still feels like we could use a better tool for this though, either teach
llvm-dis to spit out the FileCheck syntax, or provide another tool to turn a
.ll into a "matchable" input.
- Also on my Christmas list is better FileCheck diagnostics with missing
variables or mismatches.
Daniel Dunbar [Wed, 11 Nov 2009 03:45:59 +0000 (03:45 +0000)]
Rewrite splitLines using StringRef; this is much simpler, and also now avoids
tons of std::string trashing. I plan to move this and other fun string munging
utilities to a StringRefExtras.h at some point if no one beats me to it.
On a synthetic benchmark on x86_64, llvm-gcc actually generates code thats 10%
faster using the StringRef version. gcc miscompiles the synthetic benchmark,
which I'm crossing my fingers and hoping won't happen here. clang compiles the
sythetic benchmark correctly (wootness), but the StringRef version is
slower. Silly clang.