summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/ExprClassification.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Change the AST representation of operations on Objective-CJohn McCall2011-11-061-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | property references to use a new PseudoObjectExpr expression which pairs a syntactic form of the expression with a set of semantic expressions implementing it. This should significantly reduce the complexity required elsewhere in the compiler to deal with these kinds of expressions (e.g. IR generation's special l-value kind, the static analyzer's Message abstraction), at the lower cost of specifically dealing with the odd AST structure of these expressions. It should also greatly simplify efforts to implement similar language features in the future, most notably Managed C++'s properties and indexed properties. Most of the effort here is in dealing with the various clients of the AST. I've gone ahead and simplified the ObjC rewriter's use of properties; other clients, like IR-gen and the static analyzer, have all the old complexity *and* all the new complexity, at least temporarily. Many thanks to Ted for writing and advising on the necessary changes to the static analyzer. I've xfailed a small diagnostics regression in the static analyzer at Ted's request. llvm-svn: 143867
* Macro metaprogramming for builtin types.John McCall2011-10-181-2/+4
| | | | llvm-svn: 142420
* Initial implementation of __atomic_* (everything except __atomic_is_lock_free).Eli Friedman2011-10-111-0/+1
| | | | llvm-svn: 141632
* Declare and define implicit move constructor and assignment operator.Sebastian Redl2011-08-301-1/+1
| | | | | | | | | This makes the code duplication of implicit special member handling even worse, but the cleanup will have to come later. For now, this works. Follow-up with tests for explicit defaulting and enabling the __has_feature flag to come. llvm-svn: 138821
* Create a new expression node, SubstNonTypeTemplateParmExpr,John McCall2011-07-151-0/+3
| | | | | | | | to represent a fully-substituted non-type template parameter. This should improve source fidelity, as well as being generically useful for diagnostics and such. llvm-svn: 135243
* Teach CXXUnresolvedConstructExpr when it should be anDouglas Gregor2011-07-081-1/+4
| | | | | | | lvalue/xvalue/rvalue, rather than just (incorrectly) assuming it's an lvalue. Fixes PR10285 / <rdar://problem/9743926>. llvm-svn: 134700
* A few tweaks to MaterializeTemporaryExpr suggested by John.Douglas Gregor2011-06-211-1/+1
| | | | llvm-svn: 133528
* Introduce a new AST node describing reference binding to temporaries.Douglas Gregor2011-06-211-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | MaterializeTemporaryExpr captures a reference binding to a temporary value, making explicit that the temporary value (a prvalue) needs to be materialized into memory so that its address can be used. The intended AST invariant here is that a reference will always bind to a glvalue, and MaterializeTemporaryExpr will be used to convert prvalues into glvalues for that binding to happen. For example, given const int& r = 1.0; The initializer of "r" will be a MaterializeTemporaryExpr whose subexpression is an implicit conversion from the double literal "1.0" to an integer value. IR generation benefits most from this new node, since it was previously guessing (badly) when to materialize temporaries for the purposes of reference binding. There are likely more refactoring and cleanups we could perform there, but the introduction of MaterializeTemporaryExpr fixes PR9565, a case where IR generation would effectively bind a const reference directly to a bitfield in a struct. Addresses <rdar://problem/9552231>. llvm-svn: 133521
* Automatic Reference Counting.John McCall2011-06-151-0/+2
| | | | | | | | | | 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
* Add support for builtin astype:Tanya Lattner2011-06-041-0/+1
| | | | | | | __builtin_astype(): Used to reinterpreted as another data type of the same size using for both scalar and vector data types. Added test case. llvm-svn: 132612
* Classify bound member function types are member function types. FixesDouglas Gregor2011-05-211-4/+6
| | | | | | PR9973 / <rdar://problem/9479191>. llvm-svn: 131810
* Implementation of Embarcadero array type traitsJohn Wiegley2011-04-281-0/+1
| | | | | | | | | | 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/expr-traitsJohn Wiegley2011-04-251-0/+1
| | | | | | | | | 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
* Add a new expression classification, CL_AddressableVoidPeter Collingbourne2011-04-191-4/+9
| | | | | | | | | CL_AddressableVoid is the expression classification used for void expressions whose address can be taken, i.e. the result of [], * or void variable references in C, as opposed to things like the result of a void function call. llvm-svn: 129783
* C1X: implement generic selectionsPeter Collingbourne2011-04-151-0/+8
| | | | | | | As an extension, generic selection support has been added for all supported languages. The syntax is the same as for C1X. llvm-svn: 129554
* After some discussion with Doug, we decided that it made a lot more senseJohn McCall2011-04-121-0/+7
| | | | | | | | | for __unknown_anytype resolution to destructively modify the AST. So that's what it does now, which significantly simplifies some of the implementation. Normal member calls work pretty cleanly now, and I added support for propagating unknown-ness through &. llvm-svn: 129331
* More coherent diagnostic attempting to assign to a member of a const object ↵Fariborz Jahanian2011-03-261-1/+5
| | | | | | | | returned from an objective-c message: // rdar://9005189 llvm-svn: 128348
* Add support for the OpenCL vec_step operator, by generalising andPeter Collingbourne2011-03-111-1/+1
| | | | | | | extending the existing support for sizeof and alignof. Original patch by Guy Benyei. llvm-svn: 127475
* Change the representation of GNU ?: expressions to use a different expressionJohn McCall2011-02-171-7/+14
| | | | | | | | | | | | | | | | | | | | | | class and to bind the shared value using OpaqueValueExpr. This fixes an unnoticed problem with deserialization of these expressions where the deserialized form would lose the vital pointer-equality trait; or rather, it fixes it because this patch also does the right thing for deserializing OVEs. Change OVEs to not be a "temporary object" in the sense that copy elision is permitted. This new representation is not totally unawkward to work with, but I think that's really part and parcel with the semantics we're modelling here. In particular, it's much easier to fix things like the copy elision bug and to make the CFG look right. I've tried to update the analyzer to deal with this in at least some obvious cases, and I think we get a much better CFG out, but the printing of OpaqueValueExprs probably needs some work. llvm-svn: 125744
* AST, Sema, Serialization: add CUDAKernelCallExpr and related semantic actionsPeter Collingbourne2011-02-091-0/+1
| | | | llvm-svn: 125217
* Remove vtables from the Stmt hierarchy; this was pretty easy asJohn McCall2011-02-091-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | there were only three virtual methods of any significance. The primary way to grab child iterators now is with Stmt::child_range children(); Stmt::const_child_range children() const; where a child_range is just a std::pair of iterators suitable for being llvm::tie'd to some locals. I've left the old child_begin() and child_end() accessors in place, but it's probably a substantial penalty to grab the iterators individually now, since the switch-based dispatch is kindof inherently slower than vtable dispatch. Grabbing them together is probably a slight win over the status quo, although of course we could've achieved that with vtables, too. I also reclassified SwitchCase (correctly) as an abstract Stmt class, which (as the first such class that wasn't an Expr subclass) required some fiddling in a few places. There are somewhat gross metaprogramming hooks in place to ensure that new statements/expressions continue to implement getSourceRange() and children(). I had to work around a recent clang bug; dgregor actually fixed it already, but I didn't want to introduce a selfhosting dependency on ToT. llvm-svn: 125183
* Introduce a new expression kind, SubstNonTypeTemplateParmPackExpr,Douglas Gregor2011-01-151-0/+1
| | | | | | | | | that captures the substitution of a non-type template argument pack for a non-type template parameter pack within a pack expansion that cannot be fully expanded. This follows the approach taken by SubstTemplateTypeParmPackType. llvm-svn: 123506
* Implement the sizeof...(pack) expression to compute the length of aDouglas Gregor2011-01-041-0/+1
| | | | | | | | | parameter pack. Note that we're missing proper libclang support for the new SizeOfPackExpr expression node. llvm-svn: 122813
* Implement support for pack expansions whose pattern is a non-typeDouglas Gregor2011-01-031-0/+3
| | | | | | | | | | | | | | | | | template argument (described by an expression, of course). For example: template<int...> struct int_tuple { }; template<int ...Values> struct square { typedef int_tuple<(Values*Values)...> type; }; It also lays the foundation for pack expansions in an initializer-list. llvm-svn: 122751
* Microsoft's __uuidof operator returns a lvalue.Francois Pichet2010-12-171-1/+1
| | | | llvm-svn: 122021
* Remove the TypesCompatibleExprClass AST node. Merge its functionality into ↵Francois Pichet2010-12-081-1/+0
| | | | | | BinaryTypeTraitExpr. llvm-svn: 121298
* Type traits intrinsic implementation: __is_base_of(T, U)Francois Pichet2010-12-071-0/+1
| | | | | | New AST node introduced: BinaryTypeTraitExpr; to be reused for more intrinsics. llvm-svn: 121074
* Rename CXXExprWithTemporaries -> ExprWithCleanups; there's no theoreticalJohn McCall2010-12-061-3/+3
| | | | | | reason this is limited to C++, and it's certainly not limited to temporaries. llvm-svn: 120996
* Clarify the logic for when to build an overloaded binop. In particular,John McCall2010-12-061-1/+1
| | | | | | | | | build one when either of the operands calls itself type-dependent; previously we were building when one of the operand types was dependent, which is not always the same thing and which can lead to unfortunate inconsistencies later. Fixes PR8739. llvm-svn: 120990
* Although we currently have explicit lvalue-to-rvalue conversions, they'reJohn McCall2010-12-041-4/+7
| | | | | | | | | | | | | | | | | | | not actually frequently used, because ImpCastExprToType only creates a node if the types differ. So explicitly create an ICE in the lvalue-to-rvalue conversion code in DefaultFunctionArrayLvalueConversion() as well as several other new places, and consistently deal with the consequences throughout the compiler. In addition, introduce a new cast kind for loading an ObjCProperty l-value, and make sure we emit those nodes whenever an ObjCProperty l-value appears that's not on the LHS of an assignment operator. This breaks a couple of rewriter tests, which I've x-failed until future development occurs on the rewriter. Ted Kremenek kindly contributed the analyzer workarounds in this patch. llvm-svn: 120890
* Simplify the ASTs by consolidating ObjCImplicitGetterSetterExpr and ↵John McCall2010-12-021-12/+6
| | | | | | | | ObjCPropertyRefExpr into the latter. llvm-svn: 120643
* Switch a lot of call-sites over to using the new value-kind calculations.John McCall2010-11-241-1/+1
| | | | llvm-svn: 120084
* A few tweaks to the value-kind computation:John McCall2010-11-231-2/+0
| | | | | | | | | | | | | - Default argument expressions pick up the value kind of the incoming expression, not the value kind of the parameter it initializes. - When building a template argument for substitution, A::x is an rvalue if x is an instance method. - Anonymous struct/union paths pick up value kind the same way that normal member accesses do; extract out a common code path for this. Enable the value-kind assertion, now that it passes self-host. llvm-svn: 120055
* Major anonymous union/struct redesign.Francois Pichet2010-11-211-0/+1
| | | | | | | | | | | A new AST node is introduced: def IndirectField : DDecl<Value>; IndirectFields are injected into the anonymous's parent scope and chain back to the original field. Name lookup for anonymous entities now result in an IndirectFieldDecl instead of a FieldDecl. There is no functionality change, the code generated should be the same. llvm-svn: 119919
* Add an assertion, fix a whole bunch of bugs, comment the assertionJohn McCall2010-11-181-0/+19
| | | | | | out because there are still bugs left. llvm-svn: 119722
* Calculate the value kind of an expression when it's created andJohn McCall2010-11-181-3/+1
| | | | | | | | | | | | | store it on the expression node. Also store an "object kind", which distinguishes ordinary "addressed" l-values (like variable references and pointer dereferences) and bitfield, @property, and vector-component l-values. Currently we're not using these for much, but I aim to switch pretty much everything calculating l-valueness over to them. For now they shouldn't necessarily be trusted. llvm-svn: 119685
* Simplify some complex emission and implement correct semantics forJohn McCall2010-11-161-3/+15
| | | | | | | | | assignment to volatiles in C. This in effect reverts some of mjs's work in and around r72572. Basically, the C++ standard is quite clear, except that it lies about volatile behavior approximating C's, whereas the C standard is almost actively misleading. llvm-svn: 119344
* Add a new expression kind, OpaqueValueExpr, which is useful forJohn McCall2010-11-151-10/+22
| | | | | | | certain internal type-checking procedures as well as for representing certain implicitly-generated operations. Uses to follow. llvm-svn: 119289
* Eliminate usage of ObjCSuperExpr used forFariborz Jahanian2010-10-141-1/+0
| | | | | | | 'super' as receiver of property or a setter/getter methods. //rdar: //8525788 llvm-svn: 116483
* Fix classification of statement expressions.Douglas Gregor2010-09-151-1/+1
| | | | llvm-svn: 113917
* RHS of property expression assignment requiresFariborz Jahanian2010-09-141-1/+2
| | | | | | | copy initialization before passing it to a setter. Fixes radar 8427922. llvm-svn: 113885
* Eliminate the default case in the expression-classification code, soDouglas Gregor2010-09-141-7/+65
| | | | | | | | that we're sure to keep it updated when new expression kinds emerge. Also fixes a few little bugs in the classification of expressions. llvm-svn: 113864
* property reference expression used on lhs of assignmentFariborz Jahanian2010-09-091-1/+2
| | | | | | | | follows objective's semantics and is not overload'able with an assignment operator. Fixes a crash and a missing diagnostics. Radar 8379892. llvm-svn: 113555
* Propagate whether an id-expression is the immediate argument ofJohn McCall2010-08-271-0/+4
| | | | | | | | | | | | | | | | | | | an '&' expression from the second caller of ActOnIdExpression. Teach template argument deduction that an overloaded id-expression doesn't give a valid type for deduction purposes to a non-static member function unless the expression has the correct syntactic form. Teach ActOnIdExpression that it shouldn't try to create implicit member expressions for '&function', because this isn't a permitted form of use for member functions. Teach CheckAddressOfOperand to diagnose these more carefully. Some of these cases aren't reachable right now because earlier diagnostics interrupt them. llvm-svn: 112258
* GCC didn't care for my attempt at API compatibility, so brute-force everythingJohn McCall2010-08-251-9/+9
| | | | | | to the new constants. llvm-svn: 112047
* More incremental progress towards not including Expr.h in Sema.h.John McCall2010-08-251-4/+4
| | | | llvm-svn: 112044
* Update ImplicitCastExpr to be able to represent an XValue.Sebastian Redl2010-07-201-3/+9
| | | | llvm-svn: 108807
* Reinstate the fix for PR7556. A silly use of isTrivial() wasDouglas Gregor2010-07-081-1/+1
| | | | | | suppressing copies of objects with trivial copy constructors. llvm-svn: 107857
* Revert r107828 and r107827, the fix for PR7556, which seems to beDouglas Gregor2010-07-071-1/+1
| | | | | | breaking bootstrap on Linux. llvm-svn: 107837
* Rename CXXZeroInitValueExpr to CXXScalarValueInitExpr, to reflect itsDouglas Gregor2010-07-071-1/+1
| | | | | | newly-narrowed scope. No functionality change. llvm-svn: 107828
OpenPOWER on IntegriCloud