Commit Graph

1707 Commits

Author SHA1 Message Date
Fariborz Jahanian 8630b2d992 Explicit declaration of property setters over-ride
prohibition of 'readonly' properties in an assignment.

llvm-svn: 62028
2009-01-10 18:43:55 +00:00
Douglas Gregor b37080a969 Allow multiple Microsoft calling-convention keywords. Fixes rdar://problem/6486133
llvm-svn: 62018
2009-01-10 00:48:18 +00:00
Douglas Gregor 658b9550bb When we see a reference to a struct, class, or union like "struct X"
that is neither a definition nor a forward declaration and where X has
not yet been declared as a tag, introduce a declaration
into the appropriate scope (which is likely *not* to be the current
scope). The rules for the placement of the declaration differ slightly
in C and C++, so we implement both and test the various corner
cases. This implementation isn't 100% correct due to some lingering
issues with the function prototype scope (for a function parameter
list) not being the same scope as the scope of the function
definition. Testcase is FIXME'd; this probably isn't an important issue.

Addresses <rdar://problem/6484805>.

llvm-svn: 62014
2009-01-09 22:42:13 +00:00
Ted Kremenek 890d44eb7f Dead stores checker: Don't flag dead stores for self-assignments (common escape hatch for 'unused variable' warnings).
llvm-svn: 62010
2009-01-09 22:15:01 +00:00
Fariborz Jahanian 519976c4e9 This patch removes mergeProperties and does the property lookup
in designated protocols lazily.

llvm-svn: 62007
2009-01-09 21:04:52 +00:00
Sebastian Redl 6079525591 Very basic support for pure virtual functions.
llvm-svn: 62003
2009-01-09 19:57:06 +00:00
Douglas Gregor 020713e308 Replace DeclContext's vector of ScopedDecl pointers with a linked list
of ScopedDecls (using the new ScopedDecl::NextDeclInScope
pointer). Performance-wise:

  - It's a net win in memory utilization, since DeclContext is now one
    pointer smaller than it used to be (std::vectors are typically 3
    pointers; we now use 2 pointers) and 
  - Parsing Cocoa.h with -fsyntax-only (with a Release-Asserts Clang)
    is about 1.9% faster than before, most likely because we no longer
    have the memory allocations and copying associated with the
    std::vector.

I'll re-enable serialization of DeclContexts once I've sorted out the
NextDeclarator/NextDeclInScope question.

llvm-svn: 62001
2009-01-09 19:42:16 +00:00
Chris Lattner c7c9ab7947 Fix rdar://6480479 - [parser] infinite loop on invalid input
llvm-svn: 61975
2009-01-09 04:34:13 +00:00
Daniel Dunbar f4c6616d9d Fix crash on null deference when searching for readwrite properties in
categories.
 - Also, simplify nesting via early return.

llvm-svn: 61968
2009-01-09 01:04:21 +00:00
Ted Kremenek 339153d3be Re-enable PTH testing for Cocoa.h and Carbon.h (and include testing for Objective-C++).
llvm-svn: 61965
2009-01-09 00:41:48 +00:00
Ted Kremenek cb5a95f3a4 Temporarily revert r61956 and r61957 (PTH tests failing).
llvm-svn: 61960
2009-01-09 00:27:29 +00:00
Ted Kremenek 510b4da49d Enhance -fsyntax-only test of Carbon.h to also include testing for PTH.
llvm-svn: 61958
2009-01-08 23:42:56 +00:00
Ted Kremenek 8598addcd7 Enhance -fsyntax-only test of Cocoa.h to also include testing for PTH.
llvm-svn: 61957
2009-01-08 23:41:35 +00:00
Fariborz Jahanian d11dc0b1d9 Place warning about 'readonly' property attributes which
are related to setter syntax under -Wreadonly-setter-attrs
to prevent warnings in projects built with gcc.

llvm-svn: 61953
2009-01-08 23:23:10 +00:00
Douglas Gregor 82ac25e4a7 Unify the code for defining tags in C and C++, so that we always
introduce a Scope for the body of a tag. This reduces the number of
semantic differences between C and C++ structs and unions, and will
help with other features (e.g., anonymous unions) in C. Some important
points:

  - Fields are now in the "member" namespace (IDNS_Member), to keep
    them separate from tags and ordinary names in C. See the new test
    in Sema/member-reference.c for an example of why this matters. In
    C++, ordinary and member name lookup will find members in both the
    ordinary and member namespace, so the difference between
    IDNS_Member and IDNS_Ordinary is erased by Sema::LookupDecl (but
    only in C++!). 
  - We always introduce a Scope and push a DeclContext when we're
    defining a tag, in both C and C++. Previously, we had different
    actions and different Scope/CurContext behavior for enums, C
    structs/unions, and C++ structs/unions/classes. Now, it's one pair
    of actions. (Yay!)

There's still some fuzziness in the handling of struct/union/enum
definitions within other struct/union/enum definitions in C. We'll
need to do some more cleanup to eliminate some reliance on CurContext
before we can solve this issue for real. What we want is for something
like this:

  struct X {
    struct T { int x; } t;
  };

to introduce T into translation unit scope (placing it at the
appropriate point in the IdentifierResolver chain, too), but it should
still have struct X as its lexical declaration
context. PushOnScopeChains isn't smart enough to do that yet, though,
so there's a FIXME test in nested-redef.c

llvm-svn: 61940
2009-01-08 20:45:30 +00:00
Fariborz Jahanian 17290c3638 Objc's compatibility-alias semantics and code
gen issue fix.

llvm-svn: 61901
2009-01-08 01:10:55 +00:00
Douglas Gregor f325278799 Fix PR clang/3291
llvm-svn: 61886
2009-01-07 21:36:02 +00:00
Fariborz Jahanian dd2d75bb52 Don't ICE when messaging on 'super' receiver when class
of category implementation is undeclared. Issue error instead.

llvm-svn: 61882
2009-01-07 21:01:41 +00:00
Fariborz Jahanian 475831bd6e Another nasty code gen. bug with trivial fix. Calling class
method on 'super' receiver in a category implementation.
Other simpler cases were working by accident.

llvm-svn: 61880
2009-01-07 20:11:22 +00:00
Douglas Gregor f4d332797b Finished semantic analysis of anonymous unions in C++.
Duplicate-member checking within classes is still a little messy, and
anonymous unions are still completely broken in C. We'll need to unify
the handling of fields in C and C++ to make this code applicable in
both languages.

llvm-svn: 61878
2009-01-07 19:46:03 +00:00
Douglas Gregor 4bba1ed9bc Test case for anonymous unions in C++
llvm-svn: 61860
2009-01-07 16:22:09 +00:00
Douglas Gregor 8d973111a8 When determining whether a variable is a file-scoped variable, check
out its lookup context (to see through linkage
specifications). Addresses <rdar://problem/6477142>.

llvm-svn: 61848
2009-01-07 02:48:43 +00:00
Ted Kremenek 1d92d2c813 This commit reflects changes to the retain/release checker motivated by my
recent discussions with Thomas Clement and Ken Ferry concerning the "fundamental
rule" for Cocoa memory management
(http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/Tasks/MemoryManagementRules.html).

Here is the revised behavior of the checker concerning tracking retain/release
counts for objects returned from message expressions involving instance methods:

1) Track the returned object if the return type of the message expression is
id<..>, id, or a pointer to *any* object that subclasses NSObject. Such objects
are assumed to have a retain count. Previously the checker only tracked objects
when the receiver of the message expression was part of the standard Cocoa API
(i.e., had class names prefixed with 'NS'). This should significantly expand the
amount of checking performed.

2) Consider the object owned if the selector of the message expression contains
"alloc", "new", or "copy". Previously we also considered "create", but this
doesn't follow from the fundamental rule (discussions with the Cocoa folks
confirms this).

llvm-svn: 61837
2009-01-07 00:39:56 +00:00
Douglas Gregor 6ad0ef5091 Allow Objective-C entities to be declared within a transparent context
nested in the translation unit. This fixes <rdar://problem/6476070>.

llvm-svn: 61832
2009-01-06 23:51:29 +00:00
Steve Naroff f192fabbdc Another tweak to handle the MS extensions (<rdar://problem/5956221>).
llvm-svn: 61821
2009-01-06 19:34:12 +00:00
Steve Naroff 1f42c2e94d Fix <rdar://problem/5956221> clang ObjC rewriter: Microsoft-specific __fastcall keyword unrecognized.
This fix is C++ specific.

llvm-svn: 61816
2009-01-06 17:40:00 +00:00
Chris Lattner ce1da2cfca - Various comment typo fixes in Sema.h
- Simplify ParseDeclCXX to use early exit on error instead of nesting.
- Change ParseDeclCXX to using the 'skip on error' form of ExpectAndConsume.
- If we don't see the ; in a using directive, still call the action, for 
  hopefully better error recovery.

llvm-svn: 61801
2009-01-06 07:27:21 +00:00
Douglas Gregor c7acfdfe9a Add QualifiedDeclRefExpr, which retains additional source-location
information for declarations that were referenced via a qualified-id,
e.g., N::C::value. We keep track of the location of the start of the
nested-name-specifier. Note that the difference between
QualifiedDeclRefExpr and DeclRefExpr does have an effect on the
semantics of function calls in two ways:
  1) The use of a qualified-id instead of an unqualified-id suppresses
     argument-dependent lookup
  2) If the name refers to a virtual function, the qualified-id
  version will call the function determined statically while the
  unqualified-id version will call the function determined dynamically
  (by looking up the appropriate function in the vtable).

Neither of these features is implemented yet, but we do print out
qualified names for QualifiedDeclRefExprs as part of the AST printing.

llvm-svn: 61789
2009-01-06 05:10:23 +00:00
Chris Lattner 610c87cad6 rename these tests to match the attribute.
llvm-svn: 61770
2009-01-05 23:10:19 +00:00
Daniel Dunbar 0d2bfec51d Remainder is only valid on integer vector operands.
Improve ext vector test case.

llvm-svn: 61766
2009-01-05 22:55:36 +00:00
Sebastian Redl baad4e765f PODness and Type Traits
Make C++ classes track the POD property (C++ [class]p4)
Track the existence of a copy assignment operator.
Implicitly declare the copy assignment operator if none is provided.
Implement most of the parsing job for the G++ type traits extension.
Fully implement the low-hanging fruit of the type traits:
__is_pod: Whether a type is a POD.
__is_class: Whether a type is a (non-union) class.
__is_union: Whether a type is a union.
__is_enum: Whether a type is an enum.
__is_polymorphic: Whether a type is polymorphic (C++ [class.virtual]p1).

llvm-svn: 61746
2009-01-05 20:52:13 +00:00
Douglas Gregor 3bdc895818 Add forgotten test case for linkage specifications
llvm-svn: 61737
2009-01-05 19:50:09 +00:00
Douglas Gregor 07665a69e8 Introduce support for "transparent" DeclContexts, which are
DeclContexts whose members are visible from enclosing DeclContexts up
to (and including) the innermost enclosing non-transparent
DeclContexts. Transparent DeclContexts unify the mechanism to be used
for various language features, including C enumerations, anonymous
unions, C++0x inline namespaces, and C++ linkage
specifications. Please refer to the documentation in the Clang
internals manual for more information.

Only enumerations and linkage specifications currently use transparent
DeclContexts.

Still to do: use transparent DeclContexts to implement anonymous
unions and GCC's anonymous structs extension, and, later, the C++0x
features. We also need to tighten up the DeclContext/ScopedDecl link
to ensure that every ScopedDecl is in a single DeclContext, which
will ensure that we can then enforce ownership and reduce the memory
footprint of DeclContext.

llvm-svn: 61735
2009-01-05 19:45:36 +00:00
Chris Lattner c69537feb5 Fix a bug where we'd try to look beyond the current cached tokens when
not in backtracking mode.  This was just using the wrong predicate.

llvm-svn: 61666
2009-01-05 01:42:04 +00:00
Chris Lattner 6fead6e33b add a testcase
llvm-svn: 61660
2009-01-05 00:59:08 +00:00
Anders Carlsson 762e162284 Fix the bug that would cause Python to crash at startup.
When emitting the static variables we need to make sure that the order is preserved. 
Fix this by making StaticDecls a std::list which has O(1) random removal.

llvm-svn: 61621
2009-01-04 02:08:04 +00:00
Douglas Gregor d7c4d984d0 Parser support for C++ using directives, from Piotr Rak
llvm-svn: 61486
2008-12-30 03:27:21 +00:00
Sebastian Redl 4f84ddccc8 Fix a grep error that caused CodeGenObjC/encode-test.m to fail.
llvm-svn: 61455
2008-12-28 15:48:05 +00:00
Sebastian Redl a2b5e31cb1 Diagnose declarations that don't declare anything, and fix PR3020.
Examples:
int;
typedef int;

llvm-svn: 61454
2008-12-28 15:28:59 +00:00
Sebastian Redl 85cd7bac29 Fix filename typo.
llvm-svn: 61453
2008-12-28 14:19:27 +00:00
Nuno Lopes 037bc858a0 add RUN line
llvm-svn: 61452
2008-12-27 23:47:34 +00:00
Douglas Gregor 1dc9826a46 Add support for out-of-line definitions of conversion functions and member operators
llvm-svn: 61442
2008-12-26 15:00:45 +00:00
Anton Korobeynikov b46e3a8d3b Complete the test after adding handling of merged attributes on decls.
llvm-svn: 61438
2008-12-26 00:52:17 +00:00
Anton Korobeynikov d72f47aa05 Add full dllimport / dllexport support: both sema checks and codegen.
Patch by Ilya Okonsky

llvm-svn: 61437
2008-12-26 00:52:02 +00:00
Anton Korobeynikov 3112c877c1 Testcase for stdcall/fastcall sema checks.
Patch by Ilya Okonsky!

llvm-svn: 61436
2008-12-26 00:51:21 +00:00
Steve Naroff f9c29d4200 Add parser support for __forceinline, __w64, __ptr64.
llvm-svn: 61431
2008-12-25 14:41:26 +00:00
Steve Naroff 44ac777741 Add parser support for __cdecl, __stdcall, and __fastcall.
Change preprocessor implementation of _cdecl to reference __cdecl.

llvm-svn: 61430
2008-12-25 14:16:32 +00:00
Douglas Gregor b9bd8a994c Keep track of template arguments when we parse them. Right now, we don't actually do anything with the template arguments, but they'll be used to create template declarations
llvm-svn: 61413
2008-12-24 02:52:09 +00:00
Douglas Gregor 583540360c Correct the order in which we cope with end-of-class-definition
semantics and improve our handling of default arguments. Specifically,
we follow this order:

  - As soon as the see the '}' in the class definition, the class is
  complete and we add any implicit declarations (default constructor,
  copy constructor, etc.) to the class.
  - If there are any default function arguments, parse them
  - If there were any inline member function definitions, parse them

As part of this change, we now keep track of the the fact that we've
seen unparsed default function arguments within the AST. See the new
ParmVarDecl::hasUnparsedDefaultArg member. This allows us to properly
cope with calls inside default function arguments to other functions
where we're making use of the default arguments.

Made some C++ error messages regarding failed initializations more
specific. 

llvm-svn: 61406
2008-12-24 00:01:03 +00:00
Fariborz Jahanian 4ecf1e94db Last patch, for now, to privde ObjC's encoding of types.
We now pass all gcc's encoding compatibility tests.

llvm-svn: 61387
2008-12-23 21:30:15 +00:00