summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/ExprConstant.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix bug in vector initializer when initializing a vector with another vector.Tanya Lattner2011-04-151-0/+6
| | | | | | Add test case. llvm-svn: 129617
* C1X: implement generic selectionsPeter Collingbourne2011-04-151-0/+22
| | | | | | | As an extension, generic selection support has been added for all supported languages. The syntax is the same as for C1X. llvm-svn: 129554
* After some discussion with Doug, we decided that it made a lot more senseJohn McCall2011-04-121-4/+0
| | | | | | | | | for __unknown_anytype resolution to destructively modify the AST. So that's what it does now, which significantly simplifies some of the implementation. Normal member calls work pretty cleanly now, and I added support for propagating unknown-ness through &. llvm-svn: 129331
* More __unknown_anytype work.John McCall2011-04-111-0/+2
| | | | llvm-svn: 129269
* Remove CK_DynamicToNull.Anders Carlsson2011-04-111-2/+0
| | | | llvm-svn: 129265
* As a first step towards fixing PR9641, add a CK_DynamicToNull cast kind whichAnders Carlsson2011-04-101-0/+2
| | | | | | | | | | | | | | | | | | represents a dynamic cast where we know that the result is always null. For example: struct A { virtual ~A(); }; struct B final : A { }; struct C { }; bool f(B* b) { return dynamic_cast<C*>(b); } llvm-svn: 129256
* Basic, untested implementation for an "unknown any" type requested by LLDB.John McCall2011-04-071-0/+2
| | | | | | | | | | | | The idea is that you can create a VarDecl with an unknown type, or a FunctionDecl with an unknown return type, and it will still be valid to access that object as long as you explicitly cast it at every use. I'm still going back and forth about how I want to test this effectively, but I wanted to go ahead and provide a skeletal implementation for the LLDB folks' benefit and because it also improves some diagnostic goodness for placeholder expressions. llvm-svn: 129065
* Silly mistake in integer constant folding cleanup.Eli Friedman2011-03-251-1/+1
| | | | llvm-svn: 128297
* Fix some clang warnings.Anders Carlsson2011-03-251-3/+3
| | | | llvm-svn: 128272
* Switch constant evaluation of float casts over to cast kinds.Eli Friedman2011-03-251-3/+13
| | | | llvm-svn: 128251
* Cleanup integral and vector constant evaluation of casts to use cast kinds.Eli Friedman2011-03-251-87/+105
| | | | llvm-svn: 128250
* Implement a new 'availability' attribute, that allows one to specifyDouglas Gregor2011-03-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | which versions of an OS provide a certain facility. For example, void foo() __attribute__((availability(macosx,introduced=10.2,deprecated=10.4,obsoleted=10.6))); says that the function "foo" was introduced in 10.2, deprecated in 10.4, and completely obsoleted in 10.6. This attribute ties in with the deployment targets (e.g., -mmacosx-version-min=10.1 specifies that we want to deploy back to Mac OS X 10.1). There are several concrete behaviors that this attribute enables, as illustrated with the function foo() above: - If we choose a deployment target >= Mac OS X 10.4, uses of "foo" will result in a deprecation warning, as if we had placed attribute((deprecated)) on it (but with a better diagnostic) - If we choose a deployment target >= Mac OS X 10.6, uses of "foo" will result in an "unavailable" warning (in C)/error (in C++), as if we had placed attribute((unavailable)) on it - If we choose a deployment target prior to 10.2, foo() is weak-imported (if it is a kind of entity that can be weak imported), as if we had placed the weak_import attribute on it. Naturally, there can be multiple availability attributes on a declaration, for different platforms; only the current platform matters when checking availability attributes. The only platforms this attribute currently works for are "ios" and "macosx", since we already have -mxxxx-version-min flags for them and we have experience there with macro tricks translating down to the deprecated/unavailable/weak_import attributes. The end goal is to open this up to other platforms, and even extension to other "platforms" that are really libraries (say, through a #pragma clang define_system), but that hasn't yet been designed and we may want to shake out more issues with this narrower problem first. Addresses <rdar://problem/6690412>. As a drive-by bug-fix, if an entity is both deprecated and unavailable, we only emit the "unavailable" diagnostic. llvm-svn: 128127
* Add support for the OpenCL vec_step operator, by generalising andPeter Collingbourne2011-03-111-26/+51
| | | | | | | extending the existing support for sizeof and alignof. Original patch by Guy Benyei. llvm-svn: 127475
* Overload IntExprEvaluator::Success() with a function that takes a CharUnitsKen Dyck2011-03-111-5/+10
| | | | | | parameter to tidy up the places where the expression is a size. llvm-svn: 127454
* Move private structs into anonymous namespaces.Benjamin Kramer2011-03-041-17/+17
| | | | llvm-svn: 126997
* Don't crash during constant-evaluation of 1/(1/0). PR9262.John McCall2011-02-261-1/+1
| | | | llvm-svn: 126541
* Change the representation of GNU ?: expressions to use a different expressionJohn McCall2011-02-171-10/+161
| | | | | | | | | | | | | | | | | | | | | | class and to bind the shared value using OpaqueValueExpr. This fixes an unnoticed problem with deserialization of these expressions where the deserialized form would lose the vital pointer-equality trait; or rather, it fixes it because this patch also does the right thing for deserializing OVEs. Change OVEs to not be a "temporary object" in the sense that copy elision is permitted. This new representation is not totally unawkward to work with, but I think that's really part and parcel with the semantics we're modelling here. In particular, it's much easier to fix things like the copy elision bug and to make the CFG look right. I've tried to update the analyzer to deal with this in at least some obvious cases, and I think we get a much better CFG out, but the printing of OpaqueValueExprs probably needs some work. llvm-svn: 125744
* AST, Sema, Serialization: add CUDAKernelCallExpr and related semantic actionsPeter Collingbourne2011-02-091-0/+1
| | | | llvm-svn: 125217
* Remove vtables from the Stmt hierarchy; this was pretty easy asJohn McCall2011-02-091-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | there were only three virtual methods of any significance. The primary way to grab child iterators now is with Stmt::child_range children(); Stmt::const_child_range children() const; where a child_range is just a std::pair of iterators suitable for being llvm::tie'd to some locals. I've left the old child_begin() and child_end() accessors in place, but it's probably a substantial penalty to grab the iterators individually now, since the switch-based dispatch is kindof inherently slower than vtable dispatch. Grabbing them together is probably a slight win over the status quo, although of course we could've achieved that with vtables, too. I also reclassified SwitchCase (correctly) as an abstract Stmt class, which (as the first such class that wasn't an Expr subclass) required some fiddling in a few places. There are somewhat gross metaprogramming hooks in place to ensure that new statements/expressions continue to implement getSourceRange() and children(). I had to work around a recent clang bug; dgregor actually fixed it already, but I didn't want to introduce a selfhosting dependency on ToT. llvm-svn: 125183
* An insomniac stab at making block declarations list the variables they closeJohn McCall2011-02-021-1/+1
| | | | | | | on, as well as more reliably limiting invalid references to locals from nested scopes. llvm-svn: 124721
* Use RecordLayout::getBaseClassOffset() where CharUnits are needed instead ofKen Dyck2011-01-261-7/+4
| | | | | | converting getBaseClassOffsetInBits() to CharUnits. llvm-svn: 124274
* Fix the computation of alignment for fields of packed+aligned structs.John McCall2011-01-201-8/+1
| | | | | | Part of the fix for PR8413. llvm-svn: 123904
* Replace calls to CharUnits::fromQuantity() with onesKen Dyck2011-01-181-13/+8
| | | | | | ASTContext::toCharUnitsFromBits() when converting from bit sizes to char units. llvm-svn: 123715
* Introduce a new expression kind, SubstNonTypeTemplateParmPackExpr,Douglas Gregor2011-01-151-0/+1
| | | | | | | | | that captures the substitution of a non-type template argument pack for a non-type template parameter pack within a pack expansion that cannot be fully expanded. This follows the approach taken by SubstTemplateTypeParmPackType. llvm-svn: 123506
* Replace a literal '8' with getCharWidth().Ken Dyck2011-01-141-1/+2
| | | | llvm-svn: 123421
* PR3558: mark "logically const" accessor methods in ASTContext as const,Jay Foad2011-01-121-14/+16
| | | | | | | and mark the fields they use as mutable. This allows us to remove a few const_casts. llvm-svn: 123314
* Implement the sizeof...(pack) expression to compute the length of aDouglas Gregor2011-01-041-1/+9
| | | | | | | | | parameter pack. Note that we're missing proper libclang support for the new SizeOfPackExpr expression node. llvm-svn: 122813
* Implement support for pack expansions whose pattern is a non-typeDouglas Gregor2011-01-031-0/+1
| | | | | | | | | | | | | | | | | template argument (described by an expression, of course). For example: template<int...> struct int_tuple { }; template<int ...Values> struct square { typedef int_tuple<(Values*Values)...> type; }; It also lays the foundation for pack expansions in an initializer-list. llvm-svn: 122751
* Change all self assignments X=X to (void)X, so that we can turn on aJeffrey Yasskin2010-12-231-1/+1
| | | | | | | | | new gcc warning that complains on self-assignments and self-initializations. Fix one bug found by the warning, in which one clang::OverloadCandidate constructor failed to initialize its FunctionTemplate member. llvm-svn: 122459
* Rewrite ComplexExprEvaluator::VisitCastExpr to use cast kinds, and fixJohn McCall2010-12-141-78/+109
| | | | | | | the basic casting logic to insert intermediate casts and preserve the exact complex-cast design. Fixes a crash in the test suite. llvm-svn: 121776
* Improved complex constants evaluation.Abramo Bagnara2010-12-111-2/+100
| | | | llvm-svn: 121616
* Remove the TypesCompatibleExprClass AST node. Merge its functionality into ↵Francois Pichet2010-12-081-11/+0
| | | | | | BinaryTypeTraitExpr. llvm-svn: 121298
* PR5207: Change APInt methods trunc(), sext(), zext(), sextOrTrunc() andJay Foad2010-12-071-4/+3
| | | | | | | | zextOrTrunc(), and APSInt methods extend(), extOrTrunc() and new method trunc(), to be const and to return a new value instead of modifying the object in place. llvm-svn: 121121
* Type traits intrinsic implementation: __is_base_of(T, U)Francois Pichet2010-12-071-0/+5
| | | | | | New AST node introduced: BinaryTypeTraitExpr; to be reused for more intrinsics. llvm-svn: 121074
* Rename CXXExprWithTemporaries -> ExprWithCleanups; there's no theoreticalJohn McCall2010-12-061-1/+1
| | | | | | reason this is limited to C++, and it's certainly not limited to temporaries. llvm-svn: 120996
* Simplify the ASTs by consolidating ObjCImplicitGetterSetterExpr and ↵John McCall2010-12-021-1/+0
| | | | | | | | ObjCPropertyRefExpr into the latter. llvm-svn: 120643
* Kill CK_Unknown and flesh out the documentation for the existing CastKinds.John McCall2010-11-161-29/+0
| | | | llvm-svn: 119331
* Add a new expression kind, OpaqueValueExpr, which is useful forJohn McCall2010-11-151-0/+1
| | | | | | | certain internal type-checking procedures as well as for representing certain implicitly-generated operations. Uses to follow. llvm-svn: 119289
* Add a few more complex-related cast kinds that arise due to arbitraryJohn McCall2010-11-141-1/+8
| | | | | | | | | | implicit conversions; the last batch was specific to promotions. I think this is the full set we need. I do think dividing the cast kinds into floating and integral is probably a good idea. Annotate a *lot* more C casts with useful cast kinds. llvm-svn: 119036
* Introduce five new cast kinds for various conversions into andJohn McCall2010-11-131-0/+2
| | | | | | between complex types. llvm-svn: 118994
* Introduce a null-to-pointer implicit cast kind.John McCall2010-11-131-0/+6
| | | | llvm-svn: 118966
* Split out -Wconversion warnings about constant precision into theirJohn McCall2010-11-091-3/+16
| | | | | | | | | | | own subcategory, -Wconstant-conversion, which is on by default. Tweak the constant folder to give better results in the invalid case of a negative shift amount. Implements rdar://problem/6792488 llvm-svn: 118636
* Rename getBaseClassOffset to getBaseClassOffsetInBits and introduce a ↵Anders Carlsson2010-10-311-2/+2
| | | | | | getBaseClassOffset which returns the offset in CharUnits. Do the same thing for getVBaseClassOffset. llvm-svn: 117881
* Teach the constant expr evaluator about derived-to-base casts when no ↵Anders Carlsson2010-10-311-0/+36
| | | | | | virtual bases are involved. Fixes PR5974. llvm-svn: 117868
* Don't try to evaluate the LHS or RHS of a member pointer binary operation. ↵Anders Carlsson2010-10-311-0/+4
| | | | | | Fixes PR8507. llvm-svn: 117850
* Eliminate usage of ObjCSuperExpr used forFariborz Jahanian2010-10-141-1/+0
| | | | | | | 'super' as receiver of property or a setter/getter methods. //rdar: //8525788 llvm-svn: 116483
* Permit constant evaluation of const floating-point variables withJohn McCall2010-10-091-0/+41
| | | | | | constant initializers. llvm-svn: 116138
* Eagerly evaluate type traits in Sema instead of lazily in AST. They actually ↵Sebastian Redl2010-09-131-1/+1
| | | | | | need Sema access to be correct, fixes coming up. llvm-svn: 113782
* First version of a testcase, plus fixes.Sebastian Redl2010-09-101-0/+6
| | | | llvm-svn: 113624
* Define and implement CXXNoexceptExpr. Create it in Sema.Sebastian Redl2010-09-101-0/+1
| | | | llvm-svn: 113623
OpenPOWER on IntegriCloud