summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExprCXX.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Re-fix r136172 so it isn't an error; apparently, some people are fond of ↵Eli Friedman2011-07-261-16/+13
| | | | | | their undefined behavior. llvm-svn: 136183
* Diagnose trying to delete a pointer to an abstract class with a non-virtual ↵Eli Friedman2011-07-261-1/+13
| | | | | | | | destructor. PR10504. I'm not completely sure the standard allows us to reject this, but if it doesn't, it should. :) llvm-svn: 136172
* A couple minor issues with Sema for delete:Eli Friedman2011-07-261-22/+28
| | | | | | | | | 1. Attempting to delete an expression of incomplete class type should be an error, not a warning. 2. If someone tries to delete a pointer to an incomplete class type, make sure we actually emit the delete expression after we warn. llvm-svn: 136161
* remove unneeded llvm:: namespace qualifiers on some core types now that ↵Chris Lattner2011-07-231-10/+10
| | | | | | | | LLVM.h imports them into the clang namespace. llvm-svn: 135852
* Enforce access control for the destructor in a new[] expression and markJohn McCall2011-07-131-1/+11
| | | | | | | it as used. Otherwise, we can fail to instantiate or validate the destructor, which can lead to crashes in IR gen like PR10351. llvm-svn: 135073
* objc++-arc: more diagnosis of converting a weak-unavailableFariborz Jahanian2011-07-081-2/+14
| | | | | | object to a __weak object type. // rdar://9732636 llvm-svn: 134706
* In ARC, reclaim all return values of retainable type, not just thoseJohn McCall2011-07-071-7/+6
| | | | | | | | | | | | where we have an immediate need of a retained value. As an exception, don't do this when the call is made as the immediate operand of a __bridge retain. This is more in the way of a workaround than an actual guarantee, so it's acceptable to be brittle here. rdar://problem/9504800 llvm-svn: 134605
* Properly implement the scope restriction on the NRVO forDouglas Gregor2011-07-061-10/+64
| | | | | | | | | | | | throw-expressions, such that we don't consider the NRVO when the non-volatile automatic object comes from outside the innermost try scope (C++0x [class.copymove]p13). In C++98/03, our ASTs were incorrect but it didn't matter because IR generation doesn't actually apply the NRVO here. In C++0x, however, we were moving from an object when in fact we should have copied from it. Fixes PR10142 / <rdar://problem/9714312>. llvm-svn: 134548
* Perform lvalue-to-rvalue conversions on both operands of ->*John McCall2011-06-301-0/+14
| | | | | | and the RHS of .*. Noticed by Enea Zaffanella! llvm-svn: 134170
* Introduce Declarator::CXXNewContext and remove 'AutoAllowedInTypeName' parameterArgyrios Kyrtzidis2011-06-281-2/+1
| | | | | | from Sema::GetTypeForDeclarator. No functionality change. llvm-svn: 133987
* Centralize all checks for a C++ tag definition inside a typename inArgyrios Kyrtzidis2011-06-281-1/+1
| | | | | | | | Sema::GetTypeForDeclarator and remove its 'OwnedDecl' out parameter. No functionality change. llvm-svn: 133986
* Fix PR10204 in a better way.John McCall2011-06-271-1/+10
| | | | llvm-svn: 133943
* Rename objc_lifetime -> objc_ownership, and modify diagnostics to talk about ↵Argyrios Kyrtzidis2011-06-241-1/+1
| | | | | | | | 'ownership', not 'lifetime'. rdar://9477613. llvm-svn: 133779
* Fix Sema::CheckVectorOperands so that it doesn't try to insert a cast ↵Eli Friedman2011-06-231-1/+1
| | | | | | | | expression into the LHS of a compound assignment. Fixes compound assignment of various "compatible" vector types, including NEON-vector and gcc-vector types. <rdar://problem/9640356> llvm-svn: 133737
* Automatic Reference Counting.John McCall2011-06-151-70/+238
| | | | | | | | | | Language-design credit goes to a lot of people, but I particularly want to single out Blaine Garst and Patrick Beard for their contributions. Compiler implementation credit goes to Argyrios, Doug, Fariborz, and myself, in no particular order. llvm-svn: 133103
* Implement support for C++11 in-class initialization of non-static data members.Richard Smith2011-06-111-30/+43
| | | | llvm-svn: 132878
* Fix order of operands for the warning about incompatible Objective-CDouglas Gregor2011-06-111-1/+1
| | | | | | | pointer assignment in C++. This was a longstanding problem spotted by Jordy Rose. llvm-svn: 132873
* Implement Objective-C Related Result Type semantics.Douglas Gregor2011-06-111-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Related result types apply Cocoa conventions to the type of message sends and property accesses to Objective-C methods that are known to always return objects whose type is the same as the type of the receiving class (or a subclass thereof), such as +alloc and -init. This tightens up static type safety for Objective-C, so that we now diagnose mistakes like this: t.m:4:10: warning: incompatible pointer types initializing 'NSSet *' with an expression of type 'NSArray *' [-Wincompatible-pointer-types] NSSet *array = [[NSArray alloc] init]; ^ ~~~~~~~~~~~~~~~~~~~~~~ /System/Library/Frameworks/Foundation.framework/Headers/NSObject.h:72:1: note: instance method 'init' is assumed to return an instance of its receiver type ('NSArray *') - (id)init; ^ It also means that we get decent type inference when writing code in Objective-C++0x: auto array = [[NSMutableArray alloc] initWithObjects:@"one", @"two",nil]; // ^ now infers NSMutableArray* rather than id llvm-svn: 132868
* Fix a bunch more notes that were emitted even when the diagnostic theyChandler Carruth2011-06-081-6/+9
| | | | | | were intended for was suppressed. llvm-svn: 132746
* Remove all references to InitializationSequence::FailedSequence from outside ↵Sebastian Redl2011-06-051-3/+3
| | | | | | SemaInit.cpp. Replace them with the boolean conversion or the new Failed() function. This is a first step towards removing InitializationSequence::SequenceKind. No functionality change. llvm-svn: 132664
* Add new warning that warns when invoking 'delete' on a polymorphic, ↵Argyrios Kyrtzidis2011-05-241-0/+14
| | | | | | | | non-final, class without a virtual destructor. Patch by Matthieu Monrocq! llvm-svn: 131989
* The array-size operand to a new-expression is not necessarily a size_t.John McCall2011-05-151-2/+2
| | | | | | | It can be larger, it can be smaller, it can be signed, whatever. Handle all the crazy cases with grace and spirit. llvm-svn: 131378
* Implement the __is_trivially_copyable type traitAlexis Hunt2011-05-131-0/+3
| | | | llvm-svn: 131270
* Implement defaulting of destructors.Alexis Hunt2011-05-121-23/+39
| | | | llvm-svn: 131260
* HrmAlexis Hunt2011-05-121-18/+21
| | | | llvm-svn: 131259
* Rename "hasTrivialConstructor" to "hasTrivialDefaultConstructor" andAlexis Hunt2011-05-091-4/+4
| | | | | | | modify the semantics slightly to accomodate default constructors (I hope). llvm-svn: 131087
* Look at all the record redeclaration when looking for a uuid attribute.Francois Pichet2011-05-081-4/+5
| | | | llvm-svn: 131066
* Add support for Microsoft __if_exists and __if_not_exists construct inside ↵Francois Pichet2011-05-061-0/+15
| | | | | | | | | | | | function definition. Allow to include or exclude code depending on if a symbol exists or not. Just like a #ifdef but for C/C++ symbols. More doc: http://msdn.microsoft.com/en-us/library/x7wy9xh3(v=VS.100).aspx Support at class and namespace scopes will be added later. llvm-svn: 131014
* Remove a stale comment, it no longer applied after my cleanups.Chandler Carruth2011-05-011-8/+5
| | | | | | | Also fix several misspellings in my comments. I cannot spell, and cannot even be trusted to ask my editor how to spell apparently. llvm-svn: 130662
* Move several more type traits' implementations into the AST. A few wereChandler Carruth2011-05-011-12/+6
| | | | | | already present in the AST, and I added the ones that weren't. llvm-svn: 130655
* Switch __is_scalar to use the isScalarType predicate rather thanChandler Carruth2011-05-011-6/+1
| | | | | | duplicating its logic. llvm-svn: 130654
* Have the array type traits build an expression with type 'size_t'Chandler Carruth2011-05-011-1/+8
| | | | | | | | | | instead of 'int'. The Embarcadero spec says 'unsigned int', not 'int'. That's what 'size_t' is on Windows, but for Clang using a 'size_t' that can be larger than int seems more appropriate. llvm-svn: 130653
* Remove an inapplicable and completely out of place comment. The type is in ↵Chandler Carruth2011-05-011-1/+1
| | | | | | fact 'bool'. llvm-svn: 130652
* Remove more dead code for emitting diagnostics. The callers of theseChandler Carruth2011-05-011-17/+8
| | | | | | | | | | | | | functions already precluded dependent types from reaching them. Also change one of the callers to not error when a trait is applied to a dependent type. This is a perfectly reasonable pattern, and both Unary and Binary type traits already support dependent types (by populating the AST with a nonce value). Remove the actual diagnostic, since these aren't errors. llvm-svn: 130651
* Simplify the flow of some of the array type trait code.Chandler Carruth2011-05-011-13/+4
| | | | | | Completely remove a switch which selected between the same two types. llvm-svn: 130649
* Convert the expression trait evaluation to a static function andChandler Carruth2011-05-011-20/+19
| | | | | | | | | a switch with any default case. This both warns when an enumerator is missing and asserts if a value sneaks through despite the warning. While in there fix a bunch of coding style issues with this code. llvm-svn: 130648
* Remove the default case from the unary type trait evaluation function,Chandler Carruth2011-05-011-2/+1
| | | | | | | adding an unreachable annotation. Remarkably this one was already enumarting every trait. llvm-svn: 130647
* Mark that this function ends in a covering switch statement with everyChandler Carruth2011-05-011-0/+2
| | | | | | | | case returning a value. Silences a GCC warning. llvm-svn: 130644
* Remove the type traits UTT_IsLvalueExpr and UTT_IsRvalueExpr.Chandler Carruth2011-05-011-5/+0
| | | | | | | | | | | As might be surmised from their names, these aren't type traits, they're expression traits. Amazingly enough, they're expression traits that we have, and fully implement. These "type" traits are even parsed from the same tokens as the expression traits. Luckily, the parser only tried the expression trait parsing for these tokens, so this was all just a pile of dead code. llvm-svn: 130643
* More cleanup of the type traits implementation.Chandler Carruth2011-05-011-81/+110
| | | | | | | | | | | | | | | | | | | | 1) Moved the completeness checking routine above the evaluation routine so the reader sees that we do in fact check for complete types when necessary. 2) Remove the FIXME comment about not doing this. 3) Make the arguments to the evaluate function agree in order with those to the completeness checking function. 4) Completely specify the enumerators for the completeness checking function rather than relying on a default. 5) Remove a check for the Borland language to only require complete types in a few places. Borland's own documentation doesn't agree with this: some of the previously unspecified traits *do* require a complete type, some don't. 6) Correctly split the traits which do not require complete types from those that do, clarifying comments and citations to the standard or other documentation where relevant. llvm-svn: 130641
* Order the type traits according to the standard's listing of unary typeChandler Carruth2011-05-011-54/+79
| | | | | | | | | traits where possible. For the rest, group them and add some documentation regarding their origins. No functionality change intended. llvm-svn: 130639
* Begin cleaning up type trait expression implementations and settling onChandler Carruth2011-05-011-21/+21
| | | | | | a single pattern for implementing each. llvm-svn: 130638
* Extract a function to impose the completeness requirement on unary typeChandler Carruth2011-04-301-23/+76
| | | | | | | | | | | | | | | | | | | | | | trait arguments. Reflow the logic to use early exit instead of a complex condition expression. Switch to a switch for acting on different type traits and add a bunch of the recently implemented type traits here. This fixes one of the regressions with the new __is_standard_layout trait to again require a complete type. It also fixes some latent bugs in other traits that never did impose this despite the standard requiring it. However, all these bugs were hidden for non-borland systems where the default is to require a complete type. It's unclear to me what the best approach here is: providing an explicit lists for the ones requiring complete types only w/ Borland and using a default for the rest, or forcing this switch to enumerate the traits and make it clear which way each one goes. I'm still working on cleaning up the tests so that they actually catch this, a much more comprehensive update to the tests will come once I've worked through the bugs I'm finding via inspection. llvm-svn: 130604
* Hoist all of the type-specific trait logic for __is_standard_layout intoChandler Carruth2011-04-301-16/+1
| | | | | | | | | | | | a Type method isStandardLayoutType, to keep our user API matching the type trait builtins as closely as possible. Also, implement it in terms of other Type APIs rather than in terms of other type traits. This models the implementation on that of isLiteralType and isTrivialType. There remain some common problems with these traits still, so this is a bit of a WIP. However, we can now fix all of these traits at the same time and in a consistent manner. llvm-svn: 130602
* Completely re-implement the core logic behind the __is_standard_layoutChandler Carruth2011-04-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | type trait. The previous implementation suffered from several problems: 1) It implemented all of the logic in RecordType by walking over every base and field in a CXXRecordDecl and validating the constraints of the standard. This made for very straightforward code, but is extremely inefficient. It also is conceptually wrong, the logic tied to the C++ definition of standard-layout classes should be in CXXRecordDecl, not RecordType. 2) To address the performance problems with #1, a cache bit was added to CXXRecordDecl, and at the completion of every C++ class, the RecordType was queried to determine if it was a standard layout class, and that state was cached. Two things went very very wrong with this. First, the caching version of the query *was never called*. Even within the recursive steps of the walk over all fields and bases the caching variant was not called, making each query a full *recursive* walk. Second, despite the cache not being used, it was computed for every class declared, even when the trait was never used in the program. This probably significantly regressed compile time performance for edge-case files. 3) An ASTContext was required merely to query the type trait because querying it performed the actual computations. 4) The caching bit wasn't managed correctly (uninitialized). The new implementation follows the system for all the other traits on C++ classes by encoding all the state needed in the definition data and building up the trait incrementally as each base and member are added to the definition of the class. The idiosyncracies of the specification of standard-layout classes requires more state than I would like; currently 5 bits. I could eliminate one of the bits easily at the expense of both clarity and resilience of the code. I might be able to eliminate one of the other bits by computing its state in terms of other state bits in the definition. I've already done that in one place where there was a fairly simple way to achieve it. It's possible some of the bits could be moved out of the definition data and into some other structure which isn't serialized if the serialized bloat is a problem. That would preclude serialization of a partial class declaration, but that's likely already precluded. Comments on any of these issues welcome. llvm-svn: 130601
* A few corrections to type traits that missed the last checkinJohn Wiegley2011-04-281-19/+46
| | | | llvm-svn: 130371
* Implementation of Embarcadero array type traitsJohn Wiegley2011-04-281-0/+88
| | | | | | | | | | Patch authored by John Wiegley. These are array type traits used for parsing code that employs certain features of the Embarcadero C++ compiler: __array_rank(T) and __array_extent(T, Dim). llvm-svn: 130351
* t/clang/type-traitsJohn Wiegley2011-04-271-4/+77
| | | | | | | | | | Patch authored by John Wiegley. These type traits are used for parsing code that employs certain features of the Embarcadero C++ compiler. Several of these constructs are also desired by libc++, according to its project pages (such as __is_standard_layout). llvm-svn: 130342
* Make yet another placeholder type, this one marking that an expression is a ↵John McCall2011-04-261-10/+5
| | | | | | | | | | | bound member function, i.e. something of the form 'x.f' where 'f' is a non-static member function. Diagnose this in the general case. Some of the new diagnostics are probably worse than the old ones, but we now get this right much more universally, and there's certainly room for improvement in the diagnostics. llvm-svn: 130239
* t/clang/expr-traitsJohn Wiegley2011-04-251-0/+39
| | | | | | | | | Patch authored by David Abrahams. These two expression traits (__is_lvalue_expr, __is_rvalue_expr) are used for parsing code that employs certain features of the Embarcadero C++ compiler. llvm-svn: 130122
OpenPOWER on IntegriCloud