summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/ExprConstant.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* PR15884: In the 'taking the address of a temporary' extension, materialize theRichard Smith2013-05-011-8/+6
| | | | | | | | temporary to an lvalue before taking its address. This removes a weird special case from the AST representation, and allows the constant expression evaluator to deal with it without (broken) hacks. llvm-svn: 180866
* Move helper classes into anonymous namespaces.Benjamin Kramer2013-04-261-0/+2
| | | | llvm-svn: 180642
* C++1y: support simple variable assignments in constexpr functions.Richard Smith2013-04-261-96/+376
| | | | llvm-svn: 180603
* C++1y constexpr extensions, round 1: Allow most forms of declaration andRichard Smith2013-04-221-13/+99
| | | | | | | | statement in constexpr functions. Everything which doesn't require variable mutation is also allowed as an extension in C++11. 'void' becomes a literal type to support constexpr functions which return 'void'. llvm-svn: 180022
* Fix array constant expression evaluation bug: we can have different values forRichard Smith2013-04-221-36/+62
| | | | | | | different array elements, even if they're all constructed using the same default constructor. llvm-svn: 180017
* C++1y: Allow aggregates to have default initializers.Richard Smith2013-04-201-3/+35
| | | | | | | | | | | Add a CXXDefaultInitExpr, analogous to CXXDefaultArgExpr, and use it both in CXXCtorInitializers and in InitListExprs to represent a default initializer. There's an additional complication here: because the default initializer can refer to the initialized object via its 'this' pointer, we need to make sure that 'this' points to the right thing within the evaluation. llvm-svn: 179958
* Basic support for Microsoft property declarations andJohn McCall2013-04-161-0/+1
| | | | | | | | references thereto. Patch by Tong Shen! llvm-svn: 179585
* Annotate flavor of TLS variable (statically or dynamically initialized) onto ↵Richard Smith2013-04-131-1/+1
| | | | | | the AST. llvm-svn: 179447
* Force a load when creating a reference to a temporary copied from a bitfield.Jordan Rose2013-04-111-17/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For this source: const int &ref = someStruct.bitfield; We used to generate this AST: DeclStmt [...] `-VarDecl [...] ref 'const int &' `-MaterializeTemporaryExpr [...] 'const int' lvalue `-ImplicitCastExpr [...] 'const int' lvalue <NoOp> `-MemberExpr [...] 'int' lvalue bitfield .bitfield [...] `-DeclRefExpr [...] 'struct X' lvalue ParmVar [...] 'someStruct' 'struct X' Notice the lvalue inside the MaterializeTemporaryExpr, which is very confusing (and caused an assertion to fire in the analyzer - PR15694). We now generate this: DeclStmt [...] `-VarDecl [...] ref 'const int &' `-MaterializeTemporaryExpr [...] 'const int' lvalue `-ImplicitCastExpr [...] 'int' <LValueToRValue> `-MemberExpr [...] 'int' lvalue bitfield .bitfield [...] `-DeclRefExpr [...] 'struct X' lvalue ParmVar [...] 'someStruct' 'struct X' Which makes a lot more sense. This allows us to remove code in both CodeGen and AST that hacked around this special case. The commit also makes Clang accept this (legal) C++11 code: int &&ref = std::move(someStruct).bitfield PR15694 / <rdar://problem/13600396> llvm-svn: 179250
* Fix a crash in OpenCL code by using the proper (RHS) bit-width.Joey Gouly2013-01-291-2/+2
| | | | llvm-svn: 173802
* removed duplicated comment.Fariborz Jahanian2013-01-241-1/+0
| | | | llvm-svn: 173378
* Patch to check for integer overflow. It has beenFariborz Jahanian2013-01-241-17/+57
| | | | | | commented on and approved by Richard Smith. llvm-svn: 173377
* Switch to APFloat constructor taking fltSemantics.Tim Northover2013-01-221-2/+1
| | | | | | | | This change also makes the serialisation store the required semantics, fixing an issue where PPC128 was always assumed when re-reading a 128-bit value. llvm-svn: 173139
* Implement OpenCL event_t as Clang builtin type, including event_t related ↵Guy Benyei2013-01-201-0/+2
| | | | | | OpenCL restrictions (OpenCL 1.2 spec 6.9) llvm-svn: 172973
* Remove useless 'llvm::' qualifier from names like StringRef and others that areDmitri Gribenko2013-01-121-15/+14
| | | | | | brought into 'clang' namespace by clang/Basic/LLVM.h llvm-svn: 172323
* Issue warning when case value is too large to fitFariborz Jahanian2013-01-091-1/+3
| | | | | | | | | in case condition type. // rdar://11577384. Test is conditionalized on x86_64-apple triple as I am not sure if the INT_MAX/LONG_MAX values in the test will pass this test for other hosts. llvm-svn: 172016
* Scalar shifts in the OpenCL specification (as of v. 1.2) are defined to beDavid Tweed2013-01-071-6/+16
| | | | | | | | | | with respect to the lower "left-hand-side bitwidth" bits, even when negative); see OpenCL spec 6.3j. This patch both implements this behaviour in the code generator and "constant folding" bits of Sema, and also prevents tests to detect undefinedness in terms of the weaker C99 or C++ specifications from being applied. llvm-svn: 171755
* s/CPlusPlus0x/CPlusPlus11/gRichard Smith2013-01-021-17/+17
| | | | llvm-svn: 171367
* Replace magic numbers in CheckICE with an enum.Richard Smith2012-12-281-70/+66
| | | | llvm-svn: 171192
* PR14729: Fix typo in CheckICE for BinaryConditionalOperators.Richard Smith2012-12-281-1/+1
| | | | llvm-svn: 171191
* Include pruning and general cleanup.Benjamin Kramer2012-12-011-2/+3
| | | | llvm-svn: 169095
* DR1535: only potentially-evaluated typeid expressions are disallowed in constantRichard Smith2012-10-171-12/+6
| | | | | | expressions, not *any* typeid on a polymorphic class type. llvm-svn: 166156
* Expose __builtin_bswap16.Benjamin Kramer2012-10-061-0/+1
| | | | | | | GCC has always supported this on PowerPC and 4.8 supports it on all platforms, so it's a good idea to expose it in clang too. LLVM supports this on all targets. llvm-svn: 165362
* CodeGen: Fix a silly typo when emitting subs of block addresses.Benjamin Kramer2012-10-031-1/+1
| | | | | | Part of PR14005. llvm-svn: 165117
* Fix treatment of case which came up on std-proposals@: 'void' is permitted ↵Richard Smith2012-10-011-3/+1
| | | | | | in core constant expressions, despite not being a literal type. llvm-svn: 164968
* Allow __builtin_bswap32/64 in constant expressions, like gcc does. Patch by ↵Richard Smith2012-09-281-0/+9
| | | | | | Tijl Coosemans! llvm-svn: 164841
* PR13811: Add a FunctionParmPackExpr node to handle references to functionRichard Smith2012-09-121-0/+1
| | | | | | | parameter packs where the reference is not being expanded but the pack has been. Previously, Clang would segfault in such cases. llvm-svn: 163672
* Change the representation of builtin functions in the ASTEli Friedman2012-08-311-0/+2
| | | | | | | | | (__builtin_* etc.) so that it isn't possible to take their address. Specifically, introduce a new type to represent a reference to a builtin function, and a new cast kind to convert it to a function pointer in the operand of a call. Fixes PR13195. llvm-svn: 162962
* Move TLS check from LValueExprEvaluator::VisitVarDecl toHans Wennborg2012-08-291-2/+8
| | | | | | | | | | | CheckLValueConstantExpression. Richard pointed out that using the address of a TLS variable is ok in a core C++11 constant expression, as long as it isn't part of the eventual result of constant expression evaluation. Having the check in CheckLValueConstantExpression accomplishes this. llvm-svn: 162850
* Fix r162835 as per Richard's comments.Hans Wennborg2012-08-291-1/+1
| | | | | | | VisitVarDecl should return Error(E), and we should test that the address of a TLS var can't be used as a constexpr. llvm-svn: 162837
* The address of a TLS var is not compile-time constant (PR13720)Hans Wennborg2012-08-291-0/+2
| | | | | | | | | | | | This makes Clang produce an error for code such as: __thread int x; int *p = &x; The lvalue of a thread-local variable cannot be evaluated at compile time. llvm-svn: 162835
* Change a bunch of cases where we do "getAs<...>->doSomething()" toTed Kremenek2012-08-231-8/+8
| | | | | | | | | "castAs<...>->doSomething()". The analyzer was flagging these as potential null dereferences, which is technically true. The invariants appear to be that these casts should never fail, so let's use castAs<> instead and avoid a runtime check. llvm-svn: 162468
* Factor out computation of whether a typeid's expression is potentiallyRichard Smith2012-08-131-0/+3
| | | | | | evaluated into a CXXTypeid member function. No functionality change. llvm-svn: 161779
* Teach Expr::HasSideEffects about all the Expr types, and fix a bug where itRichard Smith2012-08-071-92/+3
| | | | | | | | | | | | | | | | | | | was mistakenly classifying dynamic_casts which might throw as having no side effects. Switch it from a visitor to a switch, so it is kept up-to-date as future Expr nodes are added. Move it from ExprConstant.cpp to Expr.cpp, since it's not really related to constant expression evaluation. Since we use HasSideEffect to determine whether to emit an unused global with internal linkage, this has the effect of suppressing emission of globals in some cases. I've left many of the Objective-C cases conservatively assuming that the expression has side-effects. I'll leave it to someone with better knowledge of Objective-C than mine to improve them. llvm-svn: 161388
* objective-C string literal has no side-effect,Fariborz Jahanian2012-08-041-0/+1
| | | | | | | resulting in issuance of unused static variable warning now. // rdar://10777111 llvm-svn: 161291
* Let Expr::HasSideEffects() return false for NULL, bool literals, this, and ↵Nico Weber2012-07-201-0/+6
| | | | | | | | nullptr. Fixes PR13413, -Wunused-private-field now warns on unused fields initialized to NULL. llvm-svn: 160541
* Don't treat overflow in floating-point conversions as a hard error in ↵Eli Friedman2012-07-171-6/+5
| | | | | | constant evaluation. <rdar://problem/11874571>. llvm-svn: 160394
* add support for conditional expressions in Expr::HasSideEffects()Nuno Lopes2012-07-131-0/+3
| | | | | | This fixes a bug in __builtin_object_size() codegen llvm-svn: 160191
* Fix crash when constant-evaluating a CXXConstructExpr representingRichard Smith2012-07-101-8/+9
| | | | | | | value-initialization for an array of class type with a trivial default constructor. llvm-svn: 160024
* PR13290: Constant-evaluation support for CXXConstructExprs which construct aRichard Smith2012-07-071-19/+39
| | | | | | | | multidimensional array of class type. Also, preserve zero-initialization when evaluating an initializer list for an array, in case the initializers refer to later elements (which have preceding zero-initialization). llvm-svn: 159904
* Remove typedef which is unused after r159189.Richard Smith2012-06-261-4/+0
| | | | llvm-svn: 159224
* Fix lifetime issue for backing APValue of OpaqueValueExpr in recursiveRichard Smith2012-06-261-41/+7
| | | | | | | | | | constexpr function evaluation, and corresponding ASan / valgrind issue in tests, by storing the corresponding value with the relevant stack frame. This also prevents re-evaluation of the source of the underlying OpaqueValueExpr, which makes a major performance difference for certain contrived code (see testcase update). llvm-svn: 159189
* Use std::map instead of llvm::DenseMap because we rely on the stability of ↵Eli Friedman2012-06-251-2/+6
| | | | | | references to values in these maps. PR13197. llvm-svn: 159161
* Revert Decl's iterators back to pointer value_type rather than reference ↵David Blaikie2012-06-061-4/+4
| | | | | | | | | | | | | | value_type In addition, I've made the pointer and reference typedef 'void' rather than T* just so they can't get misused. I would've omitted them entirely but std::distance likes them to be there even if it doesn't use them. This rolls back r155808 and r155869. Review by Doug Gregor incorporating feedback from Chandler Carruth. llvm-svn: 158104
* If the first argument of __builtin_object_size can be folded to a constantRichard Smith2012-05-231-4/+13
| | | | | | | | pointer, but such folding encounters side-effects, ignore the side-effects rather than performing them at runtime: CodeGen generates wrong code for __builtin_object_size in that case. llvm-svn: 157310
* My first effort to do this more subtly failed, so elaboratelyJohn McCall2012-05-011-31/+59
| | | | | | | test for an invalid declaration at every single place in the constant evaluator that's about to request a struct layout. llvm-svn: 155868
* Remove the ref/value inconsistency in filter_decl_iterator.David Blaikie2012-04-301-11/+11
| | | | | | | | | | | | | filter_decl_iterator had a weird mismatch where both op* and op-> returned T* making it difficult to generalize this filtering behavior into a reusable library of any kind. This change errs on the side of value, making op-> return T* and op* return T&. (reviewed by Richard Smith) llvm-svn: 155808
* Fix a crash-on-invalid where the constant evaluator would try toJohn McCall2012-04-261-0/+5
| | | | | | evaluate certain expressions involving invalidly-defined classes. llvm-svn: 155645
* Implements boxed expressions for Objective-C. <rdar://problem/10194391>Patrick Beard2012-04-191-2/+2
| | | | llvm-svn: 155082
* Per Richard's comments on r154794, add the checks necessary to handle ↵Eli Friedman2012-04-161-2/+13
| | | | | | constant-folding relational comparisons safely in case the user is using -fwrapv or equivalent. llvm-svn: 154849
OpenPOWER on IntegriCloud