Commit Graph

2863 Commits

Author SHA1 Message Date
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
Chris Lattner 70a42144ca adjust for the new -Wvector-conversions option
llvm-svn: 69366
2009-04-17 18:39:25 +00:00
Douglas Gregor 6cc68a47b5 PCH support for labels and goto.
llvm-svn: 69364
2009-04-17 18:18:49 +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 ead1e0002f clean up run lines.
llvm-svn: 69359
2009-04-17 17:43:56 +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
Anders Carlsson 6dc3575220 Add support for the __has_trivial_destructor type trait.
llvm-svn: 69345
2009-04-17 02:34:54 +00:00
Daniel Dunbar 3f4a2c286e 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.

llvm-svn: 69342
2009-04-17 01:54:00 +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
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
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 027aa3cb0e Force target triple for test depending on __weak.
llvm-svn: 69297
2009-04-16 17:33:37 +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
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
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
Douglas Gregor 8693ec4e58 PCH support for TypesCompatibleExpr, ChooseExpr, and GNUNullExpr.
llvm-svn: 69242
2009-04-15 23:33:31 +00:00
Douglas Gregor 2ebf8717a5 PCH support for ExtVectorElementExpr and VAArgExpr.
llvm-svn: 69240
2009-04-15 23:02:49 +00:00
Douglas Gregor d4ed114e23 PCH support for CompoundAssignOperator and ConditionalOperator
llvm-svn: 69237
2009-04-15 22:40:36 +00:00
Douglas Gregor 978887b6b0 PCH support for ImaginaryLiteral and ArraySubscriptExpr
llvm-svn: 69233
2009-04-15 22:19:53 +00:00
Daniel Dunbar 7dd749e6fd Defer generation of tentative definitions.
- PR3980.

 - <rdar://problem/6762287> [irgen] crash when generating tentative
   definition of incomplete structure

 - This also avoids creating common definitions for things which are
   later overwritten.

 - XFAIL'ed external-defs.c, it isn't completing types properly yet.

llvm-svn: 69231
2009-04-15 22:08:45 +00:00
Douglas Gregor 455b8f4106 PCH support for ExtQualType
llvm-svn: 69230
2009-04-15 22:00:08 +00:00
Fariborz Jahanian 3453f7d410 Fix decl type merges when they have
__string/__weak attributes.

llvm-svn: 69229
2009-04-15 21:54:48 +00:00
Devang Patel 9074ed8c6a Set DebugInfo at the beginning of GenerateBlockFunction().
llvm-svn: 69228
2009-04-15 21:51:44 +00:00
Daniel Dunbar c7ba533378 Add warning when a tentative array definition is assumed to have one element.
- Also, fixed one to actually be one (instead of zero). :)

llvm-svn: 69226
2009-04-15 21:35:27 +00:00
Douglas Gregor bc8a78d5a4 PCH support for declaration attributes
llvm-svn: 69225
2009-04-15 21:30:51 +00:00
Daniel Dunbar 4b68d26a93 Don't use \01 in symbol name if unnecessary.
- This was particularly bad since I fixed one instance of this name
   and not another, meaning we got an LLVM module with the same
   effective name in two different globals!

llvm-svn: 69205
2009-04-15 19:52:32 +00:00
Steve Naroff 439a3e4106 Fix <rdar://problem/6786597> varargs not supported for Blocks under clang.
Teach Sema::SemaBuiltinVAStart() about blocks.

llvm-svn: 69201
2009-04-15 19:33:47 +00:00
Fariborz Jahanian 47b21081cb Patch to remove a bogus warning which pointed to underlying AST
gen. issue for property in continuation class declared readwrite 
but which did not generate the declaration for the setter. Fix also
removed a FIXME and resulted in code cleanup.

llvm-svn: 69200
2009-04-15 19:19:03 +00:00
Daniel Dunbar 24645c9ff4 Fix alignment on obj_msgrefs to match llvm-gcc.
llvm-svn: 69199
2009-04-15 19:04:46 +00:00
Daniel Dunbar e60aa05d34 Add test case for superrefs section (and make spacing consistent).
llvm-svn: 69198
2009-04-15 19:03:14 +00:00
Douglas Gregor e20a2e5fa3 PCH support for MemberExpr and CallExpr.
llvm-svn: 69186
2009-04-15 17:43:59 +00:00
Steve Naroff bb99c5c933 Fixup http://llvm.org/viewvc/llvm-project?rev=69165&view=rev (based on feedback from Eli).
llvm-svn: 69184
2009-04-15 17:31:31 +00:00
Steve Naroff 6f84266619 Revert previous patch (will commit a fix soon).
llvm-svn: 69178
2009-04-15 16:58:41 +00:00
Douglas Gregor 958dfc9bbd PCH support for string literals
llvm-svn: 69172
2009-04-15 16:35:07 +00:00
Douglas Gregor 0253c83610 PCH support for UnaryOperator, SizeOfAlignOfExpr
llvm-svn: 69169
2009-04-15 15:58:59 +00:00
Steve Naroff 635168aa33 Fix <rdar://problem/6789707> "warning: 'extern' variable has an initializer" not correct for __private_extern__.
llvm-svn: 69167
2009-04-15 15:20:03 +00:00
Steve Naroff fab0262047 Fix <rdar://problem/6791490> [clang10 regression] [sema] invalid illegal jump diagnostic.
caused by: <rdar://problem/6252084> [sema] jumps into Obj-C exception blocks should be disallowed.

Sema::RecursiveCalcLabelScopes() and Sema::RecursiveCalcJumpScopes() need to pop the ScopeStack within the statement iteration loop (was outside the loop).

Eli, please review (thanks).

llvm-svn: 69165
2009-04-15 14:38:36 +00:00
Chris Lattner f5f049b548 add another sanity check for -Werror=xx
llvm-svn: 69157
2009-04-15 07:05:12 +00:00
Chris Lattner 5ea5dc8a3a add a missing &&
llvm-svn: 69156
2009-04-15 07:03:57 +00:00
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