Chris Lattner [Sat, 18 Apr 2009 22:35:34 +0000 (22:35 +0000)]
I didn't understand how @catches were chained. Now that I get it, fix
the scope checker to not think @catches are nested in each other, eliminating
some bogus notes.
Chris Lattner [Sat, 18 Apr 2009 21:28:52 +0000 (21:28 +0000)]
reject invalid jumps among pieces of @try blocks. This seems to work
reasonably well except for the problem that @catches are nested within
each other in the AST, giving the ugly diagnostics in L8.
Chris Lattner [Sat, 18 Apr 2009 21:00:42 +0000 (21:00 +0000)]
unconditionally check for goto correctness. This is because switch
statements don't end up in the LabelMap so we don't have a quick way
to filter them. We could add state to Sema (a "has vla" and "has
jump" bit) to try to filter this out, but that would be sort of gross
and I'm not convinced it is the best way. Thoughts welcome.
Anders Carlsson [Sat, 18 Apr 2009 20:20:22 +0000 (20:20 +0000)]
Make CodeGenFunction::EmitCallArgs a template function that takes a generic "Type Info" parameter. The type info parameter knows how to iterate over its arguments.
Chris Lattner [Sat, 18 Apr 2009 20:05:34 +0000 (20:05 +0000)]
fix two error paths out of ParseBlockLiteralExpression to
call ActOnBlockError so that CurBlock gets popped. This
fixes a crash on test/block-syntax-error.c when this new
assertion is enabled.
Chris Lattner [Sat, 18 Apr 2009 20:01:55 +0000 (20:01 +0000)]
refactor some code, adding a new getLabelMap() accessor method
so that clients can't poke the function-local one when they really
want the current block label. No functionality change.
Chris Lattner [Sat, 18 Apr 2009 19:50:02 +0000 (19:50 +0000)]
Improve switch diagnostic to emit the "jump" message on the
specific bad case instead of on the switch. Putting it on the
switch means you don't know what case is the problem. For
example:
scope-check.c:54:3: error: illegal switch case into protected scope
case 2:
^
scope-check.c:53:9: note: jump bypasses initialization of variable length array
int a[x];
^
Chris Lattner [Sat, 18 Apr 2009 19:30:02 +0000 (19:30 +0000)]
fix error recovery in the case of a jump to a label with no definition
to create a well formed AST instead of a dangling pointer. This resolves
several fixme's.
Chris Lattner [Sat, 18 Apr 2009 19:11:11 +0000 (19:11 +0000)]
glibc plays some weird games with multiple different definitions of
int8_t and games it with strange *_defined macros. Emulate its weirdness
for better compatibility with linux etc. Problem pointed out by anders
johnson.
Chris Lattner [Sat, 18 Apr 2009 18:35:15 +0000 (18:35 +0000)]
more fun with line markers: the digit string is required to be interpreted
as decimal, even if it starts with 0. Also, since things like 0x1 are
completely illegal, don't even bother using numericliteralparser for them.
Chris Lattner [Sat, 18 Apr 2009 09:36:27 +0000 (09:36 +0000)]
rewrite the goto scope checking code to be more efficient, simpler,
produce better diagnostics, and be more correct in ObjC cases (fixing
rdar://6803963).
An example is that we now diagnose:
int test1(int x) {
goto L;
int a[x];
int b[x];
L:
return sizeof a;
}
with:
scope-check.c:15:3: error: illegal goto into protected scope
goto L;
^
scope-check.c:17:7: note: scope created by variable length array
int b[x];
^
scope-check.c:16:7: note: scope created by variable length array
int a[x];
^
instead of just saying "invalid jump". An ObjC example is:
Douglas Gregor [Sat, 18 Apr 2009 05:55:16 +0000 (05:55 +0000)]
Store the type ID for __builtin_va_list in the PCH file, so that the
AST context's __builtin_va_list type will be set when the PCH file is
loaded. This fixes the crash when CodeGen'ing a va_arg expression
pulled in from a PCH file.
Chris Lattner [Sat, 18 Apr 2009 01:13:56 +0000 (01:13 +0000)]
Substantially restructure function-like macro argument parsing.
Highlights: PP::isNextPPTokenLParen() no longer eats the (
when present. We now simplify slightly the logic parsing
macro arguments. We now handle PR3937 and other related cases
correctly.
Douglas Gregor [Sat, 18 Apr 2009 00:07:54 +0000 (00:07 +0000)]
Lazy deserialization of function bodies for PCH files. For the Carbon
"Hello, World!", this takes us from deserializing 6469
statements/expressions down to deserializing 1
statement/expression. It only translated into a 1% improvement on the
Carbon-prefixed 403.gcc, but (a) it's the right thing to do, and (b)
we expect this to matter more once we lazily deserialize identifiers.
Douglas Gregor [Sat, 18 Apr 2009 00:02:19 +0000 (00:02 +0000)]
FunctionDecl::getBody() is getting an ASTContext argument for use in
lazy PCH deserialization. Propagate that argument wherever it needs to
be. No functionality change, except that I've tightened up a few PCH
tests in preparation.
Douglas Gregor [Fri, 17 Apr 2009 22:13:46 +0000 (22:13 +0000)]
Keep track of the number of statements/expressions written to and read
from a PCH file. It turns out that "Hello, World!" is bringing in 19%
of all of the statements in Carbon.h, so we need to be lazy.
Chris Lattner [Fri, 17 Apr 2009 22:04:20 +0000 (22:04 +0000)]
tweak redefinition of a typedef a bit to fix a couple of problems:
1. We had logic in sema to decide whether or not to emit the error
based on manually checking whether in a system header file.
2. we were allowing redefinitions of typedefs in class scope in C++
if in header file.
3. there was no way to force typedef redefinitions to be accepted
by the C compiler, which annoys me when stripping linemarkers out
of .i files.
The fix is to split the C++ class typedef redefinition path from the
C path, and change the C path to be a warning that normally maps to
error. This causes it to properly be ignored in system headers,
etc. and gives us a way to control it. Passing
-Wtypedef-redefinition now turns the error into a warning.
One behavior change is that we now diagnose cases where you redefine
a typedef in your .c file that was defined in a header file. This
seems like reasonable behavior, and the diagnostic now indicates that
it can be controlled with -Wtypedef-redefinition.
Douglas Gregor [Fri, 17 Apr 2009 21:46:47 +0000 (21:46 +0000)]
Fix two embarrassing PCH bugs:
1) Accidentally used delete [] on an array of statements that was allocated with ASTContext's allocator
2) Deserialization of names with multiple declarations (e.g., a struct and a function) used the wrong mangling constant, causing it to view declaration IDs as Decl*s.
Chris Lattner [Fri, 17 Apr 2009 21:05:01 +0000 (21:05 +0000)]
implement a new clang-cc option -dump-build-information=filename which causes the
compiler to dump random stuff from the build into the file. Right now this
amounts to dumping command line arguments and diagnostics to the file.
The idea is that you can set an envvar, do a world build of an OS, then grep
through all the logs for interesting things or something.
Daniel, please wire the driver up to do something with this.
Chris Lattner [Fri, 17 Apr 2009 19:32:54 +0000 (19:32 +0000)]
fix a crash on invalid by making ActOnDeclarator create decl with
a dummy *function* type when it is recovering and knows it needs
a function. rdar://6802350 - clang crash on invalid input
Chris Lattner [Fri, 17 Apr 2009 18:28:37 +0000 (18:28 +0000)]
move a vector conversion warning to be diabled by default (like gcc),
but add it to -Wall (unlike gcc) and give it a controlling group
(-Wvector-conversions).
Chris Lattner [Fri, 17 Apr 2009 17:46:19 +0000 (17:46 +0000)]
Fix rdar://6800926 - crash compiling non-fragile _Bool bitfield ivar,
the functional change here is changing ConvertType -> ConvertTypeForMem
so that we handle i1 fields properly as memory.
Daniel Dunbar [Fri, 17 Apr 2009 01:54:00 +0000 (01:54 +0000)]
Support QA_OVERRIDE_GCC3_OPTIONS
- Cover your eyes...
- This is a simple but effective way to allow developers to build a
project with clang while manipulating the command line, without
having to edit the project itself.