Anders Carlsson [Sat, 28 Feb 2009 21:56:50 +0000 (21:56 +0000)]
Fix invalid VLAs/VMs in Sema::ActOnVariableDeclarator, so that the variable will have the right type by the time the initializer is checked. This ensures that code like
Chris Lattner [Sat, 28 Feb 2009 19:37:57 +0000 (19:37 +0000)]
Fix a crash in test/Parser/control-scope.c that testrunner didn't
notice because it was a negative test with a fix suggested by
Jean-Daniel Dupas. Convert the test from a negative to a positive
test to catch stuff like this.
Chris Lattner [Sat, 28 Feb 2009 18:42:10 +0000 (18:42 +0000)]
"This patch addresses two FIXME on ObjCCategoryImplDecl:
/// FIXME: Like ObjCImplementationDecl, this should not be a NamedDecl!
/// FIXME: Introduce a new common base class for ObjCImplementationDecl and ObjCCategoryImplDecl
It adds an IndentifierInfo ivar to the ObjCCategoryImplDecl, so it can inherits from Decl and not NamedDecl (I'm not sure about the memory management of this ivar).
And now that both ObjCImplementationDecl and ObjCCategoryImplDecl have the same super classes, it allow creation of a common base class: ObjCImplDecl"
Chris Lattner [Sat, 28 Feb 2009 18:18:58 +0000 (18:18 +0000)]
after going around in circles a few times, finally cave and emit structure
copies with memcpy instead of memmove. This matches what GCC does and if it
causes a problem with a particular libc we can always fix it with a target
hook.
Anders Carlsson [Sat, 28 Feb 2009 17:11:49 +0000 (17:11 +0000)]
TargetInfo::validateAsmConstraint now takes a reference to the full constraints string. This will make it possible to support multi-character constraints. No functionality change (for now).
Steve Naroff [Sat, 28 Feb 2009 16:48:43 +0000 (16:48 +0000)]
Fix <rdar://problem/6451399> problems with labels and blocks.
- Move the 'LabelMap' from Sema to Scope. To avoid layering problems, the second element is now a 'StmtTy *', which makes the LabelMap a bit more verbose to deal with.
- Add 'ActiveScope' to Sema. Managed by ActOnStartOfFunctionDef(), ObjCActOnStartOfMethodDef(), ActOnBlockStmtExpr().
- Changed ActOnLabelStmt(), ActOnGotoStmt(), ActOnAddrLabel(), and ActOnFinishFunctionBody() to use the new ActiveScope.
- Added FIXME to workaround in ActOnFinishFunctionBody() (for dealing with C++ nested functions).
Eli Friedman [Sat, 28 Feb 2009 05:41:13 +0000 (05:41 +0000)]
Start of checking for gotos which jump to an illegal destination.
As far as I know, this catches all cases of jumping into the scope of a
variable with a variably modified type (excluding statement
expressions) in C. This is missing some stuff we probably want to check
(other kinds of variably modified declarations, statement expressions,
indirect gotos/addresses of labels in a scope, ObjC @try/@finally, cleanup
attribute), the diagnostics aren't very good, and it's not particularly
efficient, but it's a decent start.
This patch is a slightly modified version of the patch I attached to
PR3259, and it fixes that bug. I was sort of planning on improving
it, but I think it's okay as-is, especially since it looks like CodeGen
doesn't have any use for this sort of data structure. The only
significant change I can think of from the version I attached to PR3259
is that this version skips running the checking code when a function
doesn't contain any labels.
This patch doesn't cover case statements, which also need similar
checking; I'm not sure how we should deal with that. Extending the goto
checking to also check case statements wouldn't be too hard; it's just a
matter of keeping track of the scope of the closest switch and checking that
the scope of every case is the same as the scope of the switch. That said,
it would likely be a performance hit to run this check on every
function (it's an extra pass over the entire function), so we probably want
some other solution.
Alignment of pointers in __objc_classlist must be on their
natural alignment. Otherwise, the excess hole confuses the
objc2 runtime (this is darwin specific).
Douglas Gregor [Sat, 28 Feb 2009 00:25:32 +0000 (00:25 +0000)]
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.
Mike Stump [Fri, 27 Feb 2009 22:42:30 +0000 (22:42 +0000)]
Fix PR3612. We ensure that we add builtins to the GlobalDeclMap and
we ensure that things added to the module can be found even when they
are not in GlobalDeclMap. The later is for increased flexibility,
should someone want to do something tricky like extern "Ada" in the
same module.
Ted Kremenek [Fri, 27 Feb 2009 19:58:12 +0000 (19:58 +0000)]
In BuildAnonymousStructUnionMemberReference, we shouldn't invalidate OpLoc when
building nested member expressions. This location is used to determine the range
of the entire expression, and the expression itself already has its location
inherited from its Base.
Douglas Gregor [Fri, 27 Feb 2009 19:31:52 +0000 (19:31 +0000)]
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.
Chris Lattner [Fri, 27 Feb 2009 18:53:28 +0000 (18:53 +0000)]
upgrade various 'implicit int' warnings from an ext-warn to warning when not
in C89 mode. This makes it enabled by default instead of only enabled with
-pedantic. Clang defaults to c99 mode, so people will see this more often
than with GCC, but they can always use -std=c89 if they really want c89.
Ted Kremenek [Fri, 27 Feb 2009 17:58:43 +0000 (17:58 +0000)]
When checking printf-arguments for functions with '__attribute__ ((format (printf, X, Y)))'
set HasVAListArg to true when 'Y' is 0 (i.e., ignore the data arguments).
Eli Friedman [Fri, 27 Feb 2009 06:44:11 +0000 (06:44 +0000)]
Change the AST generated for offsetof a bit so that it looks like a
normal expression, and change Evaluate and IRGen to evaluate it like a
normal expression. This simplifies the code significantly, and fixes
PR3396.
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.