Граф коммитов

858 Коммитов

Автор SHA1 Сообщение Дата
Fariborz Jahanian c55a24095c Don't ICE on user redeclaration of objc's built-in types.
Issue diagnostics instead if types do not match.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62349 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-16 19:58:32 +00:00
Chris Lattner 95d58f3ad7 silence release-assert warning.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62346 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-16 19:44:00 +00:00
Douglas Gregor 66b947fdf9 Fix <rdar://problem/6502934>. We were creating an ImplicitCastExpr
with reference type (it should be an lvalue with non-reference type).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62345 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-16 19:38:23 +00:00
Chris Lattner bbee00b645 minor cleanups to StringLiteralParser: no need to pass target info
into its ctor.  Also, make it handle validity checking of pascal
strings instead of making clients do it.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62332 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-16 18:51:42 +00:00
Douglas Gregor 506ae418eb Part one of handling C++ functional casts. This handles semantic
analysis and AST-building for the cases where we have N != 1
arguments. For N == 1 arguments, we need to finish the C++
implementation of explicit type casts (C++ [expr.cast]).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62329 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-16 18:33:17 +00:00
Anders Carlsson dce5e2cabf Use a single function for doing vararg argument promotion. Also, make sure to do the promotion before checking the type - fixes PR3340.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62323 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-16 16:48:51 +00:00
Chris Lattner 0c21e84b82 rename PP::getPhysicalCharacterAt -> PP::getSpelledCharacterAt.
Slightly speed up sema of numbers like '1' by going directly to 
TargetInfo instead of through ASTContext.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62314 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-16 07:10:29 +00:00
Zhongxing Xu d5ed8c3d7d Extract code dealing with typedef declarators into a separate function.
No functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62303 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-16 03:34:13 +00:00
Zhongxing Xu cb8f4f15dd Extract code dealing with variable declarator into a separate function.
No functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62300 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-16 02:36:34 +00:00
Zhongxing Xu 416fcaf920 Extract code dealing with declarators of function type into a separate function
Sema::ActOnFunctionDeclarator().  
No functionality change.  


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62290 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-16 01:13:29 +00:00
Douglas Gregor 4dc6b1c81c Improve diagnostics for ambiguous name lookup results
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62287 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-16 00:38:09 +00:00
Chris Lattner 13fd416b3d PR3330: given an enum like this:
enum E {
 A = 1U,
 B
};

Don't make an implicit cast expr of null for B.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62274 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-15 19:19:42 +00:00
Daniel Dunbar f185319f25 Fix some unused variable, control reaches end of non-void function,
and uninitialized use options.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62270 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-15 18:32:35 +00:00
Nuno Lopes 6ed2ef8281 add support for initializing static vars with a cast to union (gcc extension)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62261 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-15 16:44:45 +00:00
Seo Sanghyeon eff2cd58a8 PR2746: Implement GCC cast to union extension
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62255 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-15 04:51:39 +00:00
Douglas Gregor 4bb64e77dd Deallocate the BasePaths structure that we allocate for LookupResult.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62250 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-15 02:19:31 +00:00
Douglas Gregor 7176fff961 Initial implementation of member name lookup
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62247 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-15 00:26:24 +00:00
Douglas Gregor eb11cd078b Refactor name lookup.
This change refactors and cleans up our handling of name lookup with
LookupDecl. There are several aspects to this refactoring:

  - The criteria for name lookup is now encapsulated into the class
  LookupCriteria, which replaces the hideous set of boolean values
  that LookupDecl currently has.

  - The results of name lookup are returned in a new class
  LookupResult, which can lazily build OverloadedFunctionDecls for
  overloaded function sets (and, eventually, eliminate the need to
  allocate member for OverloadedFunctionDecls) and contains a
  placeholder for handling ambiguous name lookup (for C++).

  - The primary entry points for name lookup are now LookupName (for
    unqualified name lookup) and LookupQualifiedName (for qualified
    name lookup). There is also a convenience function
    LookupParsedName that handles qualified/unqualified name lookup
    when given a scope specifier. Together, these routines are meant
    to gradually replace the kludgy LookupDecl, but this won't happen
    until after we have base class lookup (which forces us to cope
    with ambiguities).

  - Documented the heck out of name lookup. Experimenting a little
    with using Doxygen's member groups to make some sense of the Sema
    class. Feedback welcome!

  - Fixes some lingering issues with name lookup for
  nested-name-specifiers, which now goes through
  LookupName/LookupQualifiedName. 



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62245 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-14 22:20:51 +00:00
Douglas Gregor 09f41cf63f Introduce support for C++0x explicit conversion operators (N2437)
Small cleanup in the handling of user-defined conversions. 

Also, implement an optimization when constructing a call. We avoid
recomputing implicit conversion sequences and instead use those
conversion sequences that we computed as part of overload resolution.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62231 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-14 15:45:31 +00:00
Ted Kremenek fc767615bc FunctionDecl::setParams() now uses the allocator associated with ASTContext to allocate the array of ParmVarDecl*'s.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62203 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-14 00:42:25 +00:00
Fariborz Jahanian fa23c1d9ad Implemenent objective-c's NSObject attribute as a way of ddeclaraing c-type
objects as an objective-c object.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62197 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-13 23:34:40 +00:00
Ted Kremenek 28396608ec PTH:
- Use canonical FileID when using getSpelling() caching.  This
  addresses some cache misses we were seeing with -fsyntax-only on
  Cocoa.h
- Added Preprocessor::getPhysicalCharacterAt() utility method for
  clients to grab the first character at a specified sourcelocation.
  This uses the PTH spelling cache.
- Modified Sema::ActOnNumericConstant() to use
  Preprocessor::getPhysicalCharacterAt() instead of
  SourceManager::getCharacterData() (to get PTH hits).

These changes cause -fsyntax-only to not page in any sources from
Cocoa.h.  We see a speedup of 27%.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62193 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-13 23:19:12 +00:00
Douglas Gregor ee159c14c1 Permitting typedefs without a name is a Microsoft/GNU extension
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62192 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-13 23:10:51 +00:00
Anders Carlsson 53859912e4 Use the unqualified type for GCCs struct/union cast extension
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62170 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-13 17:00:51 +00:00
Anders Carlsson 906fed0fb5 Warn when someone tries to pass a variable with a non-POD type to a varargs function/method/block.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62148 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-13 05:48:52 +00:00
Douglas Gregor 518fda1d12 Fix argument-passing bugs in a call to object
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62147 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-13 05:10:00 +00:00
Douglas Gregor 88b4bf202a Add the proper restrictions on the left-hand argument of a built-in
assignment operator candidate (C++ [over.match.oper]p4).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62128 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-13 00:52:54 +00:00
Douglas Gregor e63ef48b76 Make sure we don't name a constructor or destructor with a qualified
type. It leads to very weird errors.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62124 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-13 00:11:19 +00:00
Douglas Gregor 482b77d1cb Cleanup DeclContext::addDecl and DeclContext::insert interface, from Piotr Rak
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62122 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-12 23:27:07 +00:00
Ted Kremenek d30ef87f34 Patch by Roman Divacky:
Extend string-literal checking for printf() format string to handle conditional
ternary operators where both sides are literals.

This fixes PR 3319: http://llvm.org/bugs/show_bug.cgi?id=3319


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62117 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-12 23:09:09 +00:00
Douglas Gregor 4920f1ffb6 Implement support for anonymous structs and unions in C. Both C and
C++ handle anonymous structs/unions in the same way. Addresses several
bugs:

  <rdar://problem/6259534>
  <rdar://problem/6481130>
  <rdar://problem/6483159>

The test case in PR clang/1750 now passes with -fsyntax-only, but
CodeGen for inline assembler still fails.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62112 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-12 22:49:06 +00:00
Fariborz Jahanian d1fa6449e9 Patch to supprt case of readonly property being
assigned to when it has user declared setter method
defined in the class implementation (but no declaration in
the class itself).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62098 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-12 19:55:42 +00:00
Douglas Gregor 1a0d31a3d7 Properly set the scope of non-fields declared within a struct, union,
or enum to be outside that struct, union, or enum. Fixes several
regressions: 

  <rdar://problem/6487662>
  <rdar://problem/6487669>
  <rdar://problem/6487684>
  <rdar://problem/6487702>
  PR clang/3305
  PR clang/3312

There is still some work to do in Objective-C++, but this requires
that each of the Objective-C entities (interfaces, implementations,
etc.) to be introduced into the context stack with
PushDeclContext/PopDeclContext. This will be a separate fix, later.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62091 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-12 18:45:55 +00:00
Sebastian Redl 2726f9ad0a Fix operator precedence.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62038 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-11 13:39:06 +00:00
Steve Naroff 93983f8fa1 Convert property implementation to DeclContext::addDecl().
This completes the ObjCContainerDecl AST cleanup (for now).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62037 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-11 12:47:58 +00:00
Sebastian Redl de30747344 Convert some more actions to smart pointers.
No performance regression in my basic test.
Also fixed a type error in ActOnFinishSwitchStmt's arguments (body is a stmt).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62032 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-11 00:38:46 +00:00
Douglas Gregor dcde115dc2 Don't bother setting NextDeclarator for EnumConstantDecls. It isn't used
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62016 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-09 23:23:35 +00:00
Douglas Gregor 3218c4bb3b 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>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62014 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-09 22:42:13 +00:00
Sebastian Redl c9b580a4de Add some comments to the virtual work. Thanks to Doug Gregor for the review.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62012 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-09 22:29:03 +00:00
Fariborz Jahanian a66793ee8d This patch removes mergeProperties and does the property lookup
in designated protocols lazily.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62007 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-09 21:04:52 +00:00
Sebastian Redl 9ba73ad654 Very basic support for pure virtual functions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62003 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-09 19:57:06 +00:00
Douglas Gregor 6037fcba34 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62001 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-09 19:42:16 +00:00
Douglas Gregor a8cc8ce044 Make sure that ScopedDecls passed to DeclContext::addDecl are added into their lexical context
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61998 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-09 18:51:29 +00:00
Douglas Gregor f8d49f64ef Provide a new kind of iterator, the specific_decl_iterator, that
filters the decls seen by decl_iterator with two criteria: the dynamic
type of the declaration and a run-time predicate described by a member
function. This simplifies EnumDecl, RecordDecl, and ObjCContainerDecl
considerably. It has no measurable performance impact.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61994 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-09 17:18:27 +00:00
Steve Naroff 09c4719788 Move property API's up to ObjCContainerDecl (removing a lot of duplicate code).
Add isa/cast/dyncast support for ObjCContainerDecl.
Renamed classprop_iterator/begin/end to prop_iterator/begin/end (the class prefix was confusing).
More simplifications to Sema::ActOnAtEnd()...
Added/changed some FIXME's as a result of the above work.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61988 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-09 15:36:25 +00:00
Douglas Gregor d04341000d Addressed the issue in <rdar://problem/6479085>, where we failed to
rewrite @class declarations that showed up within linkage
specifications because those @class declarations never made it any
place where the rewriter could find them.

Moved all of the ObjC*Decl nodes over to ScopedDecls, so that they can
live in the appropriate top-level or transparent DeclContext near the
top level, e.g., TranslationUnitDecl or LinkageSpecDecl. Objective-C
declarations now show up in a traversal of the declarations in a
DeclContext (they didn't before!). This way, the rewriter finds all
Objective-C declarations within linkage specifications.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61966 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-09 00:49:46 +00:00
Fariborz Jahanian 439c65892c Adding support for ObjC methods which have c-style
parameter list. This is work in progress.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61964 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-09 00:38:19 +00:00
Douglas Gregor b3eef68111 Revert my previous, failed attempt to pretty-print anonymous struct/union accesses well. Added a FIXME so we know to revisit this later
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61951 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-08 22:45:41 +00:00
Douglas Gregor 25553512a5 Remove double-insertion of EnumConstantDecls. Thanks to Zhongxing Xu for pointing this out
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61942 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-08 20:48:26 +00:00
Douglas Gregor 72de6676bd 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



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61940 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-08 20:45:30 +00:00