summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/Expr.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Make CodeGen produce an error if we come across a non-constant initializer ↵Douglas Gregor2009-01-291-1/+1
| | | | | | list that involves the GNU array-range designator extension llvm-svn: 63327
* Introduce a new expression node, ImplicitValueInitExpr, thatDouglas Gregor2009-01-291-1/+12
| | | | | | | | | | | | | represents an implicit value-initialization of a subobject of a particular type. This replaces the (ab)use of CXXZeroValueInitExpr within initializer lists for the "holes" that occur due to the use of C99 designated initializers. The new test case is currently XFAIL'd, because CodeGen's ConstExprEmitter (in lib/CodeGen/CGExprConstant.cpp) needs to be taught to value-initialize when it sees ImplicitValueInitExprs. llvm-svn: 63317
* Clean up designated initialization of unions, so that CodeGen doesn'tDouglas Gregor2009-01-291-1/+2
| | | | | | have to try to guess which member is being initialized. llvm-svn: 63315
* Remove Expr::hasSideEffects. It doesn't work anywayDouglas Gregor2009-01-281-6/+0
| | | | llvm-svn: 63254
* Code generation support for C99 designated initializers.Douglas Gregor2009-01-281-2/+26
| | | | | | | | | | | | | | | | | | | | The approach I've taken in this patch is relatively straightforward, although the code itself is non-trivial. Essentially, as we process an initializer list we build up a fully-explicit representation of the initializer list, where each of the subobject initializations occurs in order. Designators serve to "fill in" subobject initializations in a non-linear way. The fully-explicit representation makes initializer lists (both with and without designators) easy to grok for codegen and later semantic analyses. We keep the syntactic form of the initializer list linked into the AST for those clients interested in exactly what the user wrote. Known limitations: - Designating a member of a union that isn't the first member may result in bogus initialization (we warn about this) - GNU array-range designators are not supported (we warn about this) llvm-svn: 63242
* Finish making AST BumpPtrAllocation runtime configurable (based on ↵Steve Naroff2009-01-271-4/+3
| | | | | | | | | | | -disable-free). snaroff% time ../../Release-Asserts/bin/clang INPUTS/Cocoa_h.m 0.179u 0.051s 0:00.23 95.6% 0+0k 0+0io 0pf+0w snaroff% time ../../Release-Asserts/bin/clang INPUTS/Cocoa_h.m -disable-free 0.169u 0.052s 0:00.22 95.4% 0+0k 0+0io 0pf+0w llvm-svn: 63153
* Fix compile error from r62953.Sebastian Redl2009-01-251-1/+2
| | | | llvm-svn: 62959
* One more case for Expr::isConstantInitializer; I think this covers Eli Friedman2009-01-251-0/+2
| | | | | | everything that we aren't intending to implement in Expr::Evaluate. llvm-svn: 62953
* Enhancements to Expr::isConstantInitializer to deal with a few Eli Friedman2009-01-251-6/+25
| | | | | | cases it couldn't deal with before. llvm-svn: 62952
* Rename Expr::isConstantExpr to Expr::isConstantInitializer; this more Eli Friedman2009-01-251-4/+3
| | | | | | | | accurately states what the function is trying to do and how it is different from Expr::isEvaluatable. Also get rid of a parameter that is both unused and inaccurate. llvm-svn: 62951
* Initial implementation of semantic analysis and ASTs for C99Douglas Gregor2009-01-221-0/+111
| | | | | | | | | | | | | | | | | | designated initializers. This implementation should cover all of the constraints in C99 6.7.8, including long, complex designations and computing the size of incomplete array types initialized with a designated initializer. Please see the new test-case and holler if you find cases where this doesn't work. There are still some wrinkles with GNU's anonymous structs and anonymous unions (it isn't clear how these should work; we'll just follow GCC's lead) and with designated initializers for the members of a union. I'll tackle those very soon. CodeGen is still nonexistent, and there's some leftover code in the parser's representation of designators that I'll also need to clean up. llvm-svn: 62737
* Support evaluation of vector constant expressions, and codegen of same.Nate Begeman2009-01-181-0/+5
| | | | llvm-svn: 62455
* A couple more vector component access fixes.Nate Begeman2009-01-181-0/+11
| | | | llvm-svn: 62443
* Update support for vector component access on ExtVectors.Nate Begeman2009-01-181-5/+8
| | | | llvm-svn: 62440
* Patch to supprt case of readonly property being Fariborz Jahanian2009-01-121-13/+1
| | | | | | | | assigned to when it has user declared setter method defined in the class implementation (but no declaration in the class itself). llvm-svn: 62098
* Add QualifiedDeclRefExpr, which retains additional source-locationDouglas Gregor2009-01-061-2/+5
| | | | | | | | | | | | | | | | | | | information for declarations that were referenced via a qualified-id, e.g., N::C::value. We keep track of the location of the start of the nested-name-specifier. Note that the difference between QualifiedDeclRefExpr and DeclRefExpr does have an effect on the semantics of function calls in two ways: 1) The use of a qualified-id instead of an unqualified-id suppresses argument-dependent lookup 2) If the name refers to a virtual function, the qualified-id version will call the function determined statically while the unqualified-id version will call the function determined dynamically (by looking up the appropriate function in the vtable). Neither of these features is implemented yet, but we do print out qualified names for QualifiedDeclRefExprs as part of the AST printing. llvm-svn: 61789
* PODness and Type TraitsSebastian Redl2009-01-051-0/+4
| | | | | | | | | | | | | | | Make C++ classes track the POD property (C++ [class]p4) Track the existence of a copy assignment operator. Implicitly declare the copy assignment operator if none is provided. Implement most of the parsing job for the G++ type traits extension. Fully implement the low-hanging fruit of the type traits: __is_pod: Whether a type is a POD. __is_class: Whether a type is a (non-union) class. __is_union: Whether a type is a union. __is_enum: Whether a type is an enum. __is_polymorphic: Whether a type is polymorphic (C++ [class.virtual]p1). llvm-svn: 61746
* Add support for calls to overloaded member functions. Things to note:Douglas Gregor2008-12-221-5/+6
| | | | | | | | | | | | - Overloading has to cope with having both static and non-static member functions in the overload set. - The call may or may not have an implicit object argument, depending on the syntax (x.f() vs. f()) and the context (static vs. non-static member function). - We now generate MemberExprs for implicit member access expression. - We now cope with mutable whenever we're building MemberExprs. llvm-svn: 61329
* Add support for member references (E1.E2, E1->E2) with C++ semantics,Douglas Gregor2008-12-201-16/+53
| | | | | | | | | | which can refer to static data members, enumerators, and member functions as well as to non-static data members. Implement correct lvalue computation for member references in C++. Compute the result type of non-static data members of reference type properly. llvm-svn: 61294
* Get rid of the old Expr::Evaluate variant.Anders Carlsson2008-12-191-3/+5
| | | | llvm-svn: 61260
* Implement the final (hopefully) wrinkle to i-c-e + builtin_constant_p Chris Lattner2008-12-121-7/+11
| | | | | | | processing: it allows arbitrary foldable constants as the operand of ?: when builtin_constant_p is the condition. llvm-svn: 60954
* add a fixme.Chris Lattner2008-12-121-0/+4
| | | | llvm-svn: 60935
* implement rdar://6091492 - ?: with __builtin_constant_p as the operand is an ↵Chris Lattner2008-12-121-1/+10
| | | | | | i-c-e. llvm-svn: 60934
* Fix rdar://6095061 - gcc allows __builtin_choose_expr as an lvalueChris Lattner2008-12-121-3/+9
| | | | llvm-svn: 60924
* Unifies the name-lookup mechanisms used in various parts of the ASTDouglas Gregor2008-12-111-5/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | and separates lexical name lookup from qualified name lookup. In particular: * Make DeclContext the central data structure for storing and looking up declarations within existing declarations, e.g., members of structs/unions/classes, enumerators in C++0x enums, members of C++ namespaces, and (later) members of Objective-C interfaces/implementations. DeclContext uses a lazily-constructed data structure optimized for fast lookup (array for small contexts, hash table for larger contexts). * Implement C++ qualified name lookup in terms of lookup into DeclContext. * Implement C++ unqualified name lookup in terms of qualified+unqualified name lookup (since unqualified lookup is not purely lexical in C++!) * Limit the use of the chains of declarations stored in IdentifierInfo to those names declared lexically. * Eliminate CXXFieldDecl, collapsing its behavior into FieldDecl. (FieldDecl is now a ScopedDecl). * Make RecordDecl into a DeclContext and eliminates its Members/NumMembers fields (since one can just iterate through the DeclContext to get the fields). llvm-svn: 60878
* Introduce basic support for dependent types, type-dependentDouglas Gregor2008-12-051-2/+28
| | | | | | | | | | | | expressions, and value-dependent expressions. This permits us to parse some template definitions. This is not a complete solution; we're missing type- and value-dependent computations for most of the expression types, and we're missing checks for dependent types and type-dependent expressions throughout Sema. llvm-svn: 60615
* Representation of template type parameters and non-type templateDouglas Gregor2008-12-051-0/+6
| | | | | | | | | | | | | | | parameters, with some semantic analysis: - Template parameters are introduced into template parameter scope - Complain about template parameter shadowing (except in Microsoft mode) Note that we leak template parameter declarations like crazy, a problem we'll remedy once we actually create proper declarations for templates. Next up: dependent types and value-dependent/type-dependent expressions. llvm-svn: 60597
* Fix some type punning errors in SizeOfAlignOf and Typeid AST nodes. This ↵Sebastian Redl2008-12-031-2/+2
| | | | | | should satisfy compilers and language lawyers alike. llvm-svn: 60511
* Revert change that made isNullPointerConstant start emitting warnings. We ↵Anders Carlsson2008-12-011-11/+9
| | | | | | don't want that :) llvm-svn: 60333
* Remove dead code.Anders Carlsson2008-12-011-3/+0
| | | | llvm-svn: 60320
* Add a new variant of isNullConstantExpr that returns an EvalResult.Anders Carlsson2008-12-011-5/+15
| | | | llvm-svn: 60318
* Implement the GNU __null extensionDouglas Gregor2008-11-291-1/+8
| | | | llvm-svn: 60235
* Refactored checking on readonly property into a method.Fariborz Jahanian2008-11-251-18/+7
| | | | llvm-svn: 60050
* Patch to allow over-riding of readonly property to Fariborz Jahanian2008-11-251-4/+18
| | | | | | a writable property in one of its category. llvm-svn: 60035
* Remove more #ifdeffed codeAnders Carlsson2008-11-251-144/+0
| | | | llvm-svn: 60033
* Reimplement Expr::isConstantExpr in terms of Expr::Evaluate. This fixes PR2832.Anders Carlsson2008-11-241-0/+25
| | | | llvm-svn: 59946
* Support for implicit property assignment. Error assigning toFariborz Jahanian2008-11-221-0/+6
| | | | | | 'implicit' property with no 'setter'. llvm-svn: 59878
* New AST node to access "implicit" setter/getter using property dor syntax.Fariborz Jahanian2008-11-221-0/+16
| | | | | | | Issuing diagnostics when assigning to read-only properties. This is work in progress. llvm-svn: 59874
* Implementation of new and delete parsing and sema.Sebastian Redl2008-11-211-3/+7
| | | | | | This version uses VLAs to represent arrays. I'll try an alternative way next, but I want this safe first. llvm-svn: 59835
* Enable some more operator overloading tests, and don't look into an ↵Douglas Gregor2008-11-211-0/+3
| | | | | | identifier for functions that might not have one llvm-svn: 59818
* Rename IdentifierInfo::isName to ::isStr. Use a nifty trickChris Lattner2008-11-201-4/+4
| | | | | | | from Sebastian to enforce that a literal string is passed in, and use this to avoid having to call strlen on it. llvm-svn: 59706
* Support overloading of the subscript operator[], including support forDouglas Gregor2008-11-191-0/+5
| | | | | | | | | built-in operator candidates. Test overloading of '&' and ','. In C++, a comma expression is an lvalue if its right-hand subexpression is an lvalue. Update Expr::isLvalue accordingly. llvm-svn: 59643
* Added operator overloading for unary operators, post-increment, andDouglas Gregor2008-11-191-0/+5
| | | | | | | | | | | | | post-decrement, including support for generating all of the built-in operator candidates for these operators. C++ and C have different rules for the arguments to the builtin unary '+' and '-'. Implemented both variants in Sema::ActOnUnaryOp. In C++, pre-increment and pre-decrement return lvalues. Update Expr::isLvalue accordingly. llvm-svn: 59638
* simplify some code.Chris Lattner2008-11-191-8/+7
| | | | llvm-svn: 59608
* Implement rdar://6319320: give a good diagnostic for cases where peopleChris Lattner2008-11-171-1/+9
| | | | | | | are trying to use the old GCC "casts as lvalue" extension. We don't and will hopefully never support this. llvm-svn: 59460
* rename Expr::tryEvaluate to Expr::Evaluate.Chris Lattner2008-11-161-1/+1
| | | | llvm-svn: 59426
* Add a new expression node, CXXOperatorCallExpr, which expresses aDouglas Gregor2008-11-141-3/+16
| | | | | | | | | | | | | | | | | | | function call created in response to the use of operator syntax that resolves to an overloaded operator in C++, e.g., "str1 + str2" that resolves to std::operator+(str1, str2)". We now build a CXXOperatorCallExpr in C++ when we pick an overloaded operator. (But only for binary operators, where we actually implement overloading) I decided *not* to refactor the current CallExpr to make it abstract (with FunctionCallExpr and CXXOperatorCallExpr as derived classes). Doing so would allow us to make CXXOperatorCallExpr a little bit smaller, at the cost of making the argument and callee accessors virtual. We won't know if this is going to be a win until we can parse lots of C++ code to determine how much memory we'll save by making this change vs. the performance penalty due to the extra virtual calls. llvm-svn: 59306
* Some cleanup for the implementation of built-in operatorDouglas Gregor2008-11-131-11/+10
| | | | | | candidates. Thanks to Chris for the review! llvm-svn: 59260
* Fix for crash issues with comma operators with a void first operand, and Eli Friedman2008-11-131-0/+6
| | | | | | | | | | some more bullet-proofing/enhancements for tryEvaluate. This shouldn't cause any behavior changes except for handling cases where we were crashing before and being able to evaluate a few more cases in tryEvaluate. This should settle the minor mess surrounding r59196. llvm-svn: 59224
* Backout of r59196, plus a new ICE test. Sorry if this is a Eli Friedman2008-11-131-18/+16
| | | | | | | | | | | | | | | | | | little rude; I figure it's cleaner to just back this out now so it doesn't get forgotten or mixed up with other checkins. The modification to isICE is simply wrong; I've added a test that the change to isICE breaks. I'm pretty sure the modification to tryEvaluate is also wrong. At the very least, there's some serious miscommunication going on here, as this is going in exactly the opposite direction of r59105. My understanding is that tryEvaluate is not supposed to care about side effects. That said, a lot of the clients to tryEvaluate are expecting it to enforce a no-side-effects policy, so we probably need another method that provides that guarantee. llvm-svn: 59212
OpenPOWER on IntegriCloud