summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExprCXX.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
* Implement basic __is_trivial type-trait support, enough to close PR9472.Chandler Carruth2011-04-231-0/+1
| | | | | | | | | | | | | | | | | | This introduces a few APIs on the AST to bundle up the standard-based logic so that programmatic clients have access to exactly the same behavior. There is only one serious FIXME here: checking for non-trivial move constructors and move assignment operators. Those bits need to be added to the declaration and accessors provided. This implementation should be enough for the uses of __is_trivial in libstdc++ 4.6's C++98 library implementation. Ideas for more thorough test cases or any edge cases missing would be appreciated. =D llvm-svn: 130057
* Forbid the use of C++ new/delete to allocate/free objects within anDouglas Gregor2011-04-151-2/+8
| | | | | | | | | | address space. I could see that this functionality would be useful, but not in its current form (where the address space is ignored): rather, we'd want to encode the address space into the parameter list passed to operator new/operator delete somehow, which would require a bunch more semantic analysis. llvm-svn: 129593
* Simplify calling CheckPlaceholderExpr, converge on it in a few places,John McCall2011-04-101-24/+3
| | | | | | and move a vector-splat check to follow l-value conversion. llvm-svn: 129254
* Use ExprResult& instead of Expr *& in SemaJohn Wiegley2011-04-081-233/+282
| | | | | | | | | | | | | | | | | | | | | | | | | This patch authored by Eric Niebler. Many methods on the Sema class (e.g. ConvertPropertyForRValue) take Expr pointers as in/out parameters (Expr *&). This is especially true for the routines that apply implicit conversions to nodes in-place. This design is workable only as long as those conversions cannot fail. If they are allowed to fail, they need a way to report their failures. The typical way of doing this in clang is to use an ExprResult, which has an extra bit to signal a valid/invalid state. Returning ExprResult is de riguour elsewhere in the Sema interface. We suggest changing the Expr *& parameters in the Sema interface to ExprResult &. This increases interface consistency and maintainability. This interface change is important for work supporting MS-style C++ properties. For reasons explained here <http://lists.cs.uiuc.edu/pipermail/cfe-dev/2011-February/013180.html>, seemingly trivial operations like rvalue/lvalue conversions that formerly could not fail now can. (The reason is that given the semantics of the feature, getter/setter method lookup cannot happen until the point of use, at which point it may be found that the method does not exist, or it may have the wrong type, or overload resolution may fail, or it may be inaccessible.) llvm-svn: 129143
* In C++ the argument of logical not should always be bool. Added missing ↵Abramo Bagnara2011-04-071-13/+3
| | | | | | implicit cast for scalars. llvm-svn: 129066
* Make ChainedIncludesSource an ExternalSemaSource, otherwise initialization ↵Sebastian Redl2011-03-311-1/+1
| | | | | | of the ASTReader is incomplete, leading to errors like not realizing std::type_info is already defined. llvm-svn: 128664
* Support for Transparent unions used as overloadableFariborz Jahanian2011-03-231-0/+9
| | | | | | | function parameter. // rdar:// 9129552 and PR9406. llvm-svn: 128159
* Implement a new 'availability' attribute, that allows one to specifyDouglas Gregor2011-03-231-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | which versions of an OS provide a certain facility. For example, void foo() __attribute__((availability(macosx,introduced=10.2,deprecated=10.4,obsoleted=10.6))); says that the function "foo" was introduced in 10.2, deprecated in 10.4, and completely obsoleted in 10.6. This attribute ties in with the deployment targets (e.g., -mmacosx-version-min=10.1 specifies that we want to deploy back to Mac OS X 10.1). There are several concrete behaviors that this attribute enables, as illustrated with the function foo() above: - If we choose a deployment target >= Mac OS X 10.4, uses of "foo" will result in a deprecation warning, as if we had placed attribute((deprecated)) on it (but with a better diagnostic) - If we choose a deployment target >= Mac OS X 10.6, uses of "foo" will result in an "unavailable" warning (in C)/error (in C++), as if we had placed attribute((unavailable)) on it - If we choose a deployment target prior to 10.2, foo() is weak-imported (if it is a kind of entity that can be weak imported), as if we had placed the weak_import attribute on it. Naturally, there can be multiple availability attributes on a declaration, for different platforms; only the current platform matters when checking availability attributes. The only platforms this attribute currently works for are "ios" and "macosx", since we already have -mxxxx-version-min flags for them and we have experience there with macro tricks translating down to the deprecated/unavailable/weak_import attributes. The end goal is to open this up to other platforms, and even extension to other "platforms" that are really libraries (say, through a #pragma clang define_system), but that hasn't yet been designed and we may want to shake out more issues with this narrower problem first. Addresses <rdar://problem/6690412>. As a drive-by bug-fix, if an entity is both deprecated and unavailable, we only emit the "unavailable" diagnostic. llvm-svn: 128127
OpenPOWER on IntegriCloud