Commit Graph

1575 Commits

Author SHA1 Message Date
Douglas Gregor 91f84216f7 Unifies the name-lookup mechanisms used in various parts of the AST
and separates lexical name lookup from qualified name lookup. In
particular:
  * Make DeclContext the central data structure for storing and
    looking up declarations within existing declarations, e.g., members
    of structs/unions/classes, enumerators in C++0x enums, members of
    C++ namespaces, and (later) members of Objective-C
    interfaces/implementations. DeclContext uses a lazily-constructed
    data structure optimized for fast lookup (array for small contexts,
    hash table for larger contexts). 

  * Implement C++ qualified name lookup in terms of lookup into
    DeclContext.

  * Implement C++ unqualified name lookup in terms of
    qualified+unqualified name lookup (since unqualified lookup is not
    purely lexical in C++!)

  * Limit the use of the chains of declarations stored in
    IdentifierInfo to those names declared lexically.

  * Eliminate CXXFieldDecl, collapsing its behavior into
    FieldDecl. (FieldDecl is now a ScopedDecl).

  * Make RecordDecl into a DeclContext and eliminates its
    Members/NumMembers fields (since one can just iterate through the
    DeclContext to get the fields).

llvm-svn: 60878
2008-12-11 16:49:14 +00:00
Anders Carlsson 591b2224cb Add another complex promotion test.
llvm-svn: 60863
2008-12-10 23:57:51 +00:00
Anders Carlsson b05961c700 Make sure to promote expressions of the form (floating point + complex integer) correctly, to (complex floating point + complex floating point)
llvm-svn: 60862
2008-12-10 23:30:05 +00:00
Douglas Gregor 85970ca84c Added a warning when referencing an if's condition variable in the
"else" clause, e.g.,

  if (int X = foo()) {
  } else {
    if (X) { // warning: X is always zero in this context
    }
  }

Fixes rdar://6425550 and lets me think about something other than
DeclContext.

llvm-svn: 60858
2008-12-10 23:01:14 +00:00
Steve Naroff c68cfcfd03 The "real" fix for <rdar://problem/6424347> clang on xcode: Assertion failed: (0 && "unexpected type"), function mergeTypes,
Commit r60845 was premature.

llvm-svn: 60852
2008-12-10 22:14:21 +00:00
Douglas Gregor 9aa8b55d10 Fix PR clang/3175: CheckAddressOfOperand does not handle references to class vars
llvm-svn: 60849
2008-12-10 21:26:49 +00:00
Steve Naroff 13ac125edf Fix <rdar://problem/6424347> clang on xcode: Assertion failed: (0 && "unexpected type"), function mergeTypes,
llvm-svn: 60845
2008-12-10 20:07:25 +00:00
Steve Naroff 68e167df8e Fix <rdar://problem/6418623> Bogus block type compatibility warning.
llvm-svn: 60842
2008-12-10 17:49:55 +00:00
Fariborz Jahanian 7572ac5614 Patch to allow a getter call using property dot-syntax notation.
llvm-svn: 60816
2008-12-10 00:21:50 +00:00
Fariborz Jahanian ea831ee11c Prevent bogus warning on unimplemented setter/getter when user
has added declaration of these methods in its @interface.

llvm-svn: 60803
2008-12-09 22:43:22 +00:00
Steve Naroff 70cb0071c9 Add testcase for commit r60781.
llvm-svn: 60793
2008-12-09 20:59:16 +00:00
Fariborz Jahanian 3d8552a75d Support for implementation of property in the case where
the synthesis is in an implementation of s subclass of
a super class where the property has been declared.

llvm-svn: 60792
2008-12-09 20:23:04 +00:00
Steve Naroff 08628db9d2 Fix <rdar://problem/6429113> clang ObjC rewriter: crash rewriting file with Blocks and properties
More fancy footwork to cope with rewriting property 'setters'.

llvm-svn: 60760
2008-12-09 12:56:34 +00:00
Ted Kremenek c28ce29a12 [static analyzer] Extend VLA size checking to look for undefined sizes.
llvm-svn: 60734
2008-12-09 00:44:16 +00:00
Ted Kremenek d7266bf20a Add zero-sized VLA check test case.
llvm-svn: 60731
2008-12-09 00:14:48 +00:00
Ted Kremenek 223005f35a Incorporate MissingDealloc_IBOutlet.m test case into MissingDealloc.m
llvm-svn: 60722
2008-12-08 22:05:43 +00:00
Ted Kremenek 1f9dd45f57 Incorporate MissingDeallc_SEL.m test case into MissingDealloc.m
llvm-svn: 60721
2008-12-08 22:01:50 +00:00
Ted Kremenek 8f5c0ede0f Add test case for <rdar://problem/6380411>.
llvm-svn: 60720
2008-12-08 21:59:21 +00:00
Chris Lattner 46415261ee Fix PR3172: if we see an eof or } at the top level, reject it.
This is important because ParseDeclarationOrFunctionDefinition
skips to, but does not consume, an } on error.

llvm-svn: 60719
2008-12-08 21:59:01 +00:00
Steve Naroff 5fd31b17df ObjCInterfaceDecl::lookupInstanceMethod() needs to look through a categories protocols.
Fixes <rdar://problem/6418640> clang on prokit: error: incompatible type returning 'id', expected 'NSSize'

llvm-svn: 60716
2008-12-08 20:57:28 +00:00
Fariborz Jahanian 3edadfc730 Changed 'readonly' 'retain/copy' diagnostics into
warning as it is allowed in gcc and will break projects.

llvm-svn: 60710
2008-12-08 19:28:10 +00:00
Fariborz Jahanian 3685995d2c Since we do not allow a readonly property to be 'copy'retain', we
must allow the continuation class to extend it to a 'readwrite'
and 'copy/retain'.

llvm-svn: 60709
2008-12-08 18:47:29 +00:00
Steve Naroff 1042ff345a Handle chained/nested property 'getters' (obj.p1.p2.p3).
This is a follow-up to fixing <rdar://problem/6213955> clang ObjC rewriter: rewriter doesn't appear to support @property and @synthesize.

llvm-svn: 60700
2008-12-08 16:43:47 +00:00
Eli Friedman 14fb8587be Workaround for PR3173. The fix is correct in the sense that if the enum
code were working correctly, it would be a no-op, but it's not really a 
proper fix.  That said, I don't really want to touch the enum code at 
the moment because I don't understand it very well, and this seems to 
be a relatively visible regression.

llvm-svn: 60680
2008-12-08 02:21:03 +00:00
Chris Lattner b3582b939e a minor grammar fix
llvm-svn: 60646
2008-12-07 00:59:53 +00:00
Anders Carlsson 0d8f0ba6ed Improve VLA diagnostics/sema checking. Fixes PR2361 and PR2352.
llvm-svn: 60638
2008-12-07 00:20:55 +00:00
Fariborz Jahanian d2c2ad515e Use of properties declared in protocols in the category
via the category's protocol list1s, with appropriate
diagnsostics and a test case.

llvm-svn: 60634
2008-12-06 23:03:39 +00:00
Anders Carlsson 3bb1ffca94 Simplify test.
llvm-svn: 60631
2008-12-06 22:27:22 +00:00
Fariborz Jahanian ff83998e31 Improve error reporting of property and setter/getter
type mimatches.

llvm-svn: 60630
2008-12-06 21:48:16 +00:00
Anders Carlsson 5df391e5c7 Add diagnostics for bitfields.
llvm-svn: 60628
2008-12-06 20:33:04 +00:00
Anders Carlsson 45f4b8c0f2 Fix invalid bit-field.
llvm-svn: 60627
2008-12-06 20:32:39 +00:00
Fariborz Jahanian 5a3422f602 Patch to diagnose a variety of misuse of property
attributes. Example would be, readonly, assign or
assign, copy, etc.

llvm-svn: 60620
2008-12-06 01:12:43 +00:00
Douglas Gregor b0846b0f51 Add support for calls to dependent names within templates, e.g.,
template<typename T> void f(T x) {
    g(x); // g is a dependent name, so don't even bother to look it up
    g(); // error: g is not a dependent name
  }

Note that when we see "g(", we build a CXXDependentNameExpr. However,
if none of the call arguments are type-dependent, we will force the
resolution of the name "g" and replace the CXXDependentNameExpr with
its result.

GCC actually produces a nice error message when you make this
mistake, and even offers to compile your code with -fpermissive. I'll
do the former next, but I don't plan to do the latter.

llvm-svn: 60618
2008-12-06 00:22:45 +00:00
Douglas Gregor 4619e439b6 Introduce basic support for dependent types, type-dependent
expressions, and value-dependent expressions. This permits us to parse
some template definitions.

This is not a complete solution; we're missing type- and
value-dependent computations for most of the expression types, and
we're missing checks for dependent types and type-dependent
expressions throughout Sema.

llvm-svn: 60615
2008-12-05 23:32:09 +00:00
Fariborz Jahanian fbbaf6afae This test checks for duplicate implementation of the same
property. It also checks for duplicate use of the same ivar
in two different iproperty implementations. It also caught
an error for a test case used in CodeGen :).

llvm-svn: 60610
2008-12-05 22:32:48 +00:00
Fariborz Jahanian 88909849bb Fixed a test case. Added a test case showing property setter's
type mismatch (related to my last patch).

llvm-svn: 60599
2008-12-05 18:38:31 +00:00
Fariborz Jahanian 7988d7dc3e (instance/class) Method type checking between class and its implementation.
(instance/class) Method type checking between category and its implementation.
And a test case for all.

llvm-svn: 60598
2008-12-05 18:18:52 +00:00
Douglas Gregor 5101c24f60 Representation of template type parameters and non-type template
parameters, with some semantic analysis:
  - Template parameters are introduced into template parameter scope
  - Complain about template parameter shadowing (except in Microsoft mode)

Note that we leak template parameter declarations like crazy, a
problem we'll remedy once we actually create proper declarations for
templates. 

Next up: dependent types and value-dependent/type-dependent
expressions.

llvm-svn: 60597
2008-12-05 18:15:24 +00:00
Steve Naroff 6d6da255fb Fixed <rdar://problem/6213808> clang ObjC rewriter: @finally is not always executed
llvm-svn: 60593
2008-12-05 17:03:39 +00:00
Anders Carlsson 1aa679227b Use VerifyIntegerConstantExpression instead of isIntegerConstantExpr. Fixes PR2963
llvm-svn: 60591
2008-12-05 16:33:57 +00:00
Anders Carlsson 1e495d9860 Make Sema::CheckForConstantInitializer use Expr::Evaluate. This fixes PR3130.
llvm-svn: 60580
2008-12-05 05:09:56 +00:00
Fariborz Jahanian 521b3a363e Patch for diagnosing type mismatch between
methods in class and its implementation.
This is work in progress.

llvm-svn: 60573
2008-12-05 01:35:25 +00:00
Chris Lattner 79413956d4 change getCurFunctionDecl to skip through Block contexts to find
the containing block.  Introduce a new getCurFunctionOrMethodDecl
method to check to see if we're in a function or objc method.
Minor cleanups to other related places.  This fixes rdar://6405429.

llvm-svn: 60564
2008-12-04 23:50:19 +00:00
Chris Lattner 2ca529ce61 instead of forcing blocks on by default, make them default to off, but let
specific targets default them to on.  Default blocks to on on 10.6 and later.
Add a -fblocks option that allows the user to override the target's default.
Use -fblocks in the various testcases that use blocks.

llvm-svn: 60563
2008-12-04 23:20:07 +00:00
Fariborz Jahanian 5271058c75 Output better diagnostics for continuation class
property attribute mis-specification.

llvm-svn: 60562
2008-12-04 22:56:16 +00:00
Sebastian Redl 33a3101d43 Code cleanup in new handling.
llvm-svn: 60557
2008-12-04 22:20:51 +00:00
Ted Kremenek 561370c23e Add 'expected-warning' to make test case pass.
llvm-svn: 60548
2008-12-04 19:44:23 +00:00
Ted Kremenek d58e74182e Add another static analyzer test case involving attribute(nonnull).
llvm-svn: 60547
2008-12-04 19:39:12 +00:00
Ted Kremenek 3f0e5c88d9 Add another test case for attribute(nonnull) checking.
llvm-svn: 60544
2008-12-04 18:35:53 +00:00
Sebastian Redl f84512a360 Fix some diagnostics and enhance test cases. Now tests member new and ambiguous overloads.
llvm-svn: 60542
2008-12-04 17:24:46 +00:00