summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGExprConstant.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
* Fix a failure (which led to a crash) in constant emission code with vector ↵Eli Friedman2011-12-221-1/+2
| | | | | | compound literals. llvm-svn: 147111
* Make sure we correctly zero-initialize unions containing a pointer to data ↵Eli Friedman2011-12-071-7/+11
| | | | | | member as the first field. PR11487. llvm-svn: 146009
* Use static storage duration for file-scope compound literals, even when theyRichard Smith2011-11-221-0/+6
| | | | | | appear in non-constant initializers in C++. llvm-svn: 145087
* Constant expression evaluation: add support for evaluation of member pointersRichard Smith2011-11-171-0/+1
| | | | | | and base-to-derived casts, and add proper handling of temporaries. llvm-svn: 144926
* Represent an APValue based on a Decl as that Decl, rather than a DeclRefExprRichard Smith2011-11-121-22/+23
| | | | | | | | 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 evaluation: support for evaluation of structs and unions ofRichard Smith2011-11-101-2/+3
| | | | | | | literal types, as well as derived-to-base casts for lvalues and derived-to-virtual-base casts. llvm-svn: 144265
* Constant expression evaluation: support for arrays.Richard Smith2011-11-071-0/+3
| | | | llvm-svn: 143922
* Rip out CK_GetObjCProperty.John McCall2011-11-071-1/+0
| | | | llvm-svn: 143910
* Fix the representation of wide strings in the AST and IR so that it uses the ↵Eli Friedman2011-11-011-7/+1
| | | | | | | | | | native representation of integers for the elements. This fixes a bunch of nastiness involving treating wide strings as a series of bytes. Patch by Seth Cantrell. llvm-svn: 143417
* Rename Expr::Evaluate to Expr::EvaluateAsRValue to make it clear that it willRichard Smith2011-10-291-1/+1
| | | | | | | | 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
* Don't try to emit CK_LValueBitCast casts as constants. PR9558.Eli Friedman2011-10-241-1/+1
| | | | llvm-svn: 142863
* Provide half floating point support as a storage only type.Anton Korobeynikov2011-10-141-2/+7
| | | | | | Lack of half FP was a regression compared to llvm-gcc. llvm-svn: 142016
* PR11124: Don't overwrite memory outside of a base class when performing ↵Eli Friedman2011-10-141-0/+5
| | | | | | zero-initialization before running its constructor. llvm-svn: 141933
* Constant expression evaluation refactoring:Richard Smith2011-10-101-2/+1
| | | | | | | | | | | - 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
* Removing a bunch of dead returns/breaks after llvm_unreachables.David Blaikie2011-09-231-4/+0
| | | | llvm-svn: 140407
* Switch assert(0/false) llvm_unreachable.David Blaikie2011-09-231-2/+2
| | | | llvm-svn: 140367
* Add list initialization for complex numbers in C. Essentially, this allows ↵Eli Friedman2011-09-191-0/+16
| | | | | | | | "_Complex float x = {1.0f, 2.0f};". See changes to docs/LanguageExtensions.html for a longer description. <rdar://problem/9397672>. llvm-svn: 140090
* Rename the ARC cast kinds to start with "ARC".John McCall2011-09-101-4/+4
| | | | llvm-svn: 139466
* When converting a block pointer to an Objective-C pointer type, extendJohn McCall2011-09-101-0/+1
| | | | | | | | | | | 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-1/+2
| | | | | | | | 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
* Declare and define implicit move constructor and assignment operator.Sebastian Redl2011-08-301-2/+2
| | | | | | | | | 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
* Cleanup to use helper.Eli Friedman2011-08-231-1/+1
| | | | llvm-svn: 138369
* remove unneeded llvm:: namespace qualifiers on some core types now that ↵Chris Lattner2011-07-231-1/+1
| | | | | | | | LLVM.h imports them into the clang namespace. llvm-svn: 135852
* Convert ConstantExpr::getGetElementPtr andJay Foad2011-07-211-1/+1
| | | | | | ConstantExpr::getInBoundsGetElementPtr to use ArrayRef. llvm-svn: 135673
* de-constify llvm::Type, patch by David Blaikie!Chris Lattner2011-07-181-24/+24
| | | | llvm-svn: 135370
* Create a new expression node, SubstNonTypeTemplateParmExpr,John McCall2011-07-151-0/+5
| | | | | | | | 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
* De-constify Types in StructType::get() and TargetData::getIntPtrType().Jay Foad2011-07-111-3/+3
| | | | llvm-svn: 134893
* In ARC, reclaim all return values of retainable type, not just thoseJohn McCall2011-07-071-0/+1
| | | | | | | | | | | | 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
OpenPOWER on IntegriCloud