summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/ExprConstant.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
* Initial implementation of __atomic_* (everything except __atomic_is_lock_free).Eli Friedman2011-10-111-0/+1
| | | | llvm-svn: 141632
* Extend lvalue evaluation in ExprConstant.cpp to handle CK_LValueBitCast ↵Eli Friedman2011-10-111-0/+3
| | | | | | (which is completely trivial). PR8836. llvm-svn: 141604
* Constant expression evaluation refactoring:Richard Smith2011-10-101-11/+18
| | | | | | | | | | | - Remodel Expr::EvaluateAsInt to behave like the other EvaluateAs* functions, and add Expr::EvaluateKnownConstInt to capture the current fold-or-assert behaviour. - Factor out evaluation of bitfield bit widths. - Fix a few places which would evaluate an expression twice: once to determine whether it is a constant expression, then again to get the value. llvm-svn: 141561
* PR11040: CheckICE should not allow an lvalue bitcast as part of an integer ↵Eli Friedman2011-09-291-4/+10
| | | | | | constant expression. llvm-svn: 140812
* Constant evaluation for pointer CXXScalarValueInitExprPeter Collingbourne2011-09-271-0/+2
| | | | llvm-svn: 140613
* Treat list-initialization of scalars as a first-class citizen in C++11.Sebastian Redl2011-09-241-3/+48
| | | | | | | | | Allow empty initializer lists for scalars, which mean value-initialization. Constant evaluation for single-element and empty initializer lists for scalars. Codegen for empty initializer lists for scalars. Test case comes in next commit. llvm-svn: 140459
* Removing a bunch of dead returns/breaks after llvm_unreachables.David Blaikie2011-09-231-1/+0
| | | | llvm-svn: 140407
* Switch assert(0/false) llvm_unreachable.David Blaikie2011-09-231-3/+3
| | | | llvm-svn: 140367
* Rename the ARC cast kinds to start with "ARC".John McCall2011-09-101-8/+8
| | | | llvm-svn: 139466
* When converting a block pointer to an Objective-C pointer type, extendJohn McCall2011-09-101-0/+2
| | | | | | | | | | | the lifetime of the block by copying it to the heap, or else we'll get a dangling reference because the code working with the non-block-typed object will not know it needs to copy. There is some danger here, e.g. with assigning a block literal to an unsafe variable, but, well, it's an unsafe variable. llvm-svn: 139451
* Give conversions of block pointers to ObjC pointers a different cast kindJohn McCall2011-09-091-3/+6
| | | | | | | | than conversions of C pointers to ObjC pointers. In order to ensure that we've caught every case, add asserts to CastExpr that strictly determine which cast kind is used for which kind of bit cast. llvm-svn: 139352
* Extend the ASTContext constructor to delay the initialization ofDouglas Gregor2011-09-021-1/+1
| | | | | | | | builtin types (When requested). This is another step toward making ASTUnit build the ASTContext as needed when loading an AST file, rather than doing so after the fact. No actual functionality change (yet). llvm-svn: 138985
* Fix a crash-on-valid that has been here for a very long time:Chandler Carruth2011-08-221-2/+9
| | | | | | | | | | | | | | | const int &x = x; This crashed by inifinetly recursing within the lvalue evaluation routine. I've added a (somewhat) braindead way of preventing this recursion. If folks have better suggestions for how to avoid it I'm all ears. That said, we have some work to do. This doesn't trigger a single warning for uninitialized, self-initialized or otherwise completely wrong code. In some senses, the crash was almost better. llvm-svn: 138239
* After further discussion it has been determined that alignof should report Chad Rosier2011-07-261-9/+4
| | | | | | the preferred alignment. Thus, revert r135934, r135935, and r135940. llvm-svn: 136062
* Allow target to specify about using minimum alignment vs preferred. Takes ↵Chad Rosier2011-07-251-4/+9
| | | | | | | | | care of FIXME: Override "preferred align" for double and long long for ARM apcs-gnu ABI. Also part of rdar://9802874 llvm-svn: 135940
* remove unneeded llvm:: namespace qualifiers on some core types now that ↵Chris Lattner2011-07-231-7/+7
| | | | | | | | LLVM.h imports them into the clang namespace. llvm-svn: 135852
* Use the new APFloat::convertToInt(APSInt) function to simplify uses ofJeffrey Yasskin2011-07-151-4/+3
| | | | | | convertToInt(integerParts*) and make them more reliable. llvm-svn: 135279
* Create a new expression node, SubstNonTypeTemplateParmExpr,John McCall2011-07-151-0/+6
| | | | | | | | 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
* In ARC, reclaim all return values of retainable type, not just thoseJohn McCall2011-07-071-0/+2
| | | | | | | | | | | | 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
* Zap a couple unnecessary loops.Eli Friedman2011-07-071-9/+1
| | | | llvm-svn: 134578
* Rewritten fix in r134139 to conform evaluation result to original evaluation ↵Abramo Bagnara2011-07-021-11/+21
| | | | | | context. llvm-svn: 134320
* Fixed enum constant evaluation assertions.Abramo Bagnara2011-06-301-6/+13
| | | | llvm-svn: 134139
* Introduce a new AST node describing reference binding to temporaries.Douglas Gregor2011-06-211-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | 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-1/+18
| | | | | | | | | | 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
* Implement the initial part of C++0x [expr.const]p2, which specifiesDouglas Gregor2011-05-241-2/+29
| | | | | | | | | | | | that the unevaluated subexpressions of &&, ||, and ? : are not considered when determining whether the expression is a constant expression. Also, turn the "used in its own initializer" warning into a runtime-behavior warning, so that it doesn't fire when a variable is used as part of an unevaluated subexpression of its own initializer. Fixes PR9999. llvm-svn: 131968
* Introduce Type::isSignedIntegerOrEnumerationType() andDouglas Gregor2011-05-201-5/+6
| | | | | | | | | | | | | Type::isUnsignedIntegerOrEnumerationType(), which are like Type::isSignedIntegerType() and Type::isUnsignedIntegerType() but also consider the underlying type of a C++0x scoped enumeration type. Audited all callers to the existing functions, switching those that need to also handle scoped enumeration types (e.g., those that deal with constant values) over to the new functions. Fixes PR9923 / <rdar://problem/9447851>. llvm-svn: 131735
* Refactoring of constant expression evaluatorPeter Collingbourne2011-05-131-335/+238
| | | | | | | | | This introduces a generic base class for the expression evaluator classes, which handles a few common expression types which were previously handled separately in each class. Also, the expression evaluator now uses ConstStmtVisitor. llvm-svn: 131281
* Implementation of Embarcadero array type traitsJohn Wiegley2011-04-281-0/+5
| | | | | | | | | | 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/+5
| | | | | | | | | 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
* ForArgyrios Kyrtzidis2011-04-211-0/+2
| | | | | | | | | | | | | | double data[20000000] = {0}; we would blow out the memory by creating 20M Exprs to fill out the initializer. To fix this, if the initializer list initializes an array with more elements than there are initializers in the list, have InitListExpr store a single 'ArrayFiller' expression that specifies an expression to be used for value initialization of the rest of the elements. Fixes rdar://9275920. llvm-svn: 129896
OpenPOWER on IntegriCloud