summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExprCXX.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Introduce Type::isAnyPointerType() and convert all clients (suggested by Chris).Steve Naroff2009-07-141-2/+1
| | | | | | I don't love the name, however it simplifies the code and is a worthwhile change. If/when we come up with a better name, we can do a search/replace. llvm-svn: 75650
* Remove some unused code from an experiment that I didn't like.Anders Carlsson2009-07-101-41/+0
| | | | llvm-svn: 75315
* This patch includes a conceptually simple, but very intrusive/pervasive change. Steve Naroff2009-07-101-1/+2
| | | | | | | | | | | | 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. llvm-svn: 75314
* Some (most) type trait expressions require that the argument passed in is a ↵Anders Carlsson2009-07-071-7/+13
| | | | | | complete type. llvm-svn: 74937
* De-ASTContext-ify DeclContext.Argyrios Kyrtzidis2009-06-301-3/+3
| | | | | | | 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. llvm-svn: 74506
* Renamed MarcDestructorReferenced -> MarkDestructorReferencedFariborz Jahanian2009-06-271-1/+1
| | | | llvm-svn: 74386
* Patch to mark destructors when they are used.Fariborz Jahanian2009-06-261-1/+1
| | | | llvm-svn: 74359
* Eliminate DeclPtrTy() arguments to ActOnDeclarator that are just a very, ↵Douglas Gregor2009-06-231-1/+1
| | | | | | very weird way to pass "false". No functionality change llvm-svn: 74007
* Rework the way we track which declarations are "used" duringDouglas Gregor2009-06-221-0/+25
| | | | | | | | | | | | | | | | | | | | | 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. llvm-svn: 73899
* Keep track of when declarations are "used" according to C andDouglas Gregor2009-06-191-2/+2
| | | | | | | | | | | | 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>. llvm-svn: 73797
* Handle temporaries in default arguments.Anders Carlsson2009-06-161-3/+4
| | | | llvm-svn: 73462
* Improvements to CXXExprWithTemporaries in preparation for fixing a bug with ↵Anders Carlsson2009-06-051-8/+18
| | | | | | default arguments that have temporaries. llvm-svn: 72944
* Make sure to copy back arguments that can be changed by ↵Anders Carlsson2009-05-311-0/+5
| | | | | | FindAllocationOverload. This fixes placement new. (Sebastian, please review). llvm-svn: 72673
* Fix an off by one error when trying to perform copy initialization of ↵Anders Carlsson2009-05-311-1/+1
| | | | | | operator new and operator delete arguments. Sebastian, please review. llvm-svn: 72670
* Forgot the implementation. Thanks Eli.Anders Carlsson2009-05-301-0/+41
| | | | llvm-svn: 72647
* Clean up the newly added C++ AST nodes.Anders Carlsson2009-05-301-3/+3
| | | | llvm-svn: 72643
* It's OK for a full expr to be null. This fixes the failing test cases.Anders Carlsson2009-05-301-3/+2
| | | | llvm-svn: 72642
* AddInitializerToDecl needs to take a full expression.Anders Carlsson2009-05-301-1/+1
| | | | llvm-svn: 72640
* Add the newly created temporary to the ExprTemporaries stack.Anders Carlsson2009-05-301-1/+2
| | | | llvm-svn: 72638
* Stop using CXXTempVarDecl and use CXXTemporary instead.Anders Carlsson2009-05-301-4/+0
| | | | llvm-svn: 72634
* Remove VarDecl from CXXConstructExpr.Anders Carlsson2009-05-301-3/+2
| | | | llvm-svn: 72633
* Add Sema::MaybeBindToTemporary which takes an expression and (if needed) ↵Anders Carlsson2009-05-301-4/+21
| | | | | | wraps it in a CXXBindTemporaryExpr. Use this when creating CXXTemporaryObjectExprs. llvm-svn: 72629
* Template instantiation for C++ "new" expressions.Douglas Gregor2009-05-211-29/+57
| | | | llvm-svn: 72199
* Introduce a new expression type, CXXUnresolvedConstructExpr, toDouglas Gregor2009-05-201-8/+5
| | | | | | | | | | | | | | | | | | 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. llvm-svn: 72176
* Create CXXConstructExpr calls for arguments passed to functions.Anders Carlsson2009-05-191-3/+7
| | | | llvm-svn: 72102
* Fix instantiate-function-1.cpp.Anders Carlsson2009-05-171-1/+0
| | | | llvm-svn: 71988
* Implement Sema::ActOnFinishFullExpr and create a CXXExprWithTemporaries node ↵Anders Carlsson2009-05-171-2/+23
| | | | | | if necessary. llvm-svn: 71983
* Reflow some comments.Mike Stump2009-05-161-24/+22
| | | | llvm-svn: 71936
* When there are any member new operators, global versions aren't looked up at ↵Sebastian Redl2009-05-141-2/+0
| | | | | | all. llvm-svn: 71780
* Implement explicit instantiations of member classes of class templates, e.g.,Douglas Gregor2009-05-141-4/+1
| | | | | | | | | | | | | | | | | | | | | | | | | 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. llvm-svn: 71756
* Implement C++0x nullptr.Sebastian Redl2009-05-101-0/+6
| | | | llvm-svn: 71405
* Fix a FIXME in new expression checking.Sebastian Redl2009-05-071-5/+4
| | | | llvm-svn: 71163
* Turns out that Sebastian already implemented the logic to compute theDouglas Gregor2009-05-051-71/+0
| | | | | | | composite pointer type, and his is better! Updated relational- and equality-operator checking accordingly. llvm-svn: 70963
* Implement support for comparing pointers with <, >, <=, >=, ==, and !=Douglas Gregor2009-05-041-0/+71
| | | | | | | | | | | | | | 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>. llvm-svn: 70829
* Improve validation of C++ exception handling: diagnose throwing incomplete ↵Sebastian Redl2009-04-271-2/+31
| | | | | | types and jumps into protected try-catch scopes. llvm-svn: 70242
* Make reference class unification in conditional expressions check for ↵Sebastian Redl2009-04-261-6/+6
| | | | | | validity of the conversion. llvm-svn: 70121
* This is a pretty big cleanup for how invalid decl/type are handle.Chris Lattner2009-04-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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. llvm-svn: 70020
* Add an ASTContext parameter to CXXTemporaryObjectExpr.Anders Carlsson2009-04-241-2/+4
| | | | llvm-svn: 69959
* Add a VarDecl parameter to the CXXTemporaryObjectExpr constructor. It's ↵Anders Carlsson2009-04-241-2/+7
| | | | | | unused for now, so no functionality change yet. Also, create CXXTempVarDecls to pass to the CXXTemporaryObjectExpr ctor. llvm-svn: 69957
* Conditional operator C++ checking complete. What issues remain are in more ↵Sebastian Redl2009-04-191-0/+2
| | | | | | general code. llvm-svn: 69555
* Bring member pointer operands of the conditional operator to a common type. ↵Sebastian Redl2009-04-191-2/+55
| | | | | | We're getting there ... llvm-svn: 69548
* Another piece of the conditional operator puzzle. We'll want to use ↵Sebastian Redl2009-04-191-12/+92
| | | | | | FindCompositePointerType in some other places, too. llvm-svn: 69534
* Implement lvalue test for conditional expressions.Sebastian Redl2009-04-171-4/+31
| | | | | | Add a few commented lines to the test case that point out things that don't work yet. llvm-svn: 69354
* Fix a crash bug when comparing overload quality of conversion operators with ↵Sebastian Redl2009-04-161-0/+290
| | | | | | | | | | | 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
* Parse deleted member functions. Parsing member declarations goes through a ↵Sebastian Redl2009-04-121-5/+15
| | | | | | | | | 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. llvm-svn: 68902
* Propagate the ASTContext to various AST traversal and lookup functions.Douglas Gregor2009-04-091-3/+3
| | | | | | No functionality change (really). llvm-svn: 68726
* Introduce a new OpaquePtr<N> struct type, which is a simple POD wrapper for aChris Lattner2009-03-281-8/+10
| | | | | | | | | | | | | | | | | | | | 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. llvm-svn: 67952
* Fix a few isObjectTypes that really need to be isIncompleteOrObjectDouglas Gregor2009-03-241-5/+6
| | | | | | types; add another use of RequireCompleteType. llvm-svn: 67644
* Make sure to use RequireCompleteType rather than testing forDouglas Gregor2009-03-241-22/+19
| | | | | | | incomplete types. RequireCompleteType is needed when the type may be completed by instantiating a template. llvm-svn: 67643
* More work on diagnosing abstract classes. We can now handle cases likeAnders Carlsson2009-03-241-3/+3
| | | | | | | | | | | | 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. llvm-svn: 67594
OpenPOWER on IntegriCloud