Commit Graph

2863 Commits

Author SHA1 Message Date
Chris Lattner e9dba48684 fix a broken test, that passed for the wrong reason. Two wrongs make a right! :)
llvm-svn: 69155
2009-04-15 07:02:57 +00:00
Chris Lattner e007de3b9a Rejigger how -pedantic and -pedantic-errors work and their interaction
with other diagnostic mapping.  In the new scheme, -Wfoo or -Wno-foo or 
-Werror=foo all override the -pedantic options, and __extension__ 
robustly silences all extension diagnostics in their scope.

An added bonus of this change is that MAP_DEFAULT goes away, meaning that
per-diagnostic mapping information can now be stored in 2 bits, doubling
the density of the Diagnostic::DiagMapping array.  This also 
substantially simplifies Diagnostic::getDiagnosticLevel.

OTOH, this temporarily introduces some "macro intensive" code in 
Diagnostic.cpp.  This will be addressed in a later patch.

llvm-svn: 69154
2009-04-15 07:01:18 +00:00
Douglas Gregor d5846a1eb5 Implement support for designated initializers that refer to members of
anonymous structs or unions. Fixes PR3778.

llvm-svn: 69153
2009-04-15 06:41:24 +00:00
Chris Lattner e94e13ca35 remove #include of system header, making this a) not apple specific, and
b) test dramatically faster.

llvm-svn: 69135
2009-04-15 04:26:10 +00:00
Daniel Dunbar b25452a98e Tweaks to Objective-C metadata (32 & 64-bit) to match llvm-gcc.
- Set alignment on property lists.
 - 32-bit:
   o Set section on property lists.
   o Fix section name for category class methods.
   o Fix symbol name for property lists.
   o Fix section name for class method.
   o Set alignment and section on class extension structure.
   o Set alignment on a number of things: instance variables, methods,
   method descriptions, the symbols structure.
 - 64-bit:
   o Fix section flags for protocol list.

I doubt most of these were problems in practice, but it is nice to
match llvm-gcc.

llvm-svn: 69132
2009-04-15 02:56:18 +00:00
Douglas Gregor 67fdb085b9 PCH support for CStyleCastExpr and BinaryOperator expression kinds.
llvm-svn: 69119
2009-04-15 00:25:59 +00:00
Daniel Dunbar c2223ab255 Improve "assignment to cast" diagnostic.
- Strip off extra parens when looking for casts.
 - Change the location info to point at the cast (instead of the
   assignment).

For example, on
  
  int *b;
  #define a ((void*) b)
  void f0() {
    a = 10;
  }
  
we now emit:
  
  /tmp/t.c:4:3: error: assignment to cast is illegal, lvalue casts are not supported
    a = 10;
    ^ ~
  /tmp/t.c:2:12: note: instantiated from:
  #define a ((void*) b)
            ~^~~~~~~~~~
  
instead of:
  
  /tmp/t.c:4:5: error: expression is not assignable
    a = 10;
    ~ ^

llvm-svn: 69114
2009-04-15 00:08:05 +00:00
Douglas Gregor 954a830eca PCH support for ParenExpr
llvm-svn: 69106
2009-04-14 23:59:37 +00:00
Douglas Gregor f0b575f79d Add PCH support for ImplicitCastExprs. This is the first expression
kind PCH handles that has an expression as an operand, so most of this
work is in the infrastructure to rebuild expression trees from the
serialized representation. We now store expressions in post-order
(e.g., Reverse Polish Notation), so that we can easily rebuild the
appropriate expression tree.

llvm-svn: 69101
2009-04-14 23:32:43 +00:00
Daniel Dunbar 9351c02bef Strip paren expressions when trying to diagnose "cast as lvalue"
extension.

llvm-svn: 69100
2009-04-14 23:26:44 +00:00
Fariborz Jahanian 6c6aea914a Diagnose properties which have no implementations;
either unimplemented setter/getter or no
implementation directive.

llvm-svn: 69098
2009-04-14 23:15:21 +00:00
Daniel Dunbar 3241fae46c Set alignment on __cstring metadata variables to 1 (matching
llvm-gcc).

llvm-svn: 69097
2009-04-14 23:14:47 +00:00
Chris Lattner b4a8fe8dcc Make the implicit-int handling error recovery stuff handle C++
nested name specifiers.  Now we emit stuff like:

t.cpp:8:13: error: unknown type name 'X'
static foo::X  P;
       ~~~~ ^

instead of:

t.cpp:8:16: error: invalid token after top level declarator
static foo::X  P;
               ^

This is inspired by a really awful error message I got from 
g++ when I misspelt diag::kind as diag::Kind.

llvm-svn: 69086
2009-04-14 22:17:06 +00:00
Douglas Gregor e0a3a51637 Add PCH support for PredefinedExpr and FloatingLiteral expressions
llvm-svn: 69084
2009-04-14 21:55:33 +00:00
Douglas Gregor feb84b0074 PCH support for a few very, very simple kinds of expressions. Hook up
expression (de-)serialization for VLAs, variable initializers,
enum constant initializers, and bitfield widths.

llvm-svn: 69075
2009-04-14 21:18:50 +00:00
Chris Lattner a723ba97db Fix a regression in a previous patch that broke implicit
int in a bitfield.  Shantonu found this in a gcc testsuite file.

llvm-svn: 69074
2009-04-14 21:16:09 +00:00
Steve Naroff 5196c618fb Fix <rdar://problem/6252084> [sema] jumps into Obj-C exception blocks should be disallowed.
This builds on Eli's work from http://llvm.org/viewvc/llvm-project?view=rev&revision=65678.

llvm-svn: 69073
2009-04-14 20:53:38 +00:00
Chris Lattner bae0e68930 Fix PR3988: extern inline functions get strong symbol definitions in
C99 mode.  This is a regression from an earlier patch of mine.

This also simplifies the linkage enums a bit.

llvm-svn: 69069
2009-04-14 20:25:53 +00:00
Douglas Gregor db908332e3 Add a tricky, tricky test case for PCH that we currently don't handle. Committed with a FIXME so that we don't forget it
llvm-svn: 69052
2009-04-14 17:10:28 +00:00
Chris Lattner 4225e23e62 implement some sema for gnuc_inline attribute. Reject always_inline and no_inline on objc methods.
llvm-svn: 69051
2009-04-14 17:02:11 +00:00
Chris Lattner 02e987f3e8 implement codegen support for __attribute((__gnuc_inline__)),
pulling some attribute munging stuff into GetLinkageForFunction.

This should fix PR3986

llvm-svn: 69045
2009-04-14 16:44:36 +00:00
Douglas Gregor 54feb84489 When building a PCH file, don't perform end-of-translation-unit
wrap-up (e.g., turning tentative definitions into definitions). Also,
very that, when we actually use the PCH file, we get the ride code
generation for tentative definitions and definitions that show up in
the PCH file.

llvm-svn: 69043
2009-04-14 16:27:31 +00:00
Steve Naroff 06f440dd7b ASTContext::mergeTypes(): Loosen up the type checking for 'Class' (treating it like 'id').
This fixes <rdar://problem/6782722> XCDataTipsManager.m registers, observes notifications in class methods.

The radar above is the result of clang typing 'self' in a class method as 'Class', which results in some spurious warnings (GCC types 'self' in a class method as 'id').

I considered changing the type of 'self' to 'id' (to conform to GCC), however this resulted in *many* test cases breaking. In addition, I really prefer a more strongly typed 'self'.

All in all, this is the least obtrusive fix I could find for removing the spurious warnings (though we do loose some valid warnings).

llvm-svn: 69041
2009-04-14 15:11:46 +00:00
Chris Lattner 92028dad66 defer emission of always_inline, extern_inline, and inline functions (when
not in c89 mode).

llvm-svn: 69032
2009-04-14 06:44:48 +00:00
Chris Lattner 256c9507c8 set the linkage of an inline function according to its language rules.
llvm-svn: 69030
2009-04-14 06:27:57 +00:00
Daniel Dunbar 0ca1660129 Audit __private_extern__ handling.
- Exposed quite a few Sema issues and a CodeGen crash.

 - See FIXMEs in test case, and in SemaDecl.cpp (PR3983).

I'm skeptical that __private_extern__ should actually be a storage
class value. I think that __private_extern__ basically amounts to
  extern A __attribute__((visibility("hidden")))
and would be better off handled (a) as that, or (b) with an extra bit
in the VarDecl.

llvm-svn: 69020
2009-04-14 02:25:56 +00:00
Mike Stump ca5ae66122 Fixup CodeGen for __weak __block variables. Radar 6756266
llvm-svn: 69010
2009-04-14 00:57:29 +00:00
Douglas Gregor 1a0d0b9acc When writing a PCH file, keep track of all of the non-static,
non-inline external definitions (and tentative definitions) that are
found at the top level. The corresponding declarations are stored in a
record in the PCH file, so that they can be provided to the
ASTConsumer (via HandleTopLevelDecl) when the PCH file is read.

llvm-svn: 69005
2009-04-14 00:24:19 +00:00
Steve Naroff e4e55d2706 Fix crasher in ASTContext::getObjCEncodingForMethodDecl().
This was exposed as a result of something else that was recently fixed.

llvm-svn: 69004
2009-04-14 00:03:58 +00:00
Douglas Gregor 92f056fadf PCH support for functions and their parameters.
llvm-svn: 68997
2009-04-13 22:18:37 +00:00
Eli Friedman 337cd3a536 PR3461: reject initializer for incomplete type. Based on patch by Tim
Northover.

llvm-svn: 68991
2009-04-13 21:28:54 +00:00
Douglas Gregor 183671e2d2 PCH support for record decls/types and their fields. Now that we can
handle the definition of __builtin_va_list on x86-64, eliminate the
forced -triple in PCH tests to get better coverage.

llvm-svn: 68988
2009-04-13 21:20:57 +00:00
Douglas Gregor 85c0fcd66d Introduce PCH (de-)serialization for most compound types, excluding
Objective-C types and record types for the moment.

llvm-svn: 68984
2009-04-13 20:46:52 +00:00
Fariborz Jahanian b6d5b54839 In objc2's None-Fragile ABI, one cannot use the super class ivar for
setter/getter synthesis.

llvm-svn: 68976
2009-04-13 19:30:37 +00:00
Steve Naroff 84073ec51f Fixed crasher in <rdar://problem/6780904> [irgen] Assertion failed: (Result == conversionOK && "UTF-8 to UTF-16 conversion failed"), function GetAddrOfConstantCFString, file CodeGenModule.cpp, line 1063.
Still a diagnostic related FIXME (will discuss with Daniel/Fariborz offline).

llvm-svn: 68975
2009-04-13 19:08:08 +00:00
Douglas Gregor 1daeb69f95 Add PCH support for enumerations and enumerators.
llvm-svn: 68974
2009-04-13 18:14:40 +00:00
Anders Carlsson 1235bbce7e Use the new guard variable mangling function and get rid of the old code.
llvm-svn: 68971
2009-04-13 18:03:33 +00:00
Steve Naroff 42959b2660 Change diagnostic as a result of researching <rdar://problem/6779809> missing interface name in "error: cannot declare variable inside a class, protocol or category ''.
Since ObjC 2.0 class "extensions" have a null name, the diagnostic above is actually "correct". Nevertheless, it is confusing. Decided to remove the name entirely (from my perspective, it didn't add any value). Also simplified the text of the diagnostic a bit.

llvm-svn: 68967
2009-04-13 17:58:46 +00:00
Douglas Gregor 4c7626e7b6 Include the SourceManager's line table in the PCH file. We can now
properly cope with #line directives in PCH files.

llvm-svn: 68963
2009-04-13 16:31:14 +00:00
Douglas Gregor 712a351c42 Make the selection of type declarations in Sema::getTypeName
deterministic when faced with an ambiguity. This eliminates the
annoying test/SemaCXX/using-directive.cpp failure.

llvm-svn: 68952
2009-04-13 15:14:38 +00:00
Chris Lattner 5c6160d019 fix rdar://6774906, a crash handling implicit conversions between pointers
in different address spaces.

llvm-svn: 68941
2009-04-13 06:04:39 +00:00
Chris Lattner 0af3ba1748 implement the microsoft/gnu "__COUNTER__" macro: rdar://4329310
llvm-svn: 68933
2009-04-13 01:29:17 +00:00
Chris Lattner 0d6c061401 Improve error recovery for calls, fixing:
PR3972: Poor diagnostic with missing ')'

llvm-svn: 68932
2009-04-13 00:10:38 +00:00
Chris Lattner bc670459ad fix PR3932: [ObjC]Type defined as 'id' is not recognized as a valid object type.
by making ASTContext::isObjCObjectPointerType accept typedefs of id.

llvm-svn: 68931
2009-04-12 23:51:02 +00:00
Chris Lattner 1e2f763c4c rename test
llvm-svn: 68930
2009-04-12 23:49:38 +00:00
Chris Lattner bdccb0393c add some more coverage.
llvm-svn: 68928
2009-04-12 23:29:27 +00:00
Chris Lattner e1b4174a9a clean up test.
llvm-svn: 68927
2009-04-12 23:27:53 +00:00
Chris Lattner 0177518897 rename test
llvm-svn: 68926
2009-04-12 23:27:31 +00:00
Chris Lattner a2ca03a908 if we already know that a decl is invalid in an @catch, don't verify its type.
llvm-svn: 68925
2009-04-12 23:26:56 +00:00
Chris Lattner 869c6610c7 Fix some C++ error recovery problems in init declarator parsing
that I noticed working on other things.

Instead of emitting:

t2.cc:1:8: error: use of undeclared identifier 'g'
int x(*g);
       ^
t2.cc:1:10: error: expected ')'
int x(*g);
         ^
t2.cc:1:6: note: to match this '('
int x(*g);
     ^

We now only emit:

t2.cc:1:7: warning: type specifier missing, defaults to 'int'
int x(*g);
      ^


Note that the example in SemaCXX/nested-name-spec.cpp:f4 is still
not great, we now produce both of:

void f4(undef::C); // expected-error {{use of undeclared identifier 'undef'}} \
                      expected-error {{variable has incomplete type 'void'}}

The second diagnostic should be silenced by something getting marked invalid.
I don't plan to fix this though.

llvm-svn: 68919
2009-04-12 22:23:27 +00:00
Chris Lattner 090d34c692 fix another case that assumed that GetTypeForDeclarator would never return null.
llvm-svn: 68918
2009-04-12 22:15:02 +00:00
Chris Lattner 67b0d6afaa mark the declspec as invalid when we recover instead of forcing to int,
this allows downstream diags to be properly silenced.

llvm-svn: 68917
2009-04-12 22:12:26 +00:00
Chris Lattner ffaa0e6919 Diagnose invalid uses of tagged types with a missing tag. For example, in:
struct xyz { int y; };
enum abc { ZZZ };

static xyz b;
abc c;

we used to produce:

t2.c:4:8: error: unknown type name 'xyz'
static xyz b;
       ^
t2.c:5:1: error: unknown type name 'abc'
abc c;
^

we now produce:

t2.c:4:8: error: use of tagged type 'xyz' without 'struct' tag
static xyz b;
       ^
       struct
t2.c:5:1: error: use of tagged type 'abc' without 'enum' tag
abc c;
^
enum

GCC produces the normal:
t2.c:4: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘b’
t2.c:5: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘c’

rdar://6783347

llvm-svn: 68914
2009-04-12 21:49:30 +00:00
Chris Lattner 14bdb78430 fix a valgrind problem I noticed while developing another patch,
if a decl is invalid, it isn't added to the Decls array, so we
need to pass in Decls.size() to avoid reading uninit memory.

llvm-svn: 68913
2009-04-12 20:51:10 +00:00
Chris Lattner 6cc055af1d Implement the first set of changes for PR3963 and rdar://6759604,
which tries to do better error recovery when it is "obvious" that an
identifier is a mis-typed typename.  In this case, we try to parse
it as a typename instead of as the identifier in a declarator, which
gives us several options for better error recovery and immediately
makes diagnostics more useful.  For example, we now produce:

t.c:4:8: error: unknown type name 'foo_t'
static foo_t a = 4;
       ^

instead of:

t.c:4:14: error: invalid token after top level declarator
static foo_t a = 4;
             ^

Also, since we now parse "a" correctly, we make a decl for it,
preventing later uses of 'a' from emitting things like:

t.c:12:20: error: use of undeclared identifier 'a'
int bar() { return a + b; }
                   ^

I'd really appreciate any scrutiny possible on this, it 
is a tricky area.

llvm-svn: 68911
2009-04-12 20:42:31 +00:00
Fariborz Jahanian 8e23171fbc OS dependent code removed.
llvm-svn: 68904
2009-04-12 17:43:53 +00:00
Sebastian Redl d1309a3c4d Add deleted functions and rvalue references to C++ status.
llvm-svn: 68903
2009-04-12 17:41:24 +00:00
Sebastian Redl 42e92c4bc3 Parse deleted member functions. Parsing member declarations goes through a different code path that I forgot previously.
Implement the rvalue reference overload dance for returning local objects. Returning a local object first tries to find a move constructor now.
The error message when no move constructor is defined (or is not applicable) and the copy constructor is deleted is quite ugly, though.

llvm-svn: 68902
2009-04-12 17:16:29 +00:00
Chris Lattner fa6059ff2f rename test
llvm-svn: 68900
2009-04-12 09:04:18 +00:00
Chris Lattner 0d5640c7be Fix rdar://6770142 - Class and qualified id's are compatible, just like
Class and unqualified id's are.

llvm-svn: 68899
2009-04-12 09:02:39 +00:00
Chris Lattner baa405fc4c rename test
llvm-svn: 68898
2009-04-12 08:47:09 +00:00
Chris Lattner 98b30412ab merge protocol-test-1.m -> protocol-test-2.m
llvm-svn: 68897
2009-04-12 08:46:44 +00:00
Chris Lattner 7a9c6d2973 Merge forward-circular into protocol-test-2
llvm-svn: 68896
2009-04-12 08:45:55 +00:00
Chris Lattner 10644fac2f this test is subsumed by protocol-test-2.m
llvm-svn: 68895
2009-04-12 08:44:47 +00:00
Chris Lattner dac168d2a6 Fix rdar://6771034: don't warn on use of forward declared protocol in protocol
list of another protocol definition.  This warning is very noisy and GCC doesn't
produce it so existing code doesn't expect it.

llvm-svn: 68894
2009-04-12 08:43:13 +00:00
Chris Lattner 1c7b885f5f fix typo in test name.
llvm-svn: 68893
2009-04-12 08:37:16 +00:00
Chris Lattner 261b6a5c3a call objc interfaces just "interfaces" in diagnostics, not "Objective-C types"
or "Objective-C interface types" etc.

llvm-svn: 68892
2009-04-12 08:25:48 +00:00
Chris Lattner a8a7d0f371 implement rdar://6780761, making sema reject some code that otherwise
crashes codegen.

llvm-svn: 68891
2009-04-12 08:11:20 +00:00
Chris Lattner cac63f359e Implement support for GCC's -dD mode, which dumps -E output *and*
macro definitions.

llvm-svn: 68884
2009-04-12 01:56:53 +00:00
Chris Lattner c523d8e88c now that we have an identifier table in the PCH file, finish hooking up
macro deserialization.  We now correctly install II's in tokens, handle
function-like macros, etc.

llvm-svn: 68882
2009-04-11 21:15:38 +00:00
Chris Lattner 28d198177f test this in non-pch mode as well as in pch mode.
llvm-svn: 68881
2009-04-11 20:52:19 +00:00
Chris Lattner 67f35b051b improve the 'conflicting types' diagnostics to include correct location info, now
that it is plumbed through Sema.  On a file from growl, we used to emit:

t.mi:107059:1: warning: conflicting types for 'removePluginHandler:forPluginTypes:'
- (void) removePluginHandler:(id <GrowlPluginHandler>)handler forPluginTypes:(NSSet *)extensions {
^
t.mi:105280:1: note: previous definition is here
- (void) removePluginHandler:(id <NSObject>)handler forPluginTypes:(NSSet *)types;
^

now we produce:

t.mi:107059:55: warning: conflicting parameter types in implementation of 'removePluginHandler:forPluginTypes:': 'id<NSObject>' vs 'id<GrowlPluginHandler>'
- (void) removePluginHandler:(id <GrowlPluginHandler>)handler forPluginTypes:(NSSet *)extensions {
                                                      ^
t.mi:105280:45: note: previous definition is here
- (void) removePluginHandler:(id <NSObject>)handler forPluginTypes:(NSSet *)types;
                                            ^

We still don't have proper loc info for properties, hence the FIXME.

rdar://6782494

llvm-svn: 68879
2009-04-11 19:58:42 +00:00
Chris Lattner 03a6cbbd91 pass -fblocks
llvm-svn: 68878
2009-04-11 19:49:49 +00:00
Chris Lattner 6de05080e4 fix blocks to reject objc interfaces returned by value. Also,
a block without a prototype should still coerce a return in it to
use the declared return type.

llvm-svn: 68875
2009-04-11 19:27:54 +00:00
Chris Lattner 80718823ae fix test
llvm-svn: 68874
2009-04-11 19:18:22 +00:00
Chris Lattner 347eec9d84 diagnose attempts to return objc interfaces by-value from C functions.
llvm-svn: 68873
2009-04-11 19:17:25 +00:00
Chris Lattner de5a531677 Improve the 'cannot pass objc interface by value' diagnostic:
1) improve localizability by not passing english strings in.
2) improve location for arguments.
3) print the objc type being passed.

Before:
method-bad-param.m:15:1: error: Objective-C type cannot be passed by value
-(void) my_method:(foo) my_param
^

after:
method-bad-param.m:15:25: error: Objective-C interface type 'foo' cannot be passed by value
-(void) my_method:(foo) my_param
                        ^

llvm-svn: 68872
2009-04-11 19:08:56 +00:00
Fariborz Jahanian aae4349df9 Fixes a ir-gen crash for K&R style blocks.
llvm-svn: 68865
2009-04-11 17:55:15 +00:00
Chris Lattner 9edfeed6b8 add radar number
llvm-svn: 68864
2009-04-11 17:26:58 +00:00
Anders Carlsson d8e39bbb84 Add support for generating reference initialization code.
llvm-svn: 68852
2009-04-11 01:08:03 +00:00
Ted Kremenek 4531be138c Add analyzer support for objc_atomicCompareAndSwap()
llvm-svn: 68849
2009-04-11 00:54:13 +00:00
Ted Kremenek df24000d24 Implement analyzer support for OSCompareAndSwap. This required pushing "tagged"
ProgramPoints all the way through to GRCoreEngine.

NSString.m now fails with RegionStoreManager because of the void** cast.
Disabling use of region store for that test for now.

llvm-svn: 68845
2009-04-11 00:11:10 +00:00
Fariborz Jahanian d381cde486 Non-pointer objects are none gc'able regardles of
the attribute set on them.

llvm-svn: 68844
2009-04-11 00:00:54 +00:00
Mike Stump d352fd3699 Fixup copy/dispose helpers for Objective-C. Radar 6756504
llvm-svn: 68837
2009-04-10 23:09:55 +00:00
Daniel Dunbar 5acb3a28e2 Force driver triple.
llvm-svn: 68836
2009-04-10 22:53:25 +00:00
Fariborz Jahanian 60331be08d Fix another fallout from defining __weak unconditionally.
llvm-svn: 68834
2009-04-10 22:42:54 +00:00
Daniel Dunbar 8c920c9220 Don't set both readnone and readonly.
llvm-svn: 68833
2009-04-10 22:14:52 +00:00
Chris Lattner d959d753bc do a dance with predefines, and finally enable reading of macros from
PCH.  This works now, except for limitations not being able to do things
with identifiers.  The basic example in the testcase works though.

llvm-svn: 68832
2009-04-10 22:13:17 +00:00
Fariborz Jahanian e49adaf7f2 Fixed the test.
llvm-svn: 68831
2009-04-10 22:09:52 +00:00
Fariborz Jahanian 5240a49f04 Add a test case for my last patch.
llvm-svn: 68829
2009-04-10 21:43:13 +00:00
Daniel Dunbar 670af594d8 Force triple for a number of tests that rely on __weak.
llvm-svn: 68826
2009-04-10 21:23:20 +00:00
Daniel Dunbar b5023e90f4 Honor MACOSX_DEPLOYMENT_TARGET environment variable.
llvm-svn: 68822
2009-04-10 21:00:07 +00:00
Daniel Dunbar d272cca527 Internal variables could mistakenly have "hidden" visibility when
their emission was deferred.
 - <rdar://problem/6775234> variables with internal linkage should not
   be exposed with -fvisibility=hidden.

llvm-svn: 68818
2009-04-10 20:26:50 +00:00
Daniel Dunbar de46660cda Test case for -miphoneos-version-min, also part of Shantonu's patch!
llvm-svn: 68817
2009-04-10 20:13:51 +00:00
Mike Stump 6764593098 Fixup codegen for nested blocks that use copy/dispose in the inner
blocks, so that the outer blocks use it as well.  Radar 6762279

llvm-svn: 68811
2009-04-10 18:52:28 +00:00
Fariborz Jahanian 464423dce4 Patch to generate meta-data for prtocol used
in @protocol expression.

llvm-svn: 68806
2009-04-10 18:47:34 +00:00
Douglas Gregor 1e9bf3bad4 Various minor fixes to PCH reading and writing, with general
cleanup. Aside from a minor tweak to the PCH file format, no
functionality change. 

llvm-svn: 68793
2009-04-10 17:25:41 +00:00
Chris Lattner feeb8f1316 use doug's new %S thing to make this work when run from different locations.
llvm-svn: 68788
2009-04-10 16:51:32 +00:00
Ted Kremenek b3b2395520 Split failing test case from misc-ps.m to misc-ps-ranges.m (which tests
functionality specific to RangeConstraintManager).

llvm-svn: 68759
2009-04-10 04:02:38 +00:00
Douglas Gregor a7f71a91c5 PCH serialization/deserialization of the source manager. With this
improvement, source locations read from the PCH file will properly
resolve to the source files that were used to build the PCH file
itself.

Once we have the preprocessor state stored in the PCH file, source
locations that refer to macro instantiations that occur in the PCH
file should have the appropriate instantiation information.

llvm-svn: 68758
2009-04-10 03:52:48 +00:00
Ted Kremenek 5054663daa Fix: <rdar://problem/6776949> Branch condition evaluates to an uninitialized value (argc is guaranteed to be >= 1)
The analyzer now adds the precondition that the first argument of 'main' is > 0.

llvm-svn: 68757
2009-04-10 00:59:50 +00:00
Ted Kremenek 40f4ee74fd Implement attribute "analyzer_noreturn" (<rdar://problem/6777003>). This allows
clients of the analyzer to designate custom assertion routines as "noreturn"
functions from the analyzer's perspective but not the compiler's.

llvm-svn: 68746
2009-04-10 00:01:14 +00:00
Douglas Gregor ef84c4b434 Implementation of pre-compiled headers (PCH) based on lazy
de-serialization of abstract syntax trees.

PCH support serializes the contents of the abstract syntax tree (AST)
to a bitstream. When the PCH file is read, declarations are serialized
as-needed. For example, a declaration of a variable "x" will be
deserialized only when its VarDecl can be found by a client, e.g.,
based on name lookup for "x" or traversing the entire contents of the
owner of "x".

This commit provides the framework for serialization and (lazy)
deserialization, along with support for variable and typedef
declarations (along with several kinds of types). More
declarations/types, along with important auxiliary structures (source
manager, preprocessor, etc.), will follow.

llvm-svn: 68732
2009-04-09 22:27:44 +00:00
Anders Carlsson 39b2e130f0 Add @encode support for complex types.
llvm-svn: 68729
2009-04-09 21:55:45 +00:00
Daniel Dunbar b041085c17 Add more builtin definitions, including strcmp.
- PR3964.

llvm-svn: 68710
2009-04-09 16:42:50 +00:00
Ted Kremenek f9f9420303 GRExprEngine: Don't try to reason about the size of 'void' for the return type
of messages sent to nil.

llvm-svn: 68683
2009-04-09 05:45:56 +00:00
Daniel Dunbar d067f7fbef Driver: Split out CPP specific options for clang so that we don't end
up adding them twice when running with -no-integrated-cpp or
-save-temps.
 - <rdar://problem/6766636> -save-temps falls over with prefix headers

llvm-svn: 68660
2009-04-08 23:54:23 +00:00
Steve Naroff b47acdb2e5 Fix <rdar://problem/6770998> make cast of super illegal (again:-)
llvm-svn: 68659
2009-04-08 23:52:26 +00:00
Daniel Dunbar 6eaebd0934 Force triple for these tests.
llvm-svn: 68651
2009-04-08 23:02:51 +00:00
Chris Lattner e01d82b81f finish the implementation of -imacros. The driver still needs to be hooked up.
llvm-svn: 68640
2009-04-08 20:53:24 +00:00
Anders Carlsson 03a409feda We weren't generating correct code for calls to variadic member functions.
llvm-svn: 68635
2009-04-08 20:31:57 +00:00
Fariborz Jahanian fc58ca4af6 Fixed a problem using property syntax on a 'super'
used as receiver.

llvm-svn: 68631
2009-04-08 19:50:10 +00:00
Ted Kremenek 5451c60f5a Enhance analyzer reasoning about sending messages to nil. A nil receiver returns 0 for scalars of size <= sizeof(void*).
llvm-svn: 68629
2009-04-08 18:51:08 +00:00
Daniel Dunbar 17ddaa677e More fixes to builtin preprocessor defines.
- Add -static-define option driver can use when __STATIC__ should be
   defined (instead of __DYNAMIC__).

 - Don't set __OPTIMIZE_SIZE__ on Os, __OPTIMIZE_SIZE__ is tied to Oz.

 - Set __NO_INLINE__ following GCC 4.2.

 - Set __GNU_GNU_INLINE__ or __GNU_STDC_INLINE__ following GCC 4.2.

 - Set __EXCEPTIONS for Objective-C NonFragile ABI.

 - Set __STRICT_ANSI__ for standard conforming modes.

 - I added a clang style test case in utils for this, but its not
   particularly portable and I don't think it belongs in the test
   suite.

llvm-svn: 68621
2009-04-08 18:03:55 +00:00
Steve Naroff ea4c780da1 Sema::CheckConditionalOperands(): Soften pointer/integer mismatch from error->warning.
Fixes <rdar://problem/6762239> [sema] gcc incompatibility; error on incompatible operand types in ?:.

llvm-svn: 68617
2009-04-08 17:05:15 +00:00
Douglas Gregor b53c0c29c0 -Wmissing-prototypes shouldn't complain about main() missing a prototype.
Fixes <rdar://problem/6759522>

llvm-svn: 68611
2009-04-08 15:21:36 +00:00
Daniel Dunbar 8f28d01126 Implementation definition of interfaces with __objc_exception attribute.
- Complete <rdar://problem/6635883> Support __objc_exception__
   attribute

llvm-svn: 68591
2009-04-08 04:21:03 +00:00
Ted Kremenek 605fee8445 New static analyzer check by Nikita Zhuk!
"The attached patch generates warnings of cases where an ObjC message is sent to
a nil object and the size of return type of that message is larger than the size
of void pointer. This may result in undefined return values as described in PR
2718.  The patch also includes test cases."

llvm-svn: 68585
2009-04-08 03:07:17 +00:00
Daniel Dunbar ab7b2f5623 Set __PIC__ (more) correctly.
- Add -pic-level clang-cc option to specify the value for the define,
   updated driver to pass this.

 - Added __pic__

 - Added OBJC_ZEROCOST_EXCEPTIONS define while I was here (to match gcc).

llvm-svn: 68584
2009-04-08 03:03:23 +00:00
Anders Carlsson a60cbcdfe6 Don't assume that a block always has a FunctionProtoType. Fixes rdar://6768379.
llvm-svn: 68583
2009-04-08 02:55:55 +00:00
Daniel Dunbar d4510f2223 Driver: Fix forwarding of -fpascal-strings.
llvm-svn: 68570
2009-04-07 23:51:44 +00:00
Steve Naroff 65a0089eb7 Fix <rdar://problem/6764172> [sema] crash on invalid.
llvm-svn: 68568
2009-04-07 22:56:58 +00:00
Daniel Dunbar ea10ab668f Visibility attributes should only be set on definition.
llvm-svn: 68561
2009-04-07 22:36:33 +00:00
Daniel Dunbar c44b4ccca8 Driver: Fix forwarding of -{std,ansi,trigraphs} when there are
multiple instances of an option.

Also, removed direct -ansi support from clang-cc.

llvm-svn: 68558
2009-04-07 22:13:21 +00:00
Fariborz Jahanian 9ecb84bb21 Now that we have __weak defined as attribute in all modes,
we must not issue gc-specific errors in non-gc mode.

llvm-svn: 68551
2009-04-07 21:25:06 +00:00
Daniel Dunbar d18049ab1d Driver: Manually translate a number of -f with no- variants options to
clang.
 - We will eventually want some more driver infrastructre for this
   probably.

 - For now, the clang-cc interface stays relatively the same, but we
   don't accept multiple instances anymore, or the [no-] variants
   directly.

llvm-svn: 68550
2009-04-07 21:16:11 +00:00
Fariborz Jahanian 57eb2e021e Propagte -fvisibility to objc2's class symbols.
llvm-svn: 68543
2009-04-07 20:26:30 +00:00
Eli Friedman 574c745370 Diagnose uses of function specifiers on declarations which don't declare
functions.  Fixes PR3941.

llvm-svn: 68541
2009-04-07 19:37:57 +00:00
Fariborz Jahanian 69ba935743 Fixes method name lookup when method appears in
the base implementations (and not in
current implementation).

llvm-svn: 68527
2009-04-07 18:28:06 +00:00
Anders Carlsson e871d05e26 Fix broken test case. I have no idea why this ever worked.
llvm-svn: 68526
2009-04-07 18:21:53 +00:00
Daniel Dunbar b2a7c062aa Driver: Fix a parsing bug where some options were matched
incorrectly. I'm blanking on the smartest way to write this search,
but we should just do the right thing when we move to TableGen.
 - <rdar://problem/6761194> [driver] -Wextra-tokens isn't parsed
   correctly

llvm-svn: 68525
2009-04-07 18:21:47 +00:00
Daniel Dunbar 88056a97f2 Use %s in test, not hard coded name.
llvm-svn: 68521
2009-04-07 17:09:43 +00:00
Douglas Gregor 40a8e0fbce XFAIL a failing test
llvm-svn: 68519
2009-04-07 16:32:03 +00:00
Steve Naroff ebc790d4d8 Tweak Sema::ActOnInstanceMessage() to look for a class method when dealing with qualified id's. This change is motivated by our desire to not support the "Class<foo>" idiom. Note that the change makes perfect sense (since all ObjC classes are also id/instances).
This allow us to document a simple migration path...change "Class <foo>" to "id <foo>".

This effects: 
- <rdar://problem/6761939> TASK: File source change radars for "qualified Class" errors
- <rdar://problem/6761864> Protocol qualified Class is unsupported

llvm-svn: 68517
2009-04-07 15:07:57 +00:00
Steve Naroff d338d08f49 Fix typo in newly added test case.
llvm-svn: 68515
2009-04-07 14:22:40 +00:00
Steve Naroff 54e5945297 Change the type of ObjC @ string constants (from NSConstantString->NSString).
This fixes <rdar://problem/6757102> clang type for @"xxx" is "NSConstantString *" (GCC type is "NSString *").

llvm-svn: 68514
2009-04-07 14:18:33 +00:00
Daniel Dunbar d7beeea228 Handle use side of __objc_exception__ attribute; when using an
exception with this attribute we don't need to emit a weak definition
for the exception type information.

llvm-svn: 68513
2009-04-07 06:43:45 +00:00
Chris Lattner 91c941ecfd *everyone* knows that __weak is not defined on linux :)
llvm-svn: 68512
2009-04-07 06:05:28 +00:00
Chris Lattner 0f98a286a3 implement rdar://6762183. I'm not sure if it is more insane that
GCC ignores macro definitions after \n's or that real code depends
on this.

llvm-svn: 68511
2009-04-07 06:02:44 +00:00
Daniel Dunbar 15894b791b Various fixes to symbols used for Obj-C x86_64 metadata.
- Changed method names to match gcc (categories names still aren't
   mangled in).

 - Expose correct name for class and metadata symbols (although
   -fvisibility=hidden isn't yet correct).

 - Remove several things from llvm.used that didn't need to be there
   (I suspect this can still be trimmed).

 - Don't use asm-prefix extension for _objc_empty_{cache,vtable} (not
   needed).

 - Hide EH type class info with -fvisibility=hidden

 - Change setGlobal[Option]Visibility to not change the visibility of
   functions with internal linkage.

llvm-svn: 68510
2009-04-07 05:48:37 +00:00
Ted Kremenek 25db1f3ff1 Add test case.
llvm-svn: 68505
2009-04-07 05:33:18 +00:00
Daniel Dunbar 5718a2b4a1 Fix test (triple wasn't passed correctly, the driver doesn't accept
-mtriple).

llvm-svn: 68484
2009-04-07 02:31:44 +00:00
Daniel Dunbar 4fab57ddea Implement __sync_{add,sub,and,or,xor}_and_fetch and
__sync_bool_compare_and_swap.
 - <rdar://problem/6762223> [sema/irgen] support
   __sync_bool_compare_and_swap and __sync_add_and_fetch

llvm-svn: 68482
2009-04-07 00:55:51 +00:00
Fariborz Jahanian 54d569c51d Warn instead of error on duplicate protocol definitions.
Be kind to so many projects which are doing this (and be
like gcc).

llvm-svn: 68474
2009-04-06 23:43:32 +00:00
Steve Naroff 837dc03222 Make casting 'super' a deprecated warning (instead of a hard error).
This will simplify clang adoption, and is probably better "etiquette" (since gcc has always accepted this idiom without warning). Once we are over the adoption hurdle, we can turn this into an error.

llvm-svn: 68468
2009-04-06 22:07:54 +00:00
Douglas Gregor 7a5bc76b81 Fixed the Fix-It hints for comparison against a string literal. Thanks, Chris!
llvm-svn: 68454
2009-04-06 18:45:53 +00:00
Fariborz Jahanian bc3c77b881 Fixed visibility issues related to objc2's synthesized
ivars.

llvm-svn: 68453
2009-04-06 18:30:00 +00:00
Anders Carlsson 65cb90efc1 Define __OPTIMIZE__ and __OPTIMIZE_SIZE__ if the -O[12] and -Os flags are passed to the compiler.
llvm-svn: 68450
2009-04-06 17:37:10 +00:00
Chris Lattner a8d2dbd181 Daniel convinced me that accepting "const va_list" arguments to va_arg is
a really really bad idea.  Now that we emit an error about the unpromoted
type, users should be able to understand what is going on.

llvm-svn: 68447
2009-04-06 17:07:34 +00:00
Fariborz Jahanian 15e3a5c4b8 writable property in a category of class's superclass
makes the property writable in the current class.
 

llvm-svn: 68446
2009-04-06 16:59:10 +00:00