Commit Graph

2863 Commits

Author SHA1 Message Date
Daniel Dunbar 9a7a78b0ae Fix bug in computation of ivar offsets for (adjacent) bitfields.
- The confusing IRgen bitfield interface is partly to blame here;
   fixing the functional error for now, cleanups to the interface to
   follow.

llvm-svn: 69503
2009-04-19 02:03:42 +00:00
Chris Lattner c67540501f second half of indirect jump checking: make sure that any
address taken labels are in function scope

llvm-svn: 69499
2009-04-19 01:16:06 +00:00
Chris Lattner 0bf2dd2ed4 First half of jump scope checking for indirect goto.
llvm-svn: 69498
2009-04-19 01:05:26 +00:00
Chris Lattner 19bd27f493 add some testcases that we do not correctly handle.
llvm-svn: 69492
2009-04-18 23:07:55 +00:00
Chris Lattner f7fcb516de reimplement DeclStmt handling so that we correctly handle intermixed
VLA's and statement expressions.

llvm-svn: 69491
2009-04-18 23:01:20 +00:00
Chris Lattner a0cfd6b610 rearrange.
llvm-svn: 69490
2009-04-18 22:56:52 +00:00
Chris Lattner fb5ef701d5 add testcases for some more scary/horrible things that work.
llvm-svn: 69488
2009-04-18 22:42:18 +00:00
Chris Lattner 508253d64b the scope checker does work with objc methods, add testcase.
llvm-svn: 69487
2009-04-18 22:37:38 +00:00
Chris Lattner b6e368235a 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.

llvm-svn: 69486
2009-04-18 22:35:34 +00:00
Chris Lattner bf78da7b36 Fix PR3917: the location of a #line directive is the location of the first _.
llvm-svn: 69485
2009-04-18 22:29:33 +00:00
Chris Lattner 5c926f3660 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.

llvm-svn: 69477
2009-04-18 21:28:52 +00:00
Chris Lattner 1d4fc1bc6d 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.

llvm-svn: 69476
2009-04-18 21:00:42 +00:00
Daniel Dunbar f45dbd8c7b Test case would allow clang to fail.
llvm-svn: 69470
2009-04-18 20:23:29 +00:00
Chris Lattner b0cb5b2db2 merge two tests.
llvm-svn: 69466
2009-04-18 20:12:56 +00:00
Chris Lattner 96b3139773 abstract the SwitchStack for blocks just like we do the goto labels.
This fixes a crash on invalid (test10). rdar://6805469

llvm-svn: 69465
2009-04-18 20:10:59 +00:00
Chris Lattner 36dec99d12 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];
        ^

llvm-svn: 69462
2009-04-18 19:50:02 +00:00
Chris Lattner 7535f41c66 first step to getting switches giving "jump into vla scope" errors.
llvm-svn: 69461
2009-04-18 19:42:37 +00:00
Chris Lattner 8560addfa6 add some block goto test cases.
llvm-svn: 69460
2009-04-18 19:32:54 +00:00
Chris Lattner a2ac7aab6e make sure to verify that the "non pch" runs worked.
llvm-svn: 69457
2009-04-18 18:45:36 +00:00
Chris Lattner 07f62f1881 improve wording of scope violation error messages.
llvm-svn: 69456
2009-04-18 18:42:55 +00:00
Chris Lattner e227091199 rename test
llvm-svn: 69455
2009-04-18 18:41:40 +00:00
Chris Lattner d66f172ab1 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.

llvm-svn: 69454
2009-04-18 18:35:15 +00:00
Douglas Gregor f21701b70c Fix test to output LLVM to a temporary file, which we grep as part of the test
llvm-svn: 69448
2009-04-18 15:48:37 +00:00
Chris Lattner 960cc525ec 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:

void test1() {
  goto L;
  @try {
L: ;
  } @finally {
  }
}

t.m:6:3: error: illegal goto into protected scope
  goto L;
  ^
t.m:7:3: note: scope created by @try block
  @try {
  ^

There are a whole ton of fixme's for stuff to do, but I believe that this
is a monotonic improvement over what we had.

llvm-svn: 69437
2009-04-18 09:36:27 +00:00
Daniel Dunbar 41595d43d5 Use getAsPointerType instead of using getCanonicalType directly.
- <rdar://problem/6803995>

llvm-svn: 69435
2009-04-18 08:54:40 +00:00
Chris Lattner 9f3e711503 add another testcase
llvm-svn: 69432
2009-04-18 07:54:11 +00:00
Chris Lattner c2e868fd14 fix incorrect lowering of __builtin_ia32_shufpd, rdar://6803924
llvm-svn: 69428
2009-04-18 07:01:54 +00:00
Chris Lattner 032f7665d0 rename file.
llvm-svn: 69427
2009-04-18 07:00:54 +00:00
Chris Lattner 85e4dd4055 don't dump .ll file in this dir.
llvm-svn: 69426
2009-04-18 07:00:06 +00:00
Chris Lattner 24ad8621a4 __builtin_prefetch should be declared as "void __builtin_prefetch(const void *)",
not "const void __builtin_prefetch(void *)".  This fixes PR3912.

llvm-svn: 69425
2009-04-18 06:51:21 +00:00
Chris Lattner 974e1f40b3 rename test
llvm-svn: 69424
2009-04-18 06:49:47 +00:00
Chris Lattner 35dd5056fc fix PR3927 by being more careful about the pp test for identifier.
llvm-svn: 69423
2009-04-18 06:44:18 +00:00
Chris Lattner 5ca5d40cf4 second half of PR3940: #line requires simple digit sequence.
llvm-svn: 69422
2009-04-18 06:38:24 +00:00
Douglas Gregor 652d82a096 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.

llvm-svn: 69421
2009-04-18 05:55:16 +00:00
Chris Lattner 751f045e32 this is really just a recommendation, not a requirement.
llvm-svn: 69416
2009-04-18 02:25:14 +00:00
Chris Lattner 2425bcb49a enforce requirements imposed by C90 6.8 TC1, fixing PR3919.
llvm-svn: 69415
2009-04-18 02:23:25 +00:00
Chris Lattner bc63de144f Fix PR3938 by taking into account C99 6.10p4.
llvm-svn: 69413
2009-04-18 01:34:22 +00:00
Chris Lattner b547394ba5 convert test to -verify style.
llvm-svn: 69412
2009-04-18 01:33:54 +00:00
Chris Lattner c17925da61 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.

llvm-svn: 69411
2009-04-18 01:13:56 +00:00
Douglas Gregor e3dcb2ddd1 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.

llvm-svn: 69406
2009-04-18 00:02:19 +00:00
Chris Lattner b40289b2b8 Fix two problems from PR3916, and one problem I noticed while hacking
on the code.

llvm-svn: 69404
2009-04-17 23:56:52 +00:00
Chris Lattner ca556cb3e3 implement PR3940: #line numbers not fully checked
llvm-svn: 69403
2009-04-17 23:37:49 +00:00
Chris Lattner 0003c27f5e #line is allowed to have macros that expand to nothing after them.
llvm-svn: 69401
2009-04-17 23:30:53 +00:00
Chris Lattner 6fdd57cba8 fix a crash compiling code with its own definition of objc_assign_weak.
rdar://6800430

llvm-svn: 69392
2009-04-17 22:12:36 +00:00
Chris Lattner 2581fc3fa9 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.

llvm-svn: 69391
2009-04-17 22:04:20 +00:00
Douglas Gregor ba6e557378 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.

403.gcc builds and links properly.

llvm-svn: 69390
2009-04-17 21:46:47 +00:00
Douglas Gregor f994f062fd PCH support for inline assembly statements.
This completes support for all of C (+ extensions). We can (again)
build a PCH file for Carbon.h.

llvm-svn: 69385
2009-04-17 20:57:14 +00:00
Douglas Gregor 5ceb1a2dd9 PCH tests for va_arg expressions. Verified that the blocks test does create a BlockDeclRefExpr
llvm-svn: 69376
2009-04-17 20:06:59 +00:00
Chris Lattner fbbf539c45 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

llvm-svn: 69374
2009-04-17 19:32:54 +00:00
Douglas Gregor c95701da6c PCH support for blocks
llvm-svn: 69373
2009-04-17 19:21:43 +00:00