summaryrefslogtreecommitdiffstats
path: root/clang/AST/Expr.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Now that we can refer to instance variables, make sure they are considered ↵Steve Naroff2007-11-121-0/+2
| | | | | | lvalues. llvm-svn: 44017
* Implement instance variable references.Steve Naroff2007-11-121-0/+4
| | | | llvm-svn: 44016
* Recognize ObjCStringLiteral as a constant expression.Steve Naroff2007-11-091-0/+1
| | | | llvm-svn: 43946
* Fix backwards assert.Chris Lattner2007-11-081-1/+1
| | | | llvm-svn: 43894
* Add a method prototype slot/getter to the ObjCMessageExpr AST.Steve Naroff2007-11-031-4/+8
| | | | llvm-svn: 43666
* Implement test/Sema/init.c by treating functions as constants.Chris Lattner2007-11-011-2/+5
| | | | llvm-svn: 43599
* __real__ and __imag__ can be lvalues. Add support to ast and codegen for them.Chris Lattner2007-10-301-2/+7
| | | | llvm-svn: 43525
* Add a new ChooseExpr::isConditionTrue method to unifyChris Lattner2007-10-251-0/+8
| | | | | | some code. llvm-svn: 43322
* Fixed DeclStmt::child_begin() to actually create an iterator thatTed Kremenek2007-10-181-26/+47
| | | | | | | | | | | | | visits its decls, rather than just creating an "end()" iterator. Fixed child_end() for statements and expressions to use child_iterator() to create the end() iterator, rather than just returning NULL. Fixed bug in StmtIterator where we did not correctly detect if we had marched off the end of the ScopedDecls. llvm-svn: 43156
* Make control flow in Expr::isConstantExpr more simple andChris Lattner2007-10-181-20/+12
| | | | | | local, making the code easier to read. llvm-svn: 43104
* Implementation of AST for @protocol expression.Fariborz Jahanian2007-10-171-0/+4
| | | | llvm-svn: 43075
* Generate code for static variables that don't have initializers. Also, ↵Anders Carlsson2007-10-171-1/+2
| | | | | | report an error if a static initializer is not constant. llvm-svn: 43058
* Patch to implement AST generation for objective-c's @selector expression.Fariborz Jahanian2007-10-161-0/+4
| | | | llvm-svn: 43038
* Move type compatibility predicates from Type to ASTContext. In addition, the ↵Steve Naroff2007-10-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | predicates are now instance methods (they were previously static class methods on Type). This allowed me to fix the following hack from this weekend... // FIXME: Devise a way to do this without using strcmp. // Would like to say..."return getAsStructureType() == IdStructType;", but // we don't have a pointer to ASTContext. bool Type::isObjcIdType() const { if (const RecordType *RT = getAsStructureType()) return !strcmp(RT->getDecl()->getName(), "objc_object"); return false; } ...which is now... bool isObjcIdType(QualType T) const { return T->getAsStructureType() == IdStructType; } Side notes: - I had to remove a convenience function from the TypesCompatibleExpr class. int typesAreCompatible() const {return Type::typesAreCompatible(Type1,Type2);} Which required a couple clients get a little more verbose... - Result = TCE->typesAreCompatible(); + Result = Ctx.typesAreCompatible(TCE->getArgType1(), TCE->getArgType2()); Overall, I think this change also makes sense for a couple reasons... 1) Since ASTContext vends types, it makes sense for the type compatibility API to be there. 2) This allows the type compatibility predeciates to refer to data not strictly present in the AST (which I have found problematic on several occasions). llvm-svn: 43009
* Add code generation and sema checking for __builtin_va_arg.Anders Carlsson2007-10-151-0/+9
| | | | llvm-svn: 43006
* move IdentifierTable.h from liblex to libbasic.Chris Lattner2007-10-071-1/+1
| | | | llvm-svn: 42730
* Yesterday I discovered that 78% of all selectors in "Cocoa.h" take 0/1 argument.Steve Naroff2007-09-281-21/+6
| | | | | | | | | | | | This motivated implementing a devious clattner inspired solution:-) This approach uses a small value "Selector" class to point to an IdentifierInfo for the 0/1 case. For multi-keyword selectors, we instantiate a MultiKeywordSelector object (previously known as SelectorInfo). Now, the incremental cost for selectors is only 24,800 for Cocoa.h! This saves 156,592 bytes, or 86%!! The size reduction is also the result of getting rid of the AST slot, which was not strictly necessary (we will associate a selector with it's method using another table...most likely in Sema). This change was critical to make now, before we have too many clients. I still need to add some comments to the Selector class...will likely add later today/tomorrow. llvm-svn: 42452
* Add SelectorInfo (similar in spirit to IdentifierInfo). The key difference ↵Steve Naroff2007-09-271-37/+37
| | | | | | | | | | | | | | | | | | | | is SelectorInfo is not string-oriented, it is a unique aggregate of IdentifierInfo's (using a folding set). SelectorInfo also has a richer API that simplifies the parser/action interface. 3 noteworthy benefits: #1: It is cleaner. I never "liked" storing keyword selectors (i.e. foo:bar:baz) in the IdentifierTable. #2: It is more space efficient. Since Cocoa keyword selectors can be quite long, this technique is space saving. For Cocoa.h, pulling the keyword selectors out saves ~180k. The cost of the SelectorInfo data is ~100k. Saves ~80k, or 43%. #3: It results in many API simplifications. Here are some highlights: - Removed 3 actions (ActOnKeywordMessage, ActOnUnaryMessage, & one flavor of ObjcBuildMethodDeclaration that was specific to unary messages). - Removed 3 funky structs from DeclSpec.h (ObjcKeywordMessage, ObjcKeywordDecl, and ObjcKeywordInfo). - Removed 2 ivars and 2 constructors from ObjCMessageExpr (fyi, this space savings has not been measured). I am happy with the way it turned out (though it took a bit more hacking than I expected). Given the central role of selectors in ObjC, making sure this is "right" will pay dividends later. Thanks to Chris for talking this through with me and suggesting this approach. llvm-svn: 42395
* objc messages have side effects, return true from hasLocalSideEffect,Chris Lattner2007-09-261-0/+2
| | | | | | | | | | fixing: VoidMethod.m:14:5: warning: expression result unused [Greeter hello]; ^~~~~~~~~~~~~~~ llvm-svn: 42380
* Handle (int)1.0e40 as an i-c-e.Chris Lattner2007-09-261-13/+10
| | | | llvm-svn: 42334
* use the right rounding mode.Chris Lattner2007-09-251-1/+1
| | | | llvm-svn: 42291
* Use the APFloat routines to evaluate FP immediates as Chris Lattner2007-09-221-10/+25
| | | | | | | | | | | | | | | | | | | | | | | integer constant expressions. The only questionable thing is that we now reject: void foo() { switch (1) { case (int)1.0e10000: ; } } with: t.c:5:13: error: case label does not reduce to an integer constant case (int)1.0e10000: ~~~~~^~~~~~~~~ GCC accepts this, emitting the pedwarn: t.c:5: warning: floating constant exceeds range of 'double' llvm-svn: 42238
* further apfloat'ize the front-end, allowing codegen to pass Chris Lattner2007-09-221-1/+1
| | | | | | APFloat straight through to LLVM now. llvm-svn: 42236
* Remove SelectorTable/SelectorInfo, simply store all selectors in the central ↵Steve Naroff2007-09-191-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | IdentifierTable. Rationale: We currently have a separate table to unique ObjC selectors. Since I don't need all the instance data in IdentifierInfo, I thought this would save space (and make more sense conceptually). It turns out the cost of having duplicate entries for unary selectors (i.e. names without colons) outweighs the cost difference between the IdentifierInfo & SelectorInfo structures. Here is the data: Two tables: *** Selector/Identifier Stats: # Selectors/Identifiers: 51635 Bytes allocated: 1999824 One table: *** Identifier Table Stats: # Identifiers: 49500 Bytes allocated: 1990316 llvm-svn: 42139
* Progress on message expressions...Steve Naroff2007-09-181-0/+56
| | | | | | | | | | | - Add ObjcMessageExpr AST node and associated constructors. - Add SourceLocation's to ActOnKeywordMessage/ActOnUnaryMessage API. - Instantiate message expressions... - Replace alloca usage with SmallString. Next step, installing a correct type, among other tweaks... llvm-svn: 42116
* Silenced a VC++ warning.Hartmut Kaiser2007-09-161-1/+2
| | | | | | Updated VC++ project files. llvm-svn: 42015
* Silence VC++ warnings, patch by Hartmut KaiserChris Lattner2007-09-041-9/+18
| | | | llvm-svn: 41693
* More progress on array initializers.Steve Naroff2007-09-021-0/+114
| | | | | | | | - Added Expr::isConstantExpr(). - Added type checking for InitListExpr elements. - Added diagnostic for trying to initialize a variable sized object. llvm-svn: 41674
* Add InitListExpr class.Anders Carlsson2007-08-311-0/+20
| | | | llvm-svn: 41636
* implement initial sema support for __builtin_offsetofChris Lattner2007-08-301-0/+1
| | | | llvm-svn: 41613
* Re-teach Expr::isNullPointerConstant() about ImplicitCastExpr:-)Steve Naroff2007-08-291-7/+2
| | | | | | | | | | This fixes the following bug submitted by Neil... const char *f (void) { return 0; } ...which would incorrectly warn with -pedantic enabled. llvm-svn: 41559
* Teach Expr::isNullPointerConstant() about ImplicitCastExpr's.Steve Naroff2007-08-281-0/+8
| | | | | | | | | | | | | | | | This fixes the following (recent) regression noticed by Keith Bauer (thanks!). void func(void *a); main() { void *p; p = 0; func(0); } ...which now works as you would expect. llvm-svn: 41557
* Fixed bug in child_begin/child_end for CallExpr where we incorrectly ↵Ted Kremenek2007-08-271-2/+2
| | | | | | | | calculated a Stmt** pointer based on an offset within SubExprs. llvm-svn: 41512
* add a new ImaginaryLiteral AST node that is used toChris Lattner2007-08-261-33/+23
| | | | | | | | | | | | | | | | | | represent imaginary literals: float _Complex A; void foo() { A = 1.0iF; } generates: (BinaryOperator 0x2305ec0 '_Complex float' '=' (DeclRefExpr 0x2305e60 '_Complex float' Decl='A' 0x2305cf0) (ImaginaryLiteral 0x2305f40 '_Complex float' (FloatingLiteral 0x2305ea0 'float' 1.000000)))) llvm-svn: 41413
* Surpress the UsualUnaryConversions for compound assignment operators. This ↵Steve Naroff2007-08-251-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | change eliminates the possibility that the left hand expression is an ImplicitCastExpr. As a result, I removed the check for ImplicitCastExpr in Expr::isLvalue(). This results in the following AST's... [dylan:~/llvm/tools/clang] admin% cat fix.c short x; void test4(char c) { x += c; x = x + c; } [dylan:~/llvm/tools/clang] admin% ../../Debug/bin/clang fix.c -parse-ast-dump Read top-level variable decl: 'x' void test4(char c) (CompoundStmt 0x2605d30 (CompoundAssignOperator 0x2605c40 'short' '+=' (DeclRefExpr 0x2605c00 'short' Decl='x' 0x2605a80) (DeclRefExpr 0x2605c20 'char' Decl='c' 0x2605bc0)) (BinaryOperator 0x2605d10 'short' '=' (DeclRefExpr 0x2605c60 'short' Decl='x' 0x2605a80) (ImplicitCastExpr 0x2605d00 'short' (BinaryOperator 0x2605ce0 'int' '+' (ImplicitCastExpr 0x2605cc0 'int' (DeclRefExpr 0x2605c80 'short' Decl='x' 0x2605a80)) (ImplicitCastExpr 0x2605cd0 'int' (DeclRefExpr 0x2605ca0 'char' Decl='c' 0x2605bc0)))))) llvm-svn: 41404
* Change Expr::isLvalue() to properly deal with ImplicitCastExpr's.Steve Naroff2007-08-251-0/+2
| | | | | | | | | | | This fixes the following bug... t.c:1:31: error: expression is not assignable short x; void foo(char c) { x += c; } This case, among others are now captured in implicit-casts.c. llvm-svn: 41402
* Split the ASTNode out for compound assignments out from binary operators. NowChris Lattner2007-08-251-1/+1
| | | | | | they show up in dumps etc. llvm-svn: 41393
* fix off-by-one errorChris Lattner2007-08-251-0/+2
| | | | llvm-svn: 41392
* Finished adding child_begin/child_end to all subclasses of Stmt in Expr.h.Ted Kremenek2007-08-241-18/+117
| | | | llvm-svn: 41366
* Began implementing "child iterator" interface for Stmts and Exprs. EachTed Kremenek2007-08-241-3/+76
| | | | | | | | | | | | | | | | | | | | | subclass of Stmt will implement child_begin() and child_end(), which will be used to iterate over all the children (subexpressions/substatements) of a Stmt object. This will provide for easy traversal over the AST, which is useful for a variety of purposes. None of the interfaces to subclasses of Stmt will be changed (other than adding the child_begin and child_end methods). The only caveat is that the implementation of subclasses of Stmt will require colocating all substatements (subexpressions) in an array. This is because we define child_iterator as Stmt**. All accessor methods to subexpressions will need to be altered to reflect this new implementation. This patch includes the typedefs for child_iterator, as well the implementation for child_begin/child_end for the primary expressions and some postfix expressions. llvm-svn: 41363
* sizeof(x) doesn't require x to be an i-c-e for sizeof to be an i-c-e. ↵Chris Lattner2007-08-231-2/+2
| | | | | | Thanks to Neil for pointing this out. llvm-svn: 41338
* Finish implementing __builtin_classify_type()...Steve Naroff2007-08-081-0/+77
| | | | llvm-svn: 40951
* Rename AddrLabel and OCUVectorComponent -> AddrLabelExpr and ↵Chris Lattner2007-08-031-8/+9
| | | | | | OCUVectorElementExpr respectively. This is for consistency with other expr nodes end with *Expr. llvm-svn: 40785
* add OCUVectorComponent::getNumComponents()Chris Lattner2007-08-031-1/+6
| | | | llvm-svn: 40778
* Add support for encoding a OCUVectorComponent into a single integer.Chris Lattner2007-08-021-0/+17
| | | | llvm-svn: 40768
* rename some helpers, have them return the idx of the field being accessed.Chris Lattner2007-08-021-3/+3
| | | | llvm-svn: 40764
* Use static methods, which don't require an instance of OCUVectorTypeChris Lattner2007-08-021-5/+7
| | | | llvm-svn: 40763
* Minor comment improvements.Chris Lattner2007-08-021-0/+4
| | | | llvm-svn: 40760
* Tweak to Expr::isIntegerConstantExpr...make sure the result is appropriately ↵Steve Naroff2007-08-021-2/+5
| | | | | | size for TypesCompatibleExpr's. llvm-svn: 40716
* Hack Expr::isConstantExpr() to allow for __builtin_types_compatible_p.Steve Naroff2007-08-021-0/+3
| | | | llvm-svn: 40705
OpenPOWER on IntegriCloud