summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGExprConstant.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* PR12086, PR15117Richard Smith2013-06-121-5/+0
| | | | | | | | | | | | | | | | | | | Introduce CXXStdInitializerListExpr node, representing the implicit construction of a std::initializer_list<T> object from its underlying array. The AST representation of such an expression goes from an InitListExpr with a flag set, to a CXXStdInitializerListExpr containing a MaterializeTemporaryExpr containing an InitListExpr (possibly wrapped in a CXXBindTemporaryExpr). This more detailed representation has several advantages, the most important of which is that the new MaterializeTemporaryExpr allows us to directly model lifetime extension of the underlying temporary array. Using that, this patch *drastically* simplifies the IR generation of this construct, provides IR generation support for nested global initializer_list objects, fixes several bugs where the destructors for the underlying array would accidentally not get invoked, and provides constant expression evaluation support for std::initializer_list objects. llvm-svn: 183872
* Model temporary lifetime-extension explicitly in the AST. Use this model toRichard Smith2013-06-051-0/+9
| | | | | | | | | handle temporaries which have been lifetime-extended to static storage duration within constant expressions. This correctly handles nested lifetime extension (through reference members of aggregates in aggregate initializers) but non-constant-expression emission hasn't yet been updated to do the same. llvm-svn: 183283
* C++1y: Allow aggregates to have default initializers.Richard Smith2013-04-201-0/+6
| | | | | | | | | | | 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
* Allow EmitConstantInit() to emit constant initializers for objects with ↵Alexey Samsonov2013-04-051-2/+1
| | | | | | trivial constructors and non-trivial destructors. Test that such objects are ignored by init-order checker. llvm-svn: 178856
* Silence a number of static analyzer warnings with assertions and such.Jordan Rose2013-03-051-0/+2
| | | | | | No functionality change. llvm-svn: 176469
* Add a new LangOpt NativeHalfType. This option allows for native half/fp16Joey Gouly2013-01-231-1/+2
| | | | | | | | operations (as opposed to storage only half/fp16). Also add some semantic checks for OpenCL half types. llvm-svn: 173254
* Implement OpenCL event_t as Clang builtin type, including event_t related ↵Guy Benyei2013-01-201-0/+1
| | | | | | 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-1/+1
| | | | | | brought into 'clang' namespace by clang/Basic/LLVM.h llvm-svn: 172323
* c++ IRGen. In trivial cases that object is going into staticFariborz Jahanian2013-01-101-0/+17
| | | | | | | | | | storage and thus is implicitly zero-initialized, no need to do C++11 memory model. This patch unconditionally detects such condition and zeroinitializer's the variable. Patch has been commented on and OKed by Doug off-line. // rdar://12897704 llvm-svn: 172144
* Don't assert/crash on reference variables in lambdas bound to aEli Friedman2013-01-031-4/+2
| | | | | | static local variable from the parent scope. PR14773. llvm-svn: 171433
* Rewrite #includes for llvm/Foo.h to llvm/IR/Foo.h as appropriate toChandler Carruth2013-01-021-4/+4
| | | | | | | | reflect the migration in r171366. Re-sort the #include lines to reflect the new paths. llvm-svn: 171369
* Sort all of Clang's files under 'lib', and fix up the broken headersChandler Carruth2012-12-041-2/+2
| | | | | | | | | | | | | uncovered. This required manually correcting all of the incorrect main-module headers I could find, and running the new llvm/utils/sort_includes.py script over the files. I also manually added quite a few missing headers that were uncovered by shuffling the order or moving headers up to be main-module-headers. llvm-svn: 169237
* Make -mms-bitfields behave consistently.Eli Friedman2012-10-121-2/+2
| | | | | | Patch by Jeremiah Zanin. llvm-svn: 165849
* Add codegen support for __uuidof().Nico Weber2012-10-111-0/+3
| | | | llvm-svn: 165710
* Move TargetData to DataLayout.Micah Villmow2012-10-081-10/+10
| | | | llvm-svn: 165395
* Remove some redundancy from constant aggregate emission. No functionality ↵Richard Smith2012-09-111-9/+2
| | | | | | change. llvm-svn: 163595
* Changing of type checking order on InitListExprJin-Gu Kang2012-09-051-3/+3
| | | | | | - UnionType is checked eariler than RecordType. llvm-svn: 163202
* Change the representation of builtin functions in the ASTEli Friedman2012-08-311-0/+3
| | | | | | | | | (__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
* Remove get(V)BaseClassOffsetInBits, the CharUnit functions should be used ↵Benjamin Kramer2012-07-041-1/+2
| | | | | | | | instead. No functionality change. llvm-svn: 159719
* Support the tls_model attribute (PR9788)Hans Wennborg2012-06-231-1/+2
| | | | | | | | | | | | | | This adds support for the tls_model attribute. This allows the user to choose a TLS model that is better than what LLVM would select by default. For example, a variable might be declared as: __thread int x __attribute__((tls_model("initial-exec"))); if it will not be used in a shared library that is dlopen'ed. This depends on LLVM r159077. llvm-svn: 159078
* Revert Decl's iterators back to pointer value_type rather than reference ↵David Blaikie2012-06-061-13/+13
| | | | | | | | | | | | | | 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
* Remove the ref/value inconsistency in filter_decl_iterator.David Blaikie2012-04-301-13/+13
| | | | | | | | | | | | | 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
* PR12226: don't generate wrong code if a braced string literal is used toRichard Smith2012-04-151-6/+2
| | | | | | | | | initialize an array of unsigned char. Outside C++11 mode, this bug was benign, and just resulted in us emitting a constant which was double the required length, padded with 0s. In C++11, it resulted in us generating an array whose first element was something like i8 ptrtoint ([n x i8]* @str to i8). llvm-svn: 154756
* Missing piece of r153720: make sure the vtable pointer is handled correctly.Eli Friedman2012-03-301-1/+1
| | | | llvm-svn: 153721
* ConstStructBuilder: fix offset math for base classes so it works correctly ↵Eli Friedman2012-03-301-7/+3
| | | | | | in general. Found by inspection. llvm-svn: 153720
* Make sure constant emission handles initializer lists with strings ↵Eli Friedman2012-03-091-1/+3
| | | | | | correctly. Part of <rdar://problem/10957867>. llvm-svn: 152370
* Reinstate r151879, r151880, reverted in r151922, along with a bugfix forRichard Smith2012-03-021-18/+24
| | | | | | | | | scalar emission of DeclRefExprs to const bools: emit scalar bools as i1, not as i8. In addition to the extra unit testing, this has successfully bootstrapped. llvm-svn: 151955
* CodeGen support for global variables of type std::initializer_list<X>.Sebastian Redl2012-02-251-1/+1
| | | | | | | | | | | | | This emits a backing array with internal linkage and fills it with data, then has the initializer_list point at the array. Dynamic initialization and global destructors are correctly supported. What doesn't work is nested initializer_lists. I have no idea how to get them to work, either. However, these should be very rare, and so I'll just call it a known bug and declare generalized initializers DONE! llvm-svn: 151457
* PR12067: When emitting an evaluated constant structure in C++11 mode, don'tRichard Smith2012-02-231-12/+82
| | | | | | forget the vptrs. llvm-svn: 151245
* Generate an AST for the conversion from a lambda closure type to aDouglas Gregor2012-02-221-0/+1
| | | | | | | | | | | | | | | block pointer that returns a block literal which captures (by copy) the lambda closure itself. Some aspects of the block literal are left unspecified, namely the capture variable (which doesn't actually exist) and the body (which will be filled in by IRgen because it can't be written as an AST). Because we're switching to this model, this patch also eliminates tracking the copy-initialization expression for the block capture of the conversion function, since that information is now embedded in the synthesized block literal. -1 side tables FTW. llvm-svn: 151131
* Refuse to compile global std::initializer_lists instead of doing completely ↵Sebastian Redl2012-02-191-0/+5
| | | | | | the wrong thing. llvm-svn: 150928
* Split reinterpret_casts of member pointers out from CK_BitCast; thisJohn McCall2012-02-151-3/+6
| | | | | | | | | | | | | | | | | | | | | is general goodness because representations of member pointers are not always equivalent across member pointer types on all ABIs (even though this isn't really standard-endorsed). Take advantage of the new information to teach IR-generation how to do these reinterprets in constant initializers. Make sure this works when intermingled with hierarchy conversions (although this is not part of our motivating use case). Doing this in the constant-evaluator would probably have been better, but that would require a *lot* of extra structure in the representation of constant member pointers: you'd really have to track an arbitrary chain of hierarchy conversions and reinterpretations in order to get this right. Ultimately, this seems less complex. I also wasn't quite sure how to extend the constant evaluator to handle foldings that we don't actually want to treat as extended constant expressions. llvm-svn: 150551
* Use a simpler (and more efficient) pattern to pad vectors.Benjamin Kramer2012-02-141-4/+3
| | | | llvm-svn: 150475
* Deal with a horrible C++11 special case. If a non-literal type has a constexprRichard Smith2012-02-131-0/+9
| | | | | | | | | | | constructor, and that constructor is used to initialize an object of static storage duration such that all members and bases are initialized by constant expressions, constant initialization is performed. In this case, the object can still have a non-trivial destructor, and if it does, we must emit a dynamic initializer which performs no initialization and instead simply registers that destructor. llvm-svn: 150419
* Bump up the initial vector size to avoid having to grow the vector more often.Bill Wendling2012-02-071-1/+1
| | | | llvm-svn: 149945
* simplify a bunch of code to use the well-known LLVM IR types computed by ↵Chris Lattner2012-02-071-11/+7
| | | | | | CodeGenModule. llvm-svn: 149943
* Use a more efficient container for these values. Also reserve space when using aBill Wendling2012-02-071-3/+6
| | | | | | std::vector. llvm-svn: 149936
* Use a SmallVector instead of std::vector. This improves compilation time inBill Wendling2012-02-071-5/+5
| | | | | | 445.gobmk by ~1.7%. llvm-svn: 149935
* Don't recalculate the size of the array each time through the for-loop.Bill Wendling2012-02-061-2/+2
| | | | llvm-svn: 149933
* simplify code and smallvectorize.Chris Lattner2012-02-061-6/+7
| | | | llvm-svn: 149915
* reapply the patches reverted in r149477, which enable ConstantDataArray.Chris Lattner2012-02-051-1/+1
| | | | llvm-svn: 149801
* Revert r149363 which was part a series of commits that were reverted in llvmArgyrios Kyrtzidis2012-02-011-1/+1
| | | | | | | | | | | | | | | | | commit 149470. This fixes test/CodeGen/PR3589-freestanding-libcalls.c. Original log: ConstantArray::get() (for strings) is going away, use ConstantDataArray::getString instead. Many instances of ConstantArray::get() could be moved to use more efficient ConstantDataArray methods that avoid a ton of intermediate Constant*'s for each element (e.g. GetConstantArrayFromStringLiteral). I don't plan on doing this in the short-term though. llvm-svn: 149477
* ConstantArray::get() (for strings) is going away, useChris Lattner2012-01-311-1/+1
| | | | | | | | | | | | ConstantDataArray::getString instead. Many instances of ConstantArray::get() could be moved to use more efficient ConstantDataArray methods that avoid a ton of intermediate Constant*'s for each element (e.g. GetConstantArrayFromStringLiteral). I don't plan on doing this in the short-term though. llvm-svn: 149363
* Remove constant member pointer support from Expr-based constant emission nowRichard Smith2012-01-171-24/+13
| | | | | | that APValue-based constant emission knows how to emit member pointers. llvm-svn: 148336
* Some improvements to the handling of C11 atomic types:David Chisnall2012-01-161-0/+2
| | | | | | | | | | | | | | | | | | - Add atomic-to/from-nonatomic cast types - Emit atomic operations for arithmetic on atomic types - Emit non-atomic stores for initialisation of atomic types, but atomic stores and loads for every other store / load - Add a __atomic_init() intrinsic which does a non-atomic store to an _Atomic() type. This is needed for the corresponding C11 stdatomic.h function. - Enables the relevant __has_feature() checks. The feature isn't 100% complete yet, but it's done enough that we want people testing it. Still to do: - Make the arithmetic operations on atomic types (e.g. Atomic(int) foo = 1; foo++;) use the correct LLVM intrinsic if one exists, not a loop with a cmpxchg. - Add a signal fence builtin - Properly set the fenv state in atomic operations on floating point values - Correctly handle things like _Atomic(_Complex double) which are too large for an atomic cmpxchg on some platforms (this requires working out what 'correctly' means in this context) - Fix the many remaining corner cases llvm-svn: 148242
* constexpr irgen: Add irgen support for APValue::Struct, APValue::Union,Richard Smith2012-01-141-206/+321
| | | | | | | | | | | | | | | | | | | | APValue::Array and APValue::MemberPointer. All APValue values can now be emitted as constants. Add new CGCXXABI entry point for emitting an APValue MemberPointer. The other entrypoints dealing with constant member pointers are no longer necessary and will be removed in a later change. Switch codegen from using EvaluateAsRValue/EvaluateAsLValue to VarDecl::evaluateValue. This performs caching and deals with the nasty cases in C++11 where a non-const object's initializer can refer indirectly to previously-initialized fields within the same object. Building the intermediate APValue object incurs a measurable performance hit on pathological testcases with huge initializer lists, so we continue to build IR directly from the Expr nodes for array and record types outside of C++11. llvm-svn: 148178
* Implement the missing pieces of Evaluate for _Complex types. With that ↵Eli Friedman2012-01-101-30/+1
| | | | | | complete, remove some code from CGExprConstant which is no longer necessary. While I'm here, a couple minor tweaks to _Complex-in-C++. (Specifically, make _Complex types literal types, and don't warn for _Complex int.) llvm-svn: 147840
* Address Richard's review comments on r147561 (Evaluate support for ↵Eli Friedman2012-01-051-1/+1
| | | | | | address-of-label differences). llvm-svn: 147631
* Add an APValue representation for the difference between two ↵Eli Friedman2012-01-041-68/+26
| | | | | | | | | | address-of-label expressions. Add support to Evaluate and CGExprConstant for generating/handling them. Remove the special-case for such differences in Expr::isConstantInitializer. With that done, remove a bunch of buggy code from CGExprConstant for handling scalar expressions which is no longer necessary. Fixes PR11705. llvm-svn: 147561
* constexpr: support for evaluation and codegen of typeid constants.Richard Smith2011-12-271-0/+9
| | | | llvm-svn: 147290
OpenPOWER on IntegriCloud