Eli Friedman [Fri, 27 Feb 2009 04:07:58 +0000 (04:07 +0000)]
Make isICE assert when Evaluate can't evaluate an ICE, as suggested by
Daniel. Some minor fixes/cleanup. Allow __builtin_choose_expr,
__real__, and __imag__ in ICEs, following gcc's example.
Douglas Gregor [Thu, 26 Feb 2009 23:50:07 +0000 (23:50 +0000)]
Create a new TypeNodes.def file that enumerates all of the types,
giving them rough classifications (normal types, never-canonical
types, always-dependent types, abstract type representations) and
making it far easier to make sure that we've hit all of the cases when
decoding types.
Switched some switch() statements on the type class over to using this
mechanism, and filtering out those things we don't care about. For
example, CodeGen should never see always-dependent or non-canonical
types, while debug info generation should never see always-dependent
types. More switch() statements on the type class need to be moved
over to using this approach, so that we'll get warnings when we add a
new type then fail to account for it somewhere in the compiler.
Chris Lattner [Thu, 26 Feb 2009 23:36:02 +0000 (23:36 +0000)]
ok, not as broken as I thought, just confusing. This allows
initialization of wchar_t arrays with wide strings, and generalizes
wchar_size.c to work on all targets.
Douglas Gregor [Thu, 26 Feb 2009 22:19:44 +0000 (22:19 +0000)]
Make the type associated with a ClassTemplateSpecializationDecl be a
nicely sugared type that shows how the user wrote the actual
specialization. This sugared type won't actually show up until we
start doing instantiations.
Douglas Gregor [Thu, 26 Feb 2009 21:00:50 +0000 (21:00 +0000)]
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).
Daniel Dunbar [Thu, 26 Feb 2009 19:48:14 +0000 (19:48 +0000)]
Change PointersToResolve to list the pointee type to resolve, not the
pointer type.
- Drops use of PointerLikeType.
- No intended functionality change.
Steve Naroff [Thu, 26 Feb 2009 19:11:32 +0000 (19:11 +0000)]
Fix <rdar://problem/6574319> clang issues error on 'readonly' property with a defaul setter attribute.
Needed to make isPropertyReadonly() non-const (for this fix to compile). I imagine there's a way to retain the const-ness, however I have more important fish to fry.
Steve Naroff [Thu, 26 Feb 2009 15:55:06 +0000 (15:55 +0000)]
Fix http://llvm.org/bugs/show_bug.cgi?id=3544.
The code for looking up local/private method in Sema::ActOnInstanceMessage() was not handling categories properly. Sema::ActOnClassMessage() didn't have this bug.
Created a helper with the correct logic and changed both methods to use it.
Eli Friedman [Thu, 26 Feb 2009 10:19:36 +0000 (10:19 +0000)]
Remove short-circuit evaluation and the extension warnings. I'm
pretty sure we want to keep constant expression verification outside of
Evaluate. Because of that, the short-circuit evaluation doesn't
generally make sense, and the comma warning doesn't make sense in its
current form.
Eli Friedman [Thu, 26 Feb 2009 09:29:13 +0000 (09:29 +0000)]
Rewrite of isIntegerConstantExpr to be centered around Evaluate. This
is a rather big change, but I think this is the direction we want to go;
the code is significantly shorter now, and it doesn't duplicate Evaluate
code. There shouldn't be any visible changes as far as I know.
There has been some movement towards putting ICE handling into
Evaluate (for example, VerifyIntegerConstantExpression uses Evaluate
instead of isICE). This patch is sort of the opposite of the approach,
making ICE handling work without Evaluate being aware of it. I think
this approach is better because it separates the code that does the
constant evaluation from code that's calculating a rather
arbitrary predicate.
The one thing I don't really like about this patch is that
the handling of commas in C99 complicates it signficantly. (Seriously,
what was the standards committee thinking when they wrote that
part?) I think I've come up with a decent approach, but it doesn't feel
ideal. I might add some way to check for evaluated commas from Evaluate
in a subsequent patch; that said, it might not be worth bothering.
Eli Friedman [Thu, 26 Feb 2009 04:47:58 +0000 (04:47 +0000)]
Zap the Sema constant initializer checking code that we aren't using
anymore. If we want to reuse bits and pieces to add strict checking for
constant initializers, we can dig them out of SVN history; the existing
code won't be useful as-is.
Eli Friedman [Thu, 26 Feb 2009 03:58:54 +0000 (03:58 +0000)]
Fix for PR3663/3669: use TryToFixInvalidVariablyModifiedType for
variable declarations where applicable. Also, a few fixes to
TryToFixInvalidVariablyModifiedType for issues that this exposed.
Douglas Gregor [Wed, 25 Feb 2009 23:02:36 +0000 (23:02 +0000)]
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.
Ted Kremenek [Wed, 25 Feb 2009 22:32:02 +0000 (22:32 +0000)]
Add experimental logic in GRExprEngine::EvalEagerlyAssume() to handle
expressions of the form: 'short x = (y != 10);' While we handle 'int x = (y !=
10)' lazily, the cast to another integer type currently loses the symbolic
constraint. Eager evaluation of the constraint causes the paths to bifurcate and
eagerly evaluate 'y != 10' to a constant of 1 or 0. This should address
<rdar://problem/6619921> until we have a better (more lazy approach) for
handling promotions/truncations of symbolic integer values.
Douglas Gregor [Wed, 25 Feb 2009 22:18:32 +0000 (22:18 +0000)]
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.
Douglas Gregor [Wed, 25 Feb 2009 22:02:03 +0000 (22:02 +0000)]
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).
Daniel Dunbar [Wed, 25 Feb 2009 20:59:29 +0000 (20:59 +0000)]
Temporarily disable clearing of insert point (to indicate unreachable
code) when calling noreturn functions; general expression emission
isn't ready to do the right thing in all cases.
Douglas Gregor [Wed, 25 Feb 2009 19:37:18 +0000 (19:37 +0000)]
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.
Daniel Dunbar [Wed, 25 Feb 2009 19:24:29 +0000 (19:24 +0000)]
Pull COdeGenFunction::CreateStaticBlockVarDecl (just for creating the
global variable) out of GenerateStaticBlockVarDecl.
- No intended functionality change.
- Prep for some mild cleanups and PR3662.
Douglas Gregor [Wed, 25 Feb 2009 16:33:18 +0000 (16:33 +0000)]
C99 DR #316 implies that the function parameter types that are known
only from a function definition (that does not have a prototype) are
only used to determine the compatible with other declarations of that
same function. In particular, when referencing the function we pretend
as if it does not have a prototype. Implement this behavior, which
fixes PR3626.
Chris Lattner [Wed, 25 Feb 2009 05:39:01 +0000 (05:39 +0000)]
Headers are basically done, debug info is just about done (and
will improve a lot this week hopefully), and a libgcc replacement
is ready once I wrangle lawyers.
Ted Kremenek [Tue, 24 Feb 2009 22:07:12 +0000 (22:07 +0000)]
ccc-analyzer: Don't analyze files with '-arch ppc' or '-arch ppc64' since Clang
doesn't support Altivec intrisics nor is it likely that we're currently
generating all the right #defines, etc., for those architectures.
Douglas Gregor [Tue, 24 Feb 2009 19:23:27 +0000 (19:23 +0000)]
Extend the implicit declaration and checking against out-of-scope
external declarations to also support external variable
declarations. Unified the code for these two cases into two new
subroutines.
Note that we fail to diagnose cases like the one Neil pointed
out, where a visible non-external declaration hides an external
declaration by the same name. That will require some reshuffling of
name lookup.
Ted Kremenek [Tue, 24 Feb 2009 19:15:11 +0000 (19:15 +0000)]
retain/release checker:
- For autorelease pool tracking, keep information about the stack of pools
separate from their contents. Also, keep track of the number of times an
autorelease pool will send the "release" message to an object when the pool is
destroyed.
- Update CFRefCount::Update to return a new state instead of a reference count
binding. This will allow us to implement more complicated semantics with
autorelease pools.