summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/Expr.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
* Fix bug in constant evaluation exposed by 176.gcc.Daniel Dunbar2008-11-131-16/+18
| | | | | | | | | | | | - Evaluation of , operator used bogus assumption that LHS could be evaluated as an integral expression even though its type is unspecified. This change is making isICE very permissive of the LHS in non-evaluated contexts because it is not clear what predicate we would use to reject code here. The standard didn't offer me any guidance; opinions? llvm-svn: 59196
* Implement support for operator overloading using candidate operatorDouglas Gregor2008-11-121-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | functions for built-in operators, e.g., the builtin bool operator==(int const*, int const*) can be used for the expression "x1 == x2" given: struct X { operator int const*(); } x1, x2; The scheme for handling these built-in operators is relatively simple: for each candidate required by the standard, create a special kind of candidate function for the built-in. If overload resolution picks the built-in operator, we perform the appropriate conversions on the arguments and then let the normal built-in operator take care of it. There may be some optimization opportunity left: if we can reduce the number of built-in operator overloads we generate, overload resolution for these cases will go faster. However, one must be careful when doing this: GCC generates too few operator overloads in our little test program, and fails to compile it because none of the overloads it generates match. Note that we only support operator overload for non-member binary operators at the moment. The other operators will follow. As part of this change, ImplicitCastExpr can now be an lvalue. llvm-svn: 59148
* Introduce a single AST node SizeOfAlignOfExpr for all sizeof and alignof ↵Sebastian Redl2008-11-111-65/+48
| | | | | | expressions, both of values and types. llvm-svn: 59057
* Implement C++ 'typeid' parsing and sema.Sebastian Redl2008-11-111-0/+3
| | | | llvm-svn: 59042
* Add a new expression class, ObjCSuperExpr, to handle the Objective-C ↵Douglas Gregor2008-11-041-0/+4
| | | | | | 'super'. Remove ObjCThis from PredefinedExpr llvm-svn: 58698
* Create a new expression class, CXXThisExpr, to handle the C++ 'this' primary ↵Douglas Gregor2008-11-041-3/+3
| | | | | | expression. Remove CXXThis from PredefinedExpr llvm-svn: 58695
* Trivial style fix.Sebastian Redl2008-11-041-1/+1
| | | | llvm-svn: 58689
* Implement semantic checking of static_cast and dynamic_cast.Sebastian Redl2008-10-311-8/+10
| | | | llvm-svn: 58509
* Implement initialization of a reference (C++ [dcl.init.ref]) as partDouglas Gregor2008-10-291-2/+9
| | | | | | | | | | | | | | | | | | | of copy initialization. Other pieces of the puzzle: - Try/Perform-ImplicitConversion now handles implicit conversions that don't involve references. - Try/Perform-CopyInitialization uses CheckSingleAssignmentConstraints for C. PerformCopyInitialization is now used for all argument passing and returning values from a function. - Diagnose errors with declaring references and const values without an initializer. (Uses a new Action callback, ActOnUninitializedDecl). We do not yet have implicit conversion sequences for reference binding, which means that we don't have any overloading support for reference parameters yet. llvm-svn: 58353
* Rename ExplicitCCastExpr to CStyleCastExprDouglas Gregor2008-10-281-4/+4
| | | | llvm-svn: 58331
* Replace a dyn_cast with a cast when we know the exact typeDouglas Gregor2008-10-281-1/+1
| | | | llvm-svn: 58330
* Improve our handling of (C++) references within Clang. Specifically:Douglas Gregor2008-10-281-0/+29
| | | | | | | | | | | - Do not allow expressions to ever have reference type - Extend Expr::isLvalue to handle more cases where having written a reference into the source implies that the expression is an lvalue (e.g., function calls, C++ casts). - Make GRExprEngine::VisitCall treat the call arguments as lvalues when they are being bound to a reference parameter. llvm-svn: 58306
* Refactor the expression class hierarchy for casts. Most importantly:Douglas Gregor2008-10-271-3/+3
| | | | | | | | | | | | | | | | | | | | | | - CastExpr is the root of all casts - ImplicitCastExpr is (still) used for all explicit casts - ExplicitCastExpr is now the root of all *explicit* casts - ExplicitCCastExpr (new name needed!?) is a C-style cast in C or C++ - CXXFunctionalCastExpr inherits from ExplicitCastExpr - CXXNamedCastExpr inherits from ExplicitCastExpr and is the root of all of the C++ named cast expression types (static_cast, dynamic_cast, etc.) - Added classes CXXStaticCastExpr, CXXDynamicCastExpr, CXXReinterpretCastExpr, and CXXConstCastExpr to Also, fixed returned-stack-addr.cpp, which broke once when we fixed reinterpret_cast to diagnose double->int* conversions and again when we eliminated implicit conversions to reference types. The fix is in both testcase and SemaChecking.cpp. Most of this patch is simply support for the renaming. There's very little actual change in semantics. llvm-svn: 58264
* - Move ExprIterator to Stmt.h so that it can be used by classes defined in ↵Ted Kremenek2008-10-271-0/+13
| | | | | | | | | Stmt.h - Implement child_begin() and child_end() for AsmStmt. Previously these had stub implementations that did not iterate over the input/output operands of an inline assembly statement. - Use ExprIterator for performing iteration over input/output operands. llvm-svn: 58261
* Remember whether an initlist had a designator in the AST.Chris Lattner2008-10-261-6/+5
| | | | llvm-svn: 58218
* PR2919: __builtin_types_compatible_p strips CRV qualifiers.Daniel Dunbar2008-10-241-1/+7
| | | | llvm-svn: 58079
* Now that DeclRefExpr accepts a NamedDecl, use a DeclRefExpr for when a ↵Argyrios Kyrtzidis2008-10-221-1/+1
| | | | | | CXXFieldDecl is referenced inside a method. llvm-svn: 58000
* QualType::isMoreQualifiedThan and isAtLeastAsQualifiedAs assert that weDouglas Gregor2008-10-221-6/+11
| | | | | | | | | aren't trying to compare with address-space qualifiers (for now). Clean up handing of DeclRefExprs in Expr::isLvalue and refactor part of the check into a static DeclCanBeLvalue. llvm-svn: 57980
* Functions can be lvalues in C++, but not modifiable lvaluesDouglas Gregor2008-10-221-1/+7
| | | | llvm-svn: 57941
* Initial step toward supporting qualification conversions (C++ 4.4).Douglas Gregor2008-10-211-3/+11
| | | | | | | | | | | | | | | | | | | | Changes: - Sema::IsQualificationConversion determines whether we have a qualification conversion. - Sema::CheckSingleAssignment constraints now follows the C++ rules in C++, performing an implicit conversion from the right-hand side to the type of the left-hand side rather than checking based on the C notion of "compatibility". We now rely on the implicit-conversion code to determine whether the conversion can happen or not. Sema::TryCopyInitialization has an ugly reference-related hack to cope with the initialization of references, for now. - When building DeclRefExprs, strip away the reference type, since there are no expressions whose type is a reference. We'll need to do this throughout Sema. - Expr::isLvalue now permits functions to be lvalues in C++ (but not in C). llvm-svn: 57935
* Adjust calls to APFloat conversion for new interface.Dale Johannesen2008-10-091-3/+7
| | | | llvm-svn: 57332
* - Add BlockDecl AST node.Steve Naroff2008-10-081-2/+9
| | | | | | | | | | - Modify BlockExpr to reference the BlockDecl. This is "cleanup" necessary to improve our lookup semantics for blocks (to fix <rdar://problem/6272905> clang block rewriter: parameter to function not imported into block?). Still some follow-up work to finish this (forthcoming). llvm-svn: 57298
* A little more tweaking with StmtIterator and SizeOfAlignofExpr. A recent ↵Ted Kremenek2008-10-071-2/+2
| | | | | | commit actually introduced a regression, not fixed a bug. llvm-svn: 57282
* Fixed a masked bug when iterating over the child expressions of ↵Ted Kremenek2008-10-071-2/+2
| | | | | | SizeOfAlignOfTypeExpr. This bug was unmasked by recent changes to StmtIterator. llvm-svn: 57273
* Add a Expr::isEvaluatable method, eliminate isBuiltinConstantExprChris Lattner2008-10-061-7/+4
| | | | | | | which is checking for something that can be inconsistent with what we can constant fold. llvm-svn: 57159
* Move folding of __builtin_classify_type out of the CallExprChris Lattner2008-10-061-61/+13
| | | | | | interface into the constant folding interface. llvm-svn: 57158
* Add a comment that describes tryEvaluate. Make tryEvaluate foldChris Lattner2008-10-061-1/+1
| | | | | | | __builtin_constant_p properly, and add some scaffolding for FloatExprEvaluator to eventually handle huge_val and inf. llvm-svn: 57152
* add a new CallExpr::isBuiltinCall() method, and use it to simplify some existingChris Lattner2008-10-061-63/+56
| | | | | | code. llvm-svn: 57151
* a more efficient test for __builtin_classify_typeChris Lattner2008-10-061-1/+2
| | | | llvm-svn: 57149
* Add Builtins.def attribute for "can be a constant expression".Daniel Dunbar2008-10-021-6/+3
| | | | | | | | | | | | | | - Enabled for builtins which are always constant expressions (__builtin_huge_val*, __builtin_inf*, __builtin_constant_p, __builtin_classify_type, __builtin___CFStringMakeConstantString). Added Builtin::Context::isConstantExpr. - Currently overly simply interface which only works for builtins whose constantexprness does not depend on their arguments. CallExpr::isBuiltinConstantExpr now takes an ASTContext argument. llvm-svn: 56983
* Internally store the body of a BlockExpr using a Stmt* instead of a ↵Ted Kremenek2008-09-261-9/+4
| | | | | | CompoundStmt*, and use the getBody() method to do the appropriate checking. This both removes the type-punning warnings in Expr.cpp and also makes BlockExpr have more consistency checks against modifications to its body (via StmtIterator). llvm-svn: 56710
* Tweak Expr::isModifiableLvalue() and Expr::isLvalue() to better deal with ↵Steve Naroff2008-09-261-1/+10
| | | | | | | | BlockDeclRef exprs. This fixes <rdar://problem/6248392> clang: Error when using address of stack variable inside block. llvm-svn: 56652
* Bug fix, result of isIntegerConstantExpr could be of incorrect widthDaniel Dunbar2008-09-221-26/+29
| | | | | | | for type. - PR2817 llvm-svn: 56482
* Remove BlockStmtExpr. Steve Naroff2008-09-171-2/+2
| | | | | | | | Block literals are now represented by the concrete BlockExpr class. This is cleanup (removes a FIXME). No functionality change. llvm-svn: 56288
* Remove support for BlockExprExpr. For example...Steve Naroff2008-09-161-6/+0
| | | | | | | | ^(expression) or ^(int arg1, float arg2)(expression) ...is no longer supported. All block literals now require a compound statement. llvm-svn: 56257
* CXXConditionDeclExpr expression node is an lvalue.Argyrios Kyrtzidis2008-09-111-0/+2
| | | | llvm-svn: 56093
* More type checking for blocks. Still incomplete (will hopefully finish up ↵Steve Naroff2008-09-051-0/+8
| | | | | | this weekend). llvm-svn: 55862
* Fix a handful of typos (closure->block) to avoid confusion.Steve Naroff2008-09-041-1/+1
| | | | llvm-svn: 55768
* Add semantic analysis for "blocks". Steve Naroff2008-09-031-0/+22
| | | | | | | | | | | | | | | Highlights... - 4 new AST nodes, BlockExpr, BlockStmtExpr, BlockExprExpr, BlockDeclRefExpr. - Sema::ActOnBlockStart(), ActOnBlockError(), ActOnBlockStmtExpr(), ActOnBlockExprExpr(), ActOnBlockReturnStmt(). Next steps... - hack Sema::ActOnIdentifierExpr() to deal with block decl refs. - add attribute handler for byref decls. - add test cases. llvm-svn: 55710
* Fix isIntegerConstantExpr eval of __builtin_offsetof to return resultDaniel Dunbar2008-08-281-0/+1
| | | | | | | | | with correct width. - PR2728. Also, fix PR2727 test case. llvm-svn: 55493
* Fix double-free error with sizeof applied to VLA types.Daniel Dunbar2008-08-281-0/+5
| | | | | | | | - PR2727. Also, fix warning in CodeGenTypes for new BlockPointer type. llvm-svn: 55479
* Handle emitting __builtin_huge_valf as a constant expr.Anders Carlsson2008-08-251-1/+2
| | | | llvm-svn: 55299
* treat bool literals as constatnt expressions.Anders Carlsson2008-08-231-0/+7
| | | | llvm-svn: 55255
* Add CodeGen support for CXXZeroInitValueExpr.Argyrios Kyrtzidis2008-08-231-0/+3
| | | | llvm-svn: 55249
* Handle AddrLabelExprs in Expr::isConstantExprAnders Carlsson2008-08-231-0/+1
| | | | llvm-svn: 55245
OpenPOWER on IntegriCloud