Commit Graph

5769 Commits

Author SHA1 Message Date
Douglas Gregor fa9ab53d95 Fix emission of static tentative definitions referenced from other static functions
llvm-svn: 69699
2009-04-21 19:28:58 +00:00
Daniel Dunbar 2655f85975 Revert 69694 (use of undefined getSymbol)
llvm-svn: 69697
2009-04-21 18:54:52 +00:00
Fariborz Jahanian f5fec02d0c More objc2's ivar layout bitmap. No change in functionality.
llvm-svn: 69695
2009-04-21 18:33:06 +00:00
Ted Kremenek 99de8ae19c Add pretty-printing for CodeTextRegions.
llvm-svn: 69694
2009-04-21 18:31:19 +00:00
Ted Kremenek 7421c0161a Lexically order the implementation of MemRegion 'print' methods. No functionality change.
llvm-svn: 69688
2009-04-21 18:09:22 +00:00
Chris Lattner b534f6a601 don't bother emitting a zero byte memset at all. We used to get them
in cases like this:

typedef struct {
  short instance;
  char name[0];
} ATTR_LIST_ENTRY2;

void test() {
  ATTR_LIST_ENTRY2 X = (ATTR_LIST_ENTRY2) { .instance = 7, };
}  

While it is safe to emit them, it is pretty silly.

llvm-svn: 69687
2009-04-21 17:59:23 +00:00
Ted Kremenek 30fb341f4f Use 'getAs<CodeTextRegion>' instead of 'dyn_cast<CodeTextRegion>' to handle any
layered regions.

llvm-svn: 69686
2009-04-21 17:37:26 +00:00
Douglas Gregor beecd58e21 Explictly track tentative definitions within Sema, then hand those
tentative definitions off to the ASTConsumer at the end of the
translation unit. 

Eliminate CodeGen's internal tracking of tentative definitions, and
instead hook into ASTConsumer::CompleteTentativeDefinition. Also,
tweak the definition-deferal logic for C++, where there are no
tentative definitions.

Fixes <rdar://problem/6808352>, and will make it much easier for
precompiled headers to cope with tentative definitions in the future.

llvm-svn: 69681
2009-04-21 17:11:58 +00:00
Daniel Dunbar 93c1914de3 Use an ASTRecordLayout to compute the sizeof an interface, not
addRecordToClass.
 - Among other things, this fixes a crash when applying sizeof to an
   interface with synthesized ivars, although things still aren't
   "correct" here.

llvm-svn: 69675
2009-04-21 15:48:54 +00:00
Steve Naroff 426662ba79 Add pch reader/writer support for most of DeclObjC.h. Very close to reading/writing all ObjC AST nodes that we will encounter in header files (still a few FIXME's).
Once selector support is in place, we should be able to take this for a spin (and add test cases).

llvm-svn: 69674
2009-04-21 15:12:33 +00:00
Chris Lattner 3501d43a10 implement semantic analysis for @synchronized, fixing a crash on invalid
rdar://6810940 - @synchronized has no sema checks

llvm-svn: 69670
2009-04-21 06:11:25 +00:00
Chris Lattner 6af6edb8b7 this time with more workingness.
llvm-svn: 69669
2009-04-21 06:06:09 +00:00
Sanjiv Gupta 4c5dfd3c45 Pass and return aggregate types directly to function calls.
llvm-svn: 69668
2009-04-21 06:01:16 +00:00
Chris Lattner c70dd56477 add support for goto checking and @synchronized blocks,
rdar://6810106

llvm-svn: 69667
2009-04-21 06:01:00 +00:00
Chris Lattner e08c43a3b0 fix massive testsuite failures from Alexei's patch due to inverted logic.
llvm-svn: 69666
2009-04-21 06:00:24 +00:00
Chris Lattner 2f5693f62d Split preprocessor initialization logic out of clang-cc into
libfrontend.  Patch by Alexei Svitkine!

llvm-svn: 69664
2009-04-21 05:40:52 +00:00
Chris Lattner 6968641ac5 rename -fprint-source-range-info -> -fdiagnostics-print-source-range-info.
Temporarily accept both of them, I'll rip out the old one after awhile.

llvm-svn: 69662
2009-04-21 05:34:31 +00:00
Chris Lattner 1f02e054a9 Fix PR4027 + rdar://6808859, we were rejecting implicit casts of
aggregates even though we already accept explicit ones.  Easy fix.

llvm-svn: 69661
2009-04-21 05:19:11 +00:00
Chris Lattner d6e97af74a improve MacroInfo to track the source range of the macro definition,
patch by Alexei Svitkine!

llvm-svn: 69659
2009-04-21 04:46:33 +00:00
Chris Lattner a9aeea9f27 use of predefined identifiers like __func__ at global scope warn in sema,
but crashed codegen.  Fix this to report the name of the llvm function.
This fixes rdar://6808051

llvm-svn: 69658
2009-04-21 04:41:23 +00:00
Chris Lattner 92b29b2f9f make "in included from" and "in instatiation from" messages respect
-fno-show-location, patch by Alexei Svitkine (PR4024)

llvm-svn: 69657
2009-04-21 03:57:54 +00:00
Chris Lattner cd6d4b105a add a preprocessor callback function for #undef, patch by
Alexei Svitkine!

llvm-svn: 69656
2009-04-21 03:42:09 +00:00
Anders Carlsson 6f2878360c Add a CXXDestroyExpr. Add classof member functions to CXXTempVarDecl.
llvm-svn: 69654
2009-04-21 02:22:11 +00:00
Sanjiv Gupta f09cb95236 Use an APInt of target int size to detect overflow while parsing multichars.
So 'abc' on i16 platforms will warn but not on i32 platforms.

llvm-svn: 69653
2009-04-21 02:21:29 +00:00
Anders Carlsson 21d30b41fc Add the beginnings of a CXXTempVarDecl class.
llvm-svn: 69652
2009-04-21 01:57:48 +00:00
Daniel Dunbar e000df6882 Remove unnused variable.
llvm-svn: 69650
2009-04-21 01:32:46 +00:00
Daniel Dunbar 9ebf9516af Kill ASTContext::[gs]etFieldForDecl, instead we just lookup things
when we need them -- which is exactly what some code was already
doing!
 - No intended functionality change.

llvm-svn: 69648
2009-04-21 01:19:28 +00:00
Mike Stump 3214d12325 Fixup codegen for write barriers for block variables. Radar 6786715
llvm-svn: 69642
2009-04-21 00:51:43 +00:00
Daniel Dunbar be9dae80b3 Remove LateBoundIVars() runtime interface, it is unused.
llvm-svn: 69641
2009-04-21 00:49:20 +00:00
Daniel Dunbar e03f005d30 Assert on a few conditions that (I believe) should hold
w.r.t. ASTContext::[gs]etFieldDecl, and the Field argument to
EmitObjCValueForIvar).

llvm-svn: 69639
2009-04-21 00:41:40 +00:00
Daniel Dunbar 712e4dee26 Look at the TMP environment variable as well.
llvm-svn: 69638
2009-04-21 00:25:10 +00:00
Fariborz Jahanian 80c9ce2c4a ObjC2's Ivar bitmap layout work. No change in functionality.
llvm-svn: 69629
2009-04-20 22:03:45 +00:00
Chris Lattner f4c68741d4 fix the second half of PR4006 and rdar://6807000 by treating
() as being either zero arguments or one empty argument depending
on situation.

llvm-svn: 69627
2009-04-20 21:08:10 +00:00
Douglas Gregor e84a9daa16 Write the identifier table into the PCH file as an on-disk hash table
that also includes the contents of the IdentifierInfo itself (the
various fields and flags, along with the chain of identifiers visible
at the top level that have that name).

We don't make any use of the hash table yet, except that our
identifier ID -> string mapping points into the hash table now.

llvm-svn: 69625
2009-04-20 20:36:09 +00:00
Anders Carlsson 9603143c5d Fix tyop in SSSE3 header (6808876).
llvm-svn: 69623
2009-04-20 20:31:10 +00:00
Daniel Dunbar c35694da21 Also look at the TEMP environment variable as a place to put temporary
files.

llvm-svn: 69622
2009-04-20 20:28:21 +00:00
Daniel Dunbar e3f5cfc0b8 Move countInheritedIvars to within striking distance of
GetClassSizeInfo

Reduce nesting in GetInterfaceDeclStructLayout.

Tweak some comments.

No functionality change.

llvm-svn: 69621
2009-04-20 20:18:54 +00:00
Steve Naroff aac654abeb Add pch reader/writer support for ObjCContainerDecl, ObjCInterfaceDecl, & ObjCIvarDecl.
Next step: Add selector support to PCHWriter::AddDeclarationName().

llvm-svn: 69619
2009-04-20 20:09:33 +00:00
Chris Lattner ddf6ca0355 the __gnuc_inline__ attribute is actually named __gnu_inline__,
PR4023

llvm-svn: 69618
2009-04-20 19:12:28 +00:00
Daniel Dunbar ab8ce7cddb If defined, use TMPDIR environment variable as location for temporary files.
llvm-svn: 69609
2009-04-20 17:32:49 +00:00
Chris Lattner f9b00eb7dc clean up anonymous bitfield diagnostics, PR4017
llvm-svn: 69608
2009-04-20 17:29:38 +00:00
Douglas Gregor 162dd0245e Introduce the notion of a SemaConsumer, which is an ASTConsumer that
also gets access to the Sema object performing semantic analysis. This
will be used by the PCH writer to serialize Sema state.

No functionality change.

llvm-svn: 69595
2009-04-20 15:53:59 +00:00
Steve Naroff 04f2d14d6a Add pch reader/writer support for ObjCMethodDecl.
Test will be enabled with ObjCInterfaceDecl is added.

llvm-svn: 69594
2009-04-20 15:06:07 +00:00
Eli Friedman 3a1e692fed Some cleanup and bug-fixing for address-of checking. This causes a couple of
minor accepts-invalid regressions, but we weren't really rejecting them for 
the right reason.  We really need a more general solution to detect all the 
cases of the promotion of arrays with a register storage class.

llvm-svn: 69586
2009-04-20 08:23:18 +00:00
Daniel Dunbar be1f26df5d Inline GetFirstIvarInRecord into sole caller.
- No functionality change.

llvm-svn: 69582
2009-04-20 07:18:49 +00:00
Daniel Dunbar 75e909f5e0 Set a bit in IMAGE_INFO to indicate that we don't contain any
@synthesized ivars for superclasses.
 - <rdar://problem/6806371> [clang] Mark code without miscompiled
   @synthesized properties

llvm-svn: 69581
2009-04-20 07:11:47 +00:00
Douglas Gregor 52289d3343 Move the on-disk hash table code into its own header. No functionality change.
llvm-svn: 69580
2009-04-20 07:08:21 +00:00
Daniel Dunbar f5c18461e3 Lift out GetNamedIvarList.
Drop uses of GetFirstInvarInRecord, instead we lookup the ivars we
know are in the record.
 - This is somewhat less efficient, but I need to detangle this code
   first...

llvm-svn: 69579
2009-04-20 06:54:31 +00:00
Daniel Dunbar c040ce459c Make FieldDecl parameter to getObjCEncodingForType... const.
llvm-svn: 69578
2009-04-20 06:37:24 +00:00
Zhongxing Xu 3070210377 Remove loc::FuncVal.
llvm-svn: 69577
2009-04-20 06:35:22 +00:00
Daniel Dunbar 69a79b1a60 Don't crash in the diagnostic printer if we happen to get passed a
null string / identifier.

llvm-svn: 69575
2009-04-20 06:13:16 +00:00
Daniel Dunbar caec0238bc Don't emit ivar offsets for unnamed bit fields.
Also, added assertion that the field matches what would be looked up.

llvm-svn: 69572
2009-04-20 05:53:40 +00:00
Zhongxing Xu ac1294318d get a CodeTextRegion when visiting FunctionDecl reference.
get FunctionDecl with more general utility method.

llvm-svn: 69570
2009-04-20 05:24:46 +00:00
Eli Friedman bc633beda4 PR3247: Handle a couple of cases where we weren't emitting VLA sizes (and
subsequently crashed).

llvm-svn: 69567
2009-04-20 03:54:15 +00:00
Eli Friedman 3253e189c6 PR3248: Make sure the evaluate the operand of a sizeof when it has a VLA type.
Adapted from patch by Tim Northover.

llvm-svn: 69566
2009-04-20 03:21:44 +00:00
Zhongxing Xu 23e1f45664 As we now have ValueManager as the new value factory, we do not need factory
methods of SVal.

llvm-svn: 69565
2009-04-20 02:27:09 +00:00
Daniel Dunbar 5d5dbb1754 Remove non-const form of lookupFieldDeclForIvar.
llvm-svn: 69563
2009-04-20 00:37:55 +00:00
Daniel Dunbar ae03226bc6 Comment fixes.
llvm-svn: 69562
2009-04-20 00:33:43 +00:00
Daniel Dunbar 554fd79b38 Lift GetClassSizeInfo out of GenerateClass, add a FIXME.
- No functionality change.

llvm-svn: 69561
2009-04-19 23:41:48 +00:00
Chris Lattner 504af1177d implement "#pragma GCC diagnostic". Besides being a nice feature, this
will let us test for multiple different warning modes in the same
file in regression tests.

This implements rdar://2362963, a 10-year old feature request :)

llvm-svn: 69560
2009-04-19 23:16:58 +00:00
Chris Lattner c6fafed04c move group twiddling options into Diagnostic.cpp instead of
Warnings.cpp.  Warnings.cpp now doesn't need to #include
tblgen produced output directly.

llvm-svn: 69559
2009-04-19 22:34:23 +00:00
Chris Lattner 3251e3cfaa don't crash on invalid ranges in -fprint-source-range-info
mode, just ignore them as usual.

llvm-svn: 69558
2009-04-19 22:24:10 +00:00
Chris Lattner df2226839f Warn about uses of #pragma STDC FENV_ACCESS ON, since we don't
support it.  I don't know what evaluation method we use for complex
arithmetic, so I don't know whether/if we should warn about use of
CX_LIMITED_RANGE.

This concludes my planned hacking on STDC pragmas, flame away :)

llvm-svn: 69556
2009-04-19 21:55:32 +00:00
Sebastian Redl 8ce189f9ce Conditional operator C++ checking complete. What issues remain are in more general code.
llvm-svn: 69555
2009-04-19 21:53:20 +00:00
Chris Lattner 02ef4e3dba diagnose invalid syntax of STDC pragmas.
llvm-svn: 69554
2009-04-19 21:50:08 +00:00
Eli Friedman daea3f62b5 Print an error for uses of __thread on targets which don't support it.
llvm-svn: 69553
2009-04-19 21:48:33 +00:00
Eli Friedman d88c8a104f Add target property for whether thread-local storage is supported.
Let me know if I messed up for some target.  Note that for Windows, we 
should be able to support it (MSVC supports "__declspec(thread)"), but 
I'm pretty sure LLVM doesn't know how to generate the correct code.

llvm-svn: 69552
2009-04-19 21:38:35 +00:00
Chris Lattner a0b1f76d10 reject invalid stuff in the STDC namespace.
llvm-svn: 69551
2009-04-19 21:25:37 +00:00
Chris Lattner 958ee04368 stub out STDC #pragmas.
llvm-svn: 69550
2009-04-19 21:20:35 +00:00
Daniel Dunbar f5e9b1f5d0 Forward f[no-]dollars-in-identifiers to clang, when specified.
llvm-svn: 69549
2009-04-19 21:20:32 +00:00
Sebastian Redl 0753c6f591 Bring member pointer operands of the conditional operator to a common type. We're getting there ...
llvm-svn: 69548
2009-04-19 21:15:26 +00:00
Chris Lattner 21656f22db basic support for -Wunknown-pragmas, more coming.
llvm-svn: 69547
2009-04-19 21:10:26 +00:00
Daniel Dunbar 8281bdeb4d Forward -fno-diagnostics-fixit-info to clang-cc.
llvm-svn: 69546
2009-04-19 21:09:34 +00:00
Eli Friedman 4f856744e5 PR3853: Add CodeGen support for __thread.
llvm-svn: 69545
2009-04-19 21:05:03 +00:00
Chris Lattner 1c1a00cf51 move token paste poisoning diagnostics to after the instantiation loc
for a token is set, this makes the diagnostic "expanded from stack" work
for this diagnostic.  Add a testcase for PR3918.

llvm-svn: 69544
2009-04-19 20:29:42 +00:00
Eli Friedman d5c0eeda72 Add more thorough/correct checking for invalid __thread specifiers.
llvm-svn: 69542
2009-04-19 20:27:55 +00:00
Eli Friedman fe92e701aa Silence gcc warning.
llvm-svn: 69541
2009-04-19 20:21:56 +00:00
Chris Lattner da4ebb8921 Fix PR3918: Invalid use of __VA_ARGS__ not diagnosed,
by rejecting invalid poisoned tokens in the token
pasting path.

llvm-svn: 69536
2009-04-19 20:06:32 +00:00
Sebastian Redl 3b7ef5e374 Another piece of the conditional operator puzzle. We'll want to use FindCompositePointerType in some other places, too.
llvm-svn: 69534
2009-04-19 19:26:31 +00:00
Chris Lattner 249c38bb02 Fix PR4006, incorrect handling of __VA_ARGS__ when it was the first token
in a function-like macro body.  This has the added bonus of moving some
function-like macro specific code out of the object-like macro codepath.

llvm-svn: 69530
2009-04-19 18:26:34 +00:00
Chris Lattner 6df41af7fb actually just do this on all x86 targets, it won't hurt
non-glibc ones.

llvm-svn: 69528
2009-04-19 17:32:33 +00:00
Chris Lattner 4997b8ef98 Define __NO_MATH_INLINES on linux/x86 so that we don't get inline
functions in glibc header files that use FP Stack inline asm which the
backend can't deal with (PR879).

This "fixes" PR3970 for linux.  Other affected systems should do similar
things.  Maybe this should just go to the general i386/x86-64 sections?

llvm-svn: 69527
2009-04-19 17:29:50 +00:00
Chris Lattner 29d34cabc5 implement compiler support for -fno-diagnostics-fixit-info,
rdar://6805442

llvm-svn: 69525
2009-04-19 07:44:08 +00:00
Chris Lattner 5f65cc8215 silence a warning, it isn't clear what the right answer is here,
will talk to steve.

llvm-svn: 69519
2009-04-19 06:59:18 +00:00
Chris Lattner 96adcd5e74 silence a warning, I need to talk to Devang about this code.
llvm-svn: 69517
2009-04-19 06:50:29 +00:00
Chris Lattner b433b279f3 Fix rdar://6804402 - crash on objc implementations declared with
@class but no implementation.  This was broken in all 3 runtime
impls.

llvm-svn: 69512
2009-04-19 06:02:28 +00:00
Chris Lattner 4e1f0c6757 rearrange #include order.
llvm-svn: 69511
2009-04-19 05:30:08 +00:00
Chris Lattner 45542ea107 run the jump checker on blocks, even though they don't have gotos,
they do allow switches.

llvm-svn: 69510
2009-04-19 05:28:12 +00:00
Chris Lattner 9fecd743ca add a new Sema::CurFunctionNeedsScopeChecking bool that is used to avoid
calling into the jump checker when a function or method is known to contain
no VLAs or @try blocks.

llvm-svn: 69509
2009-04-19 05:21:20 +00:00
Chris Lattner 1a1fdbd75d move jump scope checking and related code out into its own file, SemaDecl.cpp is
already too large.

llvm-svn: 69505
2009-04-19 04:46:21 +00:00
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 cd3bb8f7e4 revert david's patch, which causes a testsuite failure.
llvm-svn: 69501
2009-04-19 01:33:30 +00:00
Chris Lattner cc6892e336 rewrite an O(N^2) algorithm to be O(n).
llvm-svn: 69500
2009-04-19 01:32:00 +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 34d9a51892 Add location info for indirect goto.
llvm-svn: 69497
2009-04-19 01:04:21 +00:00
Daniel Dunbar bf90b33665 Reuse ObjcIvarOffsetVariable instead of duplicating code.
- No functionality change (but added a FIXME).

llvm-svn: 69496
2009-04-19 00:44:02 +00:00
Daniel Dunbar a106052090 Remove some unnecessary complexity.
- No functionality change.

llvm-svn: 69495
2009-04-19 00:31:15 +00:00
Chris Lattner c1b96c3590 "This patch fixes message sends to super in class methods for the GNU runtime (currently an instance method lookup is being performed)."
Patch by David Chisnall!

llvm-svn: 69493
2009-04-18 23:12:40 +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 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 93017cc12a Change Preprocessor::AdvanceToTokenCharacter to stop at
the first real character of a token.  For example, advancing
to byte 3 of foo\
bar

should stop at the b, not the \.

llvm-svn: 69484
2009-04-18 22:28:58 +00:00
Chris Lattner 38b2cde4c4 add a new Lexer::SkipEscapedNewLines method.
llvm-svn: 69483
2009-04-18 22:27:02 +00:00
Chris Lattner fbce7aa1f4 factor escape newline measuring out into its own helper function.
llvm-svn: 69482
2009-04-18 22:05:41 +00:00
Chris Lattner dfbfc44df7 remove unneeded scopes.
llvm-svn: 69481
2009-04-18 21:57:20 +00:00
Chris Lattner 637652d959 forgot to commit this before.
llvm-svn: 69480
2009-04-18 21:55:17 +00:00
Chris Lattner 397ca4a9ef fix typo
llvm-svn: 69479
2009-04-18 21:55:02 +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
Anders Carlsson 623dcae172 Use EmitCallArgs in EmitObjCMessageExpr.
llvm-svn: 69471
2009-04-18 20:29:27 +00:00
Anders Carlsson 603d6aff8b Make CodeGenFunction::EmitCallArgs a template function that takes a generic "Type Info" parameter. The type info parameter knows how to iterate over its arguments.
llvm-svn: 69469
2009-04-18 20:20:22 +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 f95894c1d2 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.

llvm-svn: 69464
2009-04-18 20:05:34 +00:00
Chris Lattner 3318e86541 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.

llvm-svn: 69463
2009-04-18 20:01:55 +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 ca4dc2e1ea 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.

llvm-svn: 69459
2009-04-18 19:30:02 +00:00
Chris Lattner 61639745b6 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.

llvm-svn: 69458
2009-04-18 19:11:11 +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 13d190ffbc Don't emit name-lookup tables for functions or methods in the PCH files
llvm-svn: 69449
2009-04-18 15:49:20 +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
Daniel Dunbar 508a7dda4a Fix a bug found by inspection, class/meta references could be emitted
into the wrong section (they shared the same lookup table).

llvm-svn: 69433
2009-04-18 08:51:00 +00:00
Chris Lattner 7a845306aa don't evaluate ->child_end() every time through the loop, or *i frequently within it.
llvm-svn: 69431
2009-04-18 07:53:55 +00:00
Chris Lattner 9512c2fb77 split code out into a new CheckFunctionJumpScopes routine,
add some comments, change type from void* -> Stmt*, use
smallvector instead of vector.

llvm-svn: 69430
2009-04-18 07:47:21 +00:00
Chris Lattner 40cc0044e7 make scope checking be static functions instead of sema methods.
llvm-svn: 69429
2009-04-18 07:36:39 +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 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 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 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 111af7d7b4 Preliminary PCH support in the driver
llvm-svn: 69410
2009-04-18 00:34:01 +00:00
Douglas Gregor 3c3aa61758 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.

llvm-svn: 69407
2009-04-18 00:07:54 +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
Douglas Gregor 08f0129003 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.

llvm-svn: 69393
2009-04-17 22:13:46 +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
Devang Patel 12f0dea922 Use PresumedLoc to record line number in debug info entries.
llvm-svn: 69389
2009-04-17 21:35:15 +00:00
Daniel Dunbar 66b13dac0a Don't put msgrefs in used globals (in particular, we don't want
no-dead-strip set on them).

llvm-svn: 69388
2009-04-17 21:10:58 +00:00
Devang Patel 75009454e3 Appropriately set file name and directory name in debug info compile units.
llvm-svn: 69387
2009-04-17 21:06:59 +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
Chris Lattner 25ef69a36e refactor htmldiags to be created up front like the other diag clients.
llvm-svn: 69379
2009-04-17 20:40:01 +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
Douglas Gregor af97671954 PCH support for GNU statement expressions
llvm-svn: 69370
2009-04-17 19:05:30 +00:00
Douglas Gregor 779d865b48 PCH support for indirect gotos and address-of-label expressions.
llvm-svn: 69369
2009-04-17 18:58:21 +00:00
Douglas Gregor 6cc68a47b5 PCH support for labels and goto.
llvm-svn: 69364
2009-04-17 18:18:49 +00:00
Chris Lattner ff8a9e6ee4 fix misspelt attribute.
llvm-svn: 69362
2009-04-17 17:55:23 +00:00
Chris Lattner 10dae30049 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.

llvm-svn: 69361
2009-04-17 17:46:19 +00:00
Chris Lattner c4688d21f7 tidy some code.
llvm-svn: 69360
2009-04-17 17:44:48 +00:00
Douglas Gregor 915b6c663d PCH support for declaration statements, and a test for PredefinedExpr
llvm-svn: 69356
2009-04-17 16:55:36 +00:00
Douglas Gregor f961e5921f PCH support for return statements.
Optimize PCH encoding for switch-case statements slightly, by making
the switch-case numbering local to a particular statement.

llvm-svn: 69355
2009-04-17 16:34:57 +00:00
Sebastian Redl 5775af1afd Implement lvalue test for conditional expressions.
Add a few commented lines to the test case that point out things that don't work yet.

llvm-svn: 69354
2009-04-17 16:30:52 +00:00
Fariborz Jahanian 493d4e080d Added -print-ivar-layout option. No change in functionality
yet.

llvm-svn: 69346
2009-04-17 03:04:15 +00:00
Anders Carlsson 6dc3575220 Add support for the __has_trivial_destructor type trait.
llvm-svn: 69345
2009-04-17 02:34:54 +00:00
Anders Carlsson eaa28f7e18 Add support for generating (very basic) C++ destructors. These aren't called by anything yet.
llvm-svn: 69343
2009-04-17 01:58:57 +00:00
Daniel Dunbar c3e7cff6d3 Attributes on block functions were not being set.
- <rdar://problem/6800351> clang not producing correct large struct
   return code for Blocks

llvm-svn: 69337
2009-04-17 00:48:04 +00:00
Douglas Gregor 71517c47e6 PCH support for do-while and for loops
llvm-svn: 69334
2009-04-17 00:29:51 +00:00
Douglas Gregor e24cbc0f4b PCH support for while and continue statements
llvm-svn: 69332
2009-04-17 00:16:09 +00:00
Mike Stump 5c3285b6fb Fixup semantic analysis for nested blocks, and allow block literal
expressions that can be of static duration to be returned.
Radar 6786551

llvm-svn: 69331
2009-04-17 00:09:41 +00:00
Anders Carlsson b7f8f594f3 Implement basic code generation of constructor calls. We can now compile:
struct S {
S(int, int);
};

void f() {
S s(10, 10);
}

llvm-svn: 69330
2009-04-17 00:06:03 +00:00
Douglas Gregor a9af1d13da PCH support for the first batch of statements, including null,
compound, case, default, if, switch, and break statements.

llvm-svn: 69329
2009-04-17 00:04:06 +00:00
Anders Carlsson e8eeffdf16 Add GetAddrOfCXXConstructor and use it.
llvm-svn: 69328
2009-04-16 23:57:24 +00:00
Anders Carlsson e6840d84df If a class has a non-trivial constructor that doesn't take any arguments, we will now make an implicit CXXTemporaryObjectExpr. So
struct S {
  S();
};

void f() {
 S s;
}

's' here will implicitly be declared as.

S s = S();

llvm-svn: 69326
2009-04-16 23:50:50 +00:00
Daniel Dunbar f2df7c283f Driver: Allow using clang as a precompiler, even if it is an
unsupported arch.

llvm-svn: 69322
2009-04-16 23:10:13 +00:00
Douglas Gregor 573b92468e Clean up the declaration-decoding step in the PCH reader, using the
same ueber-easy visitor scheme used for expressions/statements.

llvm-svn: 69320
2009-04-16 22:29:51 +00:00
Douglas Gregor 8f45df58b3 Prepare PCH reader and writer for (de-)serialization of statements. No
functionality change.

llvm-svn: 69319
2009-04-16 22:23:12 +00:00
Fariborz Jahanian 68c4c61be8 Removed a no longer needed FIXME comment.
llvm-svn: 69315
2009-04-16 21:49:16 +00:00
Steve Naroff a0c32704e2 Fix <rdar://problem/6765383> clang-6: clang does not appear to support declaring a static Block 'const'.
llvm-svn: 69306
2009-04-16 19:02:57 +00:00
Fariborz Jahanian bcf548760e Category method synbols must be qualified by gategory name to
match gcc's.

llvm-svn: 69305
2009-04-16 18:34:20 +00:00
Sebastian Redl 1a99f441e6 Fix a crash bug when comparing overload quality of conversion operators with conversion constructors.
Remove an atrocious amount of trailing whitespace in the overloaded operator mangler. Sorry, couldn't help myself.
Change the DeclType parameter of Sema::CheckReferenceInit to be passed by value instead of reference. It wasn't changed anywhere.
Let the parser handle C++'s irregular grammar around assignment-expression and conditional-expression.
And finally, the reason for all this stuff: implement C++ semantics for the conditional operator. The implementation is complete except for determining lvalueness.

llvm-svn: 69299
2009-04-16 17:51:27 +00:00
Eli Friedman 8d25b096fa Attempt to fix a read-after-free running test/Sema/designated-initializers.c.
Douglas, can you check that this is doing the right thing?

llvm-svn: 69298
2009-04-16 17:49:48 +00:00
Anders Carlsson 8798bd1bf9 When we create an implicit CXXTemporaryObjectExpr we don't need to check that it's a valid init. Instead, just set it as the VarDecl's initializer.
llvm-svn: 69292
2009-04-16 15:50:16 +00:00
Daniel Dunbar 426b5cf16a Ensure that the most recent declaration of a tentative definition wins
when generating a common definition.

llvm-svn: 69287
2009-04-16 15:34:14 +00:00
Daniel Dunbar 092f0ccd9c Pass -fdiagnostics-show-option to clang-cc by default.
- <rdar://problem/6796848> implement -fdiagnostics-show-option

llvm-svn: 69276
2009-04-16 06:32:38 +00:00
Chris Lattner 2d49eed816 optimize and comment GetDiagInfo.
llvm-svn: 69273
2009-04-16 06:13:46 +00:00
Chris Lattner 6c440329f1 merge several scattered tables into StaticDiagInfo.
llvm-svn: 69272
2009-04-16 06:07:15 +00:00
Chris Lattner 6a64cc6776 Implement Diagnostic::getWarningOptionForDiag with information from tblgen,
this implements -fdiagnostics-show-option in clang-cc.

llvm-svn: 69271
2009-04-16 06:00:24 +00:00
Chris Lattner a538967177 tblgen is now passing diagnostic group information in the .inc file, ignore it everywhere.
llvm-svn: 69269
2009-04-16 05:52:14 +00:00
Chris Lattner 22cb818913 implement framework for -fdiagnostics-show-option, but tblgen isn't
passing down the right info yet.

llvm-svn: 69268
2009-04-16 05:44:38 +00:00
Anders Carlsson 805ab5a746 Disable the code I added before until I understand what's causing default2.cpp to fail.
llvm-svn: 69267
2009-04-16 05:35:41 +00:00
Chris Lattner b8e73158e1 move handling of -pedantic and -pedantic-errors into Diagnostics,
out of Warnings.cpp.  This simplifies warnings.cpp and makes it more
efficient.

llvm-svn: 69266
2009-04-16 05:04:32 +00:00
Chris Lattner f9150bac01 arrange for -Wno-error=foo warnings to be immune to -Werror as
they are supposed to be.

llvm-svn: 69265
2009-04-16 04:32:54 +00:00
Chris Lattner 411c0ffe5d change mappings to distinguish between "unset", "set by the user" and
"set to the default value".

llvm-svn: 69264
2009-04-16 04:12:40 +00:00
Chris Lattner af73cf6363 use getDiagnosticLevel instead of getDiagnosticMapping, which
is about to become private.

llvm-svn: 69262
2009-04-16 03:59:32 +00:00
Daniel Dunbar b4b3709c5b Driver: Forward -W* to clang, it can handle all these itself now.
Remove clang_W_Group and clang_ignored_W_Group.

llvm-svn: 69261
2009-04-16 03:44:10 +00:00
Douglas Gregor 6d955a9d25 Eliminate pch::TYPE_ATTR, which is never used
llvm-svn: 69256
2009-04-16 02:45:14 +00:00
Douglas Gregor 4c5cd33527 PCH support for CompoundLiteralExpr. This is the last C expression
that does not require PCH support for statements. Only AddrLabelExpr,
StmtExpr, and BlockExpr remain (for C).

llvm-svn: 69255
2009-04-16 02:33:48 +00:00
Douglas Gregor 38676d50dc PCH support for InitListExpr, DesignatedInitExpr, and ImplicitValueInitExpr.
llvm-svn: 69251
2009-04-16 00:55:48 +00:00
Anders Carlsson fe63dc52f9 Add support for the __has_trivial_constructor type trait.
llvm-svn: 69245
2009-04-16 00:08:20 +00:00
Douglas Gregor a3c5590ec2 PCH support for ShuffleVectorExpr and BlockDeclRefExpr
llvm-svn: 69244
2009-04-16 00:01:45 +00:00