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

133 Коммитов

Автор SHA1 Сообщение Дата
Anders Carlsson 771d7c3743 Remove some unused code from an experiment that I didn't like.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@75315 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-10 23:48:10 +00:00
Steve Naroff 14108da7f7 This patch includes a conceptually simple, but very intrusive/pervasive change.
The idea is to segregate Objective-C "object" pointers from general C pointers (utilizing the recently added ObjCObjectPointerType). The fun starts in Sema::GetTypeForDeclarator(), where "SomeInterface *" is now represented by a single AST node (rather than a PointerType whose Pointee is an ObjCInterfaceType). Since a significant amount of code assumed ObjC object pointers where based on C pointers/structs, this patch is very tedious. It should also explain why it is hard to accomplish this in smaller, self-contained patches.

This patch does most of the "heavy lifting" related to moving from PointerType->ObjCObjectPointerType. It doesn't include all potential "cleanups". The good news is additional cleanups can be done later (some are noted in the code). This patch is so large that I didn't want to include any changes that are purely aesthetic.

By making the ObjC types truly built-in, they are much easier to work with (and require fewer "hacks"). For example, there is no need for ASTContext::isObjCIdStructType() or ASTContext::isObjCClassStructType()! We believe this change (and the follow-up cleanups) will pay dividends over time. 

Given the amount of code change, I do expect some fallout from this change (though it does pass all of the clang tests). If you notice any problems, please let us know asap! Thanks.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@75314 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-10 23:34:53 +00:00
Anders Carlsson 3292d5ce51 Some (most) type trait expressions require that the argument passed in is a complete type.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74937 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-07 19:06:02 +00:00
Argyrios Kyrtzidis 17945a0f64 De-ASTContext-ify DeclContext.
Remove ASTContext parameter from DeclContext's methods. This change cascaded down to other Decl's methods and changes to call sites started "escalating".
Timings using pre-tokenized "cocoa.h" showed only a ~1% increase in time run between and after this commit.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74506 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-30 02:36:12 +00:00
Fariborz Jahanian f8d736ca54 Renamed MarcDestructorReferenced -> MarkDestructorReferenced
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74386 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-27 15:05:11 +00:00
Fariborz Jahanian 8d2b35630d Patch to mark destructors when they are used.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74359 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-26 23:49:16 +00:00
Douglas Gregor 2e01cdacc5 Eliminate DeclPtrTy() arguments to ActOnDeclarator that are just a very, very weird way to pass "false". No functionality change
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74007 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-23 21:43:56 +00:00
Douglas Gregor ac7610dad6 Rework the way we track which declarations are "used" during
compilation, and (hopefully) introduce RAII objects for changing the
"potentially evaluated" state at all of the necessary places within
Sema and Parser. Other changes:

  - Set the unevaluated/potentially-evaluated context appropriately
    during template instantiation.
  - We now recognize three different states while parsing or
    instantiating expressions: unevaluated, potentially evaluated, and
    potentially potentially evaluated (for C++'s typeid).
  - When we're in a potentially potentially-evaluated context, queue
    up MarkDeclarationReferenced calls in a stack. For C++ typeid
    expressions that are potentially evaluated, we will play back
    these MarkDeclarationReferenced calls when we exit the
    corresponding potentially potentially-evaluated context.
  - Non-type template arguments are now parsed as constant
    expressions, so they are not potentially-evaluated.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73899 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-22 20:57:11 +00:00
Douglas Gregor e0762c9211 Keep track of when declarations are "used" according to C and
C++. This logic is required to trigger implicit instantiation of
function templates and member functions of class templates, which will
be implemented separately.

This commit includes support for -Wunused-parameter, printing warnings
for named parameters that are not used within a function/Objective-C
method/block. Fixes <rdar://problem/6505209>.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73797 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-19 23:52:42 +00:00
Anders Carlsson f54741e646 Handle temporaries in default arguments.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73462 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-16 03:37:31 +00:00
Anders Carlsson 99ba36de0d Improvements to CXXExprWithTemporaries in preparation for fixing a bug with default arguments that have temporaries.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72944 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-05 15:38:08 +00:00
Anders Carlsson d958389d52 Make sure to copy back arguments that can be changed by FindAllocationOverload. This fixes placement new. (Sebastian, please review).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72673 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-31 20:26:12 +00:00
Anders Carlsson fc27d268cb Fix an off by one error when trying to perform copy initialization of operator new and operator delete arguments. Sebastian, please review.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72670 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-31 19:49:47 +00:00
Anders Carlsson 75bbb97f6e Forgot the implementation. Thanks Eli.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72647 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-30 22:51:20 +00:00
Anders Carlsson 88eaf075c5 Clean up the newly added C++ AST nodes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72643 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-30 22:38:53 +00:00
Anders Carlsson a19e66d448 It's OK for a full expr to be null. This fixes the failing test cases.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72642 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-30 22:24:16 +00:00
Anders Carlsson f5dcd38858 AddInitializerToDecl needs to take a full expression.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72640 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-30 21:37:25 +00:00
Anders Carlsson 860306ee30 Add the newly created temporary to the ExprTemporaries stack.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72638 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-30 21:21:49 +00:00
Anders Carlsson ff6b3d64c9 Stop using CXXTempVarDecl and use CXXTemporary instead.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72634 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-30 21:05:25 +00:00
Anders Carlsson 8e587a15da Remove VarDecl from CXXConstructExpr.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72633 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-30 20:56:46 +00:00
Anders Carlsson def11996fb Add Sema::MaybeBindToTemporary which takes an expression and (if needed) wraps it in a CXXBindTemporaryExpr. Use this when creating CXXTemporaryObjectExprs.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72629 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-30 20:36:53 +00:00
Douglas Gregor 3433cf7dfd Template instantiation for C++ "new" expressions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72199 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-21 00:00:09 +00:00
Douglas Gregor d81e6ca6e3 Introduce a new expression type, CXXUnresolvedConstructExpr, to
describe the construction of a value of a given type using function
syntax, e.g.,
  
  T(a1, a2, ..., aN)

when the type or any of its arguments are type-dependent. In this
case, we don't know what kind of type-construction this will be: it
might construct a temporary of type 'T' (which might be a class or
non-class type) or might perform a conversion to type 'T'. Also,
implement printing of and template instantiation for this new
expression type. Due to the change in Sema::ActOnCXXTypeConstructExpr,
our existing tests cover template instantiation of this new expression
node.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72176 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-20 18:46:25 +00:00
Anders Carlsson 7c3e8a1ddb Create CXXConstructExpr calls for arguments passed to functions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72102 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-19 04:45:15 +00:00
Anders Carlsson bde2008586 Fix instantiate-function-1.cpp.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71988 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-17 19:43:12 +00:00
Anders Carlsson 165a0a07c0 Implement Sema::ActOnFinishFullExpr and create a CXXExprWithTemporaries node if necessary.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71983 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-17 18:41:29 +00:00
Mike Stump 390b4cc8b4 Reflow some comments.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71936 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-16 07:39:55 +00:00
Sebastian Redl 9afe1308ed When there are any member new operators, global versions aren't looked up at all.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71780 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-14 18:11:41 +00:00
Douglas Gregor 3f5b61c394 Implement explicit instantiations of member classes of class templates, e.g.,
template<typename T>
  struct X {
    struct Inner;
  };

  template struct X<int>::Inner;

This change is larger than it looks because it also fixes some
a problem with nested-name-specifiers and tags. We weren't requiring
the DeclContext associated with the scope specifier of a tag to be
complete. Therefore, when looking for something like "struct
X<int>::Inner", we weren't instantiating X<int>. 

This, naturally, uncovered a problem with member pointers, where we
were requiring the left-hand side of a member pointer access
expression (e.g., x->*) to be a complete type. However, this is wrong:
the semantics of this expression does not require a complete type (EDG
agrees).

Stuart vouched for me. Blame him.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71756 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-14 00:28:11 +00:00
Sebastian Redl 6e8ed16ffe Implement C++0x nullptr.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71405 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-10 18:38:11 +00:00
Sebastian Redl 4f149632ed Fix a FIXME in new expression checking.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71163 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-07 16:14:23 +00:00
Douglas Gregor de866f3d4d Turns out that Sebastian already implemented the logic to compute the
composite pointer type, and his is better! Updated relational- and
equality-operator checking accordingly.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70963 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-05 04:50:50 +00:00
Douglas Gregor 0c6db9417d Implement support for comparing pointers with <, >, <=, >=, ==, and !=
in C++, taking into account conversions to the "composite pointer
type" so that we can compare, e.g., a pointer to a derived class to a
pointer to a base class. 

Also, upgrade the "comparing distinct pointer types" from a warning to
an error for C++, since this is clearly an error. Turns out that we
hadn't gone through and audited this code for C++, ever. 

Fixes <rdar://problem/6816420>.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70829 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-04 06:07:12 +00:00
Sebastian Redl 972041f45b Improve validation of C++ exception handling: diagnose throwing incomplete types and jumps into protected try-catch scopes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70242 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-27 20:27:31 +00:00
Sebastian Redl a5cd2cdd11 Make reference class unification in conditional expressions check for validity of the conversion.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70121 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-26 11:21:02 +00:00
Chris Lattner eaaebc7cf1 This is a pretty big cleanup for how invalid decl/type are handle.
This gets rid of a bunch of random InvalidDecl bools in sema, changing
us to use the following approach:

1. When analyzing a declspec or declarator, if an error is found, we 
   set a bit in Declarator saying that it is invalid.
2. Once the Decl is created by sema, we immediately set the isInvalid
   bit on it from what is in the declarator.  From this point on, sema
   consistently looks at and sets the bit on the decl.

This gives a very clear separation of concerns and simplifies a bunch
of code.  In addition to this, this patch makes these changes:

1. it renames DeclSpec::getInvalidType() -> isInvalidType().
2. various "merge" functions no longer return bools: they just set the
   invalid bit on the dest decl if invalid.
3. The ActOnTypedefDeclarator/ActOnFunctionDeclarator/ActOnVariableDeclarator
   methods now set invalid on the decl returned instead of returning an
   invalid bit byref.
4. In SemaType, refering to a typedef that was invalid now propagates the
   bit into the resultant type.  Stuff declared with the invalid typedef
   will now be marked invalid.
5. Various methods like CheckVariableDeclaration now return void and set the
   invalid bit on the decl they check.


There are a few minor changes to tests with this, but the only major bad
result is test/SemaCXX/constructor-recovery.cpp.  I'll take a look at this
next.




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70020 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-25 08:06:05 +00:00
Anders Carlsson 09c4abb105 Add an ASTContext parameter to CXXTemporaryObjectExpr.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69959 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-24 05:44:25 +00:00
Anders Carlsson 26de54983e Add a VarDecl parameter to the CXXTemporaryObjectExpr constructor. It's unused for now, so no functionality change yet. Also, create CXXTempVarDecls to pass to the CXXTemporaryObjectExpr ctor.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69957 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-24 05:23:13 +00:00
Sebastian Redl 78eb874222 Conditional operator C++ checking complete. What issues remain are in more general code.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69555 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-19 21:53:20 +00:00
Sebastian Redl 9bebfadb80 Bring member pointer operands of the conditional operator to a common type. We're getting there ...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69548 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-19 21:15:26 +00:00
Sebastian Redl d1bd7fc4cd Another piece of the conditional operator puzzle. We'll want to use FindCompositePointerType in some other places, too.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69534 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-19 19:26:31 +00:00
Sebastian Redl 76458501a8 Implement lvalue test for conditional expressions.
Add a few commented lines to the test case that point out things that don't work yet.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69354 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-17 16:30:52 +00:00
Sebastian Redl 3201f6beec 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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69299 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-16 17:51:27 +00:00
Sebastian Redl e2b6833d44 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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68902 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-12 17:16:29 +00:00
Douglas Gregor 6ab3524f72 Propagate the ASTContext to various AST traversal and lookup functions.
No functionality change (really).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68726 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-09 21:40:53 +00:00
Chris Lattner b28317a8e5 Introduce a new OpaquePtr<N> struct type, which is a simple POD wrapper for a
pointer.  Its purpose in life is to be a glorified void*, but which does not
implicitly convert to void* or other OpaquePtr's with a different UID.

Introduce Action::DeclPtrTy which is a typedef for OpaquePtr<0>.  Change the 
entire parser/sema interface to use DeclPtrTy instead of DeclTy*.  This
makes the C++ compiler enforce that these aren't convertible to other opaque
types.

We should also convert ExprTy, StmtTy, TypeTy, AttrTy, BaseTy, etc,
but I don't plan to do that in the short term.

The one outstanding known problem with this patch is that we lose the 
bitmangling optimization where ActionResult<DeclPtrTy> doesn't know how to
bitmangle the success bit into the low bit of DeclPtrTy.  I will rectify
this with a subsequent patch.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67952 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-28 19:18:32 +00:00
Douglas Gregor 8dcb29db84 Fix a few isObjectTypes that really need to be isIncompleteOrObject
types; add another use of RequireCompleteType.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67644 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-24 20:13:58 +00:00
Douglas Gregor e7450f5dbd Make sure to use RequireCompleteType rather than testing for
incomplete types. RequireCompleteType is needed when the type may be
completed by instantiating a template.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67643 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-24 19:52:54 +00:00
Anders Carlsson 8211effbd3 More work on diagnosing abstract classes. We can now handle cases like
class C {
  void g(C c);

  virtual void f() = 0;
};

In this case, C is not known to be abstract when doing semantic analysis on g. This is done by recursively traversing the abstract class and checking the types of member functions. 



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67594 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-24 01:19:16 +00:00
Anders Carlsson 11f21a08cd More improvements to abstract type checking. Handle arrays correctly, and make sure to check parameter types before they decay.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67550 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-23 19:10:31 +00:00