summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/ExprConstant.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* PR11391: Don't try to evaluate the LHS of a _Complex assignment as an rvalue.Richard Smith2011-11-161-0/+4
| | | | llvm-svn: 144799
* Fix PR11385: A pointer constant expression which has been cast via an integer isRichard Smith2011-11-161-0/+1
| | | | | | | not safely derived. Don't allow lvalue-to-rvalue conversions on the result of dereferencing such a pointer. llvm-svn: 144783
* Represent an APValue based on a Decl as that Decl, rather than a DeclRefExprRichard Smith2011-11-121-86/+74
| | | | | | | | or MemberExpr which refers to it. As a side-effect, MemberExprs which refer to static member functions and static data members are now emitted as constant expressions. llvm-svn: 144468
* Constant expression evalation: const_cast support.Richard Smith2011-11-111-6/+1
| | | | llvm-svn: 144382
* Reduce the constexpr stack pressure somewhat. Hopefully this will be enough toRichard Smith2011-11-111-1/+1
| | | | | | please the buildbots. llvm-svn: 144375
* Constant expression evaluation: support for constexpr member functions. ThisRichard Smith2011-11-111-46/+118
| | | | | | | | | | | reinstates r144273; a combination of r144333's fix for NoOp rvalue-to-lvalue casts and some corresponding changes here resolve the regression which that caused. This patch also adds support for some additional forms of member function call, along with additional testing. llvm-svn: 144369
* Revert r144273. It causes clang self-host build failure.Devang Patel2011-11-101-56/+31
| | | | llvm-svn: 144296
* Constant expression evaluation: support for constexpr member functions.Richard Smith2011-11-101-31/+56
| | | | llvm-svn: 144273
* Constant expression evaluation: support for evaluation of structs and unions ofRichard Smith2011-11-101-142/+620
| | | | | | | literal types, as well as derived-to-base casts for lvalues and derived-to-virtual-base casts. llvm-svn: 144265
* Temporary fix for a performance problem Eli spotted. The APValue representationRichard Smith2011-11-101-0/+6
| | | | | | | is currently too inefficient to allow us to use it for array initializers, but fortunately we usually don't yet need to evaluate such initializers. llvm-svn: 144260
* Constant expression evaluation: support for default arguments.Richard Smith2011-11-091-0/+2
| | | | llvm-svn: 144156
* Fix a cluster of related issues involving value-dependence and constantRichard Smith2011-11-081-1/+4
| | | | | | | | | | | | | | expression evaluation: - When folding a non-value-dependent expression, we may try to use the initializer of a value-dependent variable. If that happens, give up. - In C++98, actually check that a const, non-volatile DeclRefExpr inside an ICE is of integral or enumeration type (a reference isn't OK!) - In C++11, DeclRefExprs for objects of const literal type initialized with value-dependent expressions are themselves value-dependent. - So are references initialized with value-dependent expressions (though this case is missing from the C++11 standard, along with many others). llvm-svn: 144056
* Constant expression evaluation: support for arrays.Richard Smith2011-11-071-33/+127
| | | | llvm-svn: 143922
* Rip out CK_GetObjCProperty.John McCall2011-11-071-2/+0
| | | | llvm-svn: 143910
* Constant expression evaluation: preserve subobject designator when flattening aRichard Smith2011-11-071-38/+70
| | | | | | core constant value down to an APValue. llvm-svn: 143909
* Allow constexpr variables' initializers to be folded in C++11 mode. ThisRichard Smith2011-11-071-2/+4
| | | | | | | | partially undoes the revert in r143491, but does not introduce any new instances of the underlying issue (which is not yet fixed) in code which does not use the 'constexpr' keyword. llvm-svn: 143905
* Change the AST representation of operations on Objective-CJohn McCall2011-11-061-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Remove unused variables.Benjamin Kramer2011-11-041-2/+0
| | | | llvm-svn: 143696
* Constant expression evaluation: refactor to start the groundwork for coping withRichard Smith2011-11-041-15/+55
| | | | | | | initializations which refer indirectly to elements of the object being initialized. llvm-svn: 143680
* Constant expression evaluation: track the manner in which an lvalue was written,Richard Smith2011-11-041-44/+172
| | | | | | | to allow us to implement the C++11 rule that a non-active union member can't be read, and use it to implement subobject access for string literals. llvm-svn: 143677
* Constant expression evaluation: although we don't know whether a literal willRichard Smith2011-11-041-2/+4
| | | | | | | be at the same address as another object, we do know it won't alias a null pointer. llvm-svn: 143674
* When constant-folding, don't look at the initializer of a global const variableRichard Smith2011-11-011-5/+11
| | | | | | if it's marked as weak: that definition may not end up being used. llvm-svn: 143496
* Temporarily disable lvalue-to-rvalue conversions on const pointers while anRichard Smith2011-11-011-1/+2
| | | | | | | apparent miscompile triggered by this is investigated. This is essentially a revert of r143298. llvm-svn: 143491
* Implement C++11 'constexpr calls must return constant expressions' rule, andRichard Smith2011-11-011-88/+60
| | | | | | perform the code simplifications this rule allows. llvm-svn: 143463
* Some minor comment changes in constant-folding comparisons.Eli Friedman2011-10-311-2/+6
| | | | llvm-svn: 143391
* Don't try to fold comparisons between the address of an object and an ↵Eli Friedman2011-10-311-0/+6
| | | | | | arbitrary integer constant. Fixes regression from r143334. llvm-svn: 143374
* Refactoring and test for r143360. Support for array rvalue to pointer decay isRichard Smith2011-10-311-3/+6
| | | | | | needed for C++11, and will follow later. llvm-svn: 143363
* Temporary fix for assert while evaluating array-to-pointer decay on arrayRichard Smith2011-10-311-1/+3
| | | | | | rvalue. Test and better fix to follow. llvm-svn: 143360
* C++11 generalized constant expression handling: evaluation support forRichard Smith2011-10-311-46/+89
| | | | | | materialized temporaries. llvm-svn: 143335
* C++11 generalized constant expressions: evaluate equality comparisons betweenRichard Smith2011-10-311-36/+44
| | | | | | arbitrary pointers, if those pointers don't point to weak objects or literals. llvm-svn: 143334
* C++11 generalized constant expressions: support pointer comparisons where theRichard Smith2011-10-311-40/+61
| | | | | | result is not unspecified. llvm-svn: 143329
* Fix assert on constant expression evaluation of floating point increment.Richard Smith2011-10-301-7/+3
| | | | llvm-svn: 143320
* Don't crash if a GCC binary conditional is used in a constant expression on anRichard Smith2011-10-291-0/+4
| | | | | | integer-cast pointer value. llvm-svn: 143299
* constexpr evaluation: allow lvalue-to-rvalue conversion on any literal type, notRichard Smith2011-10-291-4/+1
| | | | | | | | just integers and floating point types. Since we don't support evaluating class types or performing lvalue-to-rvalue conversions on array elements yet, this just means pointer types right now. llvm-svn: 143298
* constexpr function substitution:Richard Smith2011-10-291-116/+182
| | | | | | | | Track the function invocation where an lvalue referring to a constexpr function parameter originated from, and use it to substitute the correct argument and to determine whether such an argument's lifetime has ended. llvm-svn: 143296
* Rename Expr::Evaluate to Expr::EvaluateAsRValue to make it clear that it willRichard Smith2011-10-291-16/+17
| | | | | | | | implicitly perform an lvalue-to-rvalue conversion if used on an lvalue expression. Also improve the documentation of Expr::Evaluate* to indicate which of them will accept expressions with side-effects. llvm-svn: 143263
* Fix assertion in constant expression evaluation. The LHS of a floating-pointRichard Smith2011-10-281-2/+2
| | | | | | binary operator isn't an rvalue if it's an assignment operator. llvm-svn: 143250
* Initial support for C++11 constexpr function invocation substitution. UsingRichard Smith2011-10-281-11/+170
| | | | | | | | | | constexpr function arguments outside of their function (passing or returning them by reference) does not work correctly yet. Calling constexpr function templates does not work yet, since the bodies are not instantiated until the end of the translation unit. llvm-svn: 143234
* Reinstate r142844 (reverted in r142872) now that lvalue-to-rvalue conversionsRichard Smith2011-10-281-181/+315
| | | | | | | | | | are present in all the necessary places: In constant expression evaluation, evaluate lvalues as lvalues and rvalues as rvalues. Remove special case for caching reference initialization and fix a cyclic initialization crash in the process. llvm-svn: 143204
* Clean up, as suggested by John.Richard Smith2011-10-251-1/+1
| | | | llvm-svn: 142884
* Revert r142844, it broke selfhost. The problem appears to be a missingRichard Smith2011-10-241-237/+161
| | | | | | lvalue-to-rvalue conversion on the LHS operand of '->'. llvm-svn: 142872
* Add explanatory comments for ICE checking in C99 mode.Richard Smith2011-10-241-1/+10
| | | | llvm-svn: 142866
* Constant expression evaluation: evaluate lvalues as lvalues, and rvalues asRichard Smith2011-10-241-161/+237
| | | | | | | | rvalues, as C++11 constant evaluation semantics require. DeclRefs referring to references can now use the normal initialization-caching codepath, which incidentally fixes a crash in cyclic initialization of references. llvm-svn: 142844
* Constant expression evaluation: factor out handling of ignored values.Richard Smith2011-10-241-39/+15
| | | | llvm-svn: 142835
* In accordance with the C89, C99 and C++98 standards, ICEs can only containRichard Smith2011-10-241-3/+4
| | | | | | | floating-point literals if they are the immediate operands of casts. ImplicitCastExpr is not a cast in the language-standards sense. llvm-svn: 142832
* Constant expression evaluation: factor out VarDecl initializer evaluation andRichard Smith2011-10-241-68/+42
| | | | | | caching. llvm-svn: 142812
* Refactor vector constant expression evaluation to return bool like all the otherRichard Smith2011-10-221-47/+56
| | | | | | | const expression evaluation subclasses, and remove some APValue copying and malloc traffic in the process. llvm-svn: 142733
* Initial implementation of __atomic_is_lock_free. The input is the size of ↵Eli Friedman2011-10-171-0/+44
| | | | | | | | an atomic type rather than an atomic type itself just to save some implementation pain; I can change that if it seems worthwhile. I think this is the last hook needed for <atomic> besides defines for ATOMIC_CHAR_LOCK_FREE and friends. llvm-svn: 142281
* Split apart the state accumulated during constant expression evaluation and theRichard Smith2011-10-161-46/+53
| | | | | | | end result. Use this split to propagate state information and diagnostics through more of constant expression evaluation. llvm-svn: 142159
* Constant expression evaluation: refactor value initialization and scalar ↵Richard Smith2011-10-111-56/+39
| | | | | | list initialization into base class. llvm-svn: 141717
OpenPOWER on IntegriCloud