summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExpr.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Implement rdar://6319320: give a good diagnostic for cases where peopleChris Lattner2008-11-171-0/+4
| | | | | | | are trying to use the old GCC "casts as lvalue" extension. We don't and will hopefully never support this. llvm-svn: 59460
* Fix <rdar://problem/6316324> [sema] spurious warning on comparison of ↵Steve Naroff2008-11-171-1/+9
| | | | | | qualified id. llvm-svn: 59459
* Add a new expression node, CXXOperatorCallExpr, which expresses aDouglas Gregor2008-11-141-6/+6
| | | | | | | | | | | | | | | | | | | 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-9/+4
| | | | | | candidates. Thanks to Chris for the review! llvm-svn: 59260
* Implement support for operator overloading using candidate operatorDouglas Gregor2008-11-121-49/+87
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-30/+32
| | | | | | expressions, both of values and types. llvm-svn: 59057
* Basic support for taking the address of an overloaded functionDouglas Gregor2008-11-101-1/+5
| | | | llvm-svn: 59000
* Implement Sema support for C++ nested-name-specifiers.Argyrios Kyrtzidis2008-11-081-2/+15
| | | | llvm-svn: 58916
* Implement support for C++ nested-name-specifiers ('foo::bar::x') in the ↵Argyrios Kyrtzidis2008-11-081-1/+2
| | | | | | | | Parser side. No Sema functionality change, just the signatures of the Action/Sema methods. llvm-svn: 58913
* Initial, rudimentary implementation of operator overloading for binaryDouglas Gregor2008-11-061-35/+143
| | | | | | | | | | | | | | | | | | operators. For example, one can now write "x + y" where x or y is a class or enumeration type, and Clang will perform overload resolution for "+" based on the overloaded operators it finds. The other kinds of overloadable operators in C++ will follow this same approach. Three major issues remain: 1) We don't find member operators 2) Since we don't have user-defined conversion operators, we can't call any of the built-in overloaded operators in C++ [over.built]. 3) Once we've done the semantic checks, we drop the overloaded operator on the floor; it doesn't get into the AST at all. llvm-svn: 58821
* Implement C++ copy-initialization for declarations. There is now someDouglas Gregor2008-11-051-1/+2
| | | | | | | | duplication in the handling of copy-initialization by constructor, which occurs both for initialization of a declaration and for overloading. The initialization code is due for some refactoring. llvm-svn: 58756
* Add a new expression class, ObjCSuperExpr, to handle the Objective-C ↵Douglas Gregor2008-11-041-1/+1
| | | | | | 'super'. Remove ObjCThis from PredefinedExpr llvm-svn: 58698
* Fix <rdar://problem/6339636> clang ObjC rewriter: Assertion failed: FileID-1 ↵Steve Naroff2008-11-031-1/+1
| | | | | | < FileIDs.size() && "Invalid FileID!", file c:\cygwin\home\Administrator\llvm\tools\clang\include\clang/Basic/SourceManager.h, line 513 llvm-svn: 58654
* Tweak Sema::CheckReferenceInit so that it (optionally) computes an Douglas Gregor2008-10-291-1/+1
| | | | | | | | | | | ImplicitConversionSequence and, when doing so, following the specific rules of [over.best.ics]. The computation of the implicit conversion sequences implements C++ [over.ics.ref], but we do not (yet) have ranking for implicit conversion sequences that use reference binding. llvm-svn: 58357
* Implement initialization of a reference (C++ [dcl.init.ref]) as partDouglas Gregor2008-10-291-7/+4
| | | | | | | | | | | | | | | | | | | 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-1/+1
| | | | llvm-svn: 58331
* Improve our handling of (C++) references within Clang. Specifically:Douglas Gregor2008-10-281-18/+24
| | | | | | | | | | | - 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-1/+1
| | | | | | | | | | | | | | | | | | | | | | - 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
* Fix <rdar://problem/6315646> clang on xcode: error: invalid operands to ↵Steve Naroff2008-10-271-5/+8
| | | | | | | | binary expression ('id<NSTableViewDelegate>' and 'XCExtendedArrayController *'). There is still a bug here (as the FIXME in the test case indicates). Prior to this patch, the bug would generate an error. Now, we simply do nothing (which is less harmful until we can get it right). The complete bug fix will require changing ASTContext::mergeTypes(), which I'd like to defer for now. llvm-svn: 58241
* Remember whether an initlist had a designator in the AST.Chris Lattner2008-10-261-1/+3
| | | | llvm-svn: 58218
* pass designators into sema. This completes parser-level designatorChris Lattner2008-10-261-1/+3
| | | | | | support as far as I know. llvm-svn: 58217
* Don't give a default argument to ASTContext::getFunctionType for the ↵Argyrios Kyrtzidis2008-10-261-1/+1
| | | | | | | | | TypeQuals parameter, it causes subtle bugs where TypeQuals, while necessary, are omitted from the call. -Remove the default argument. -Update all call sites of ASTContext::getFunctionType. llvm-svn: 58187
* -Add support for cv-qualifiers after function declarators.Argyrios Kyrtzidis2008-10-241-1/+3
| | | | | | -Add withConst/withVolatile/withRestrict methods to QualType class, that return the QualType plus the respective qualifier. llvm-svn: 58120
* Semantic analysis for C++ reinterpret_cast and const_cast. Patch by ↵Douglas Gregor2008-10-241-1/+1
| | | | | | Sebastian Redl. llvm-svn: 58094
* First non-embarrassing cut at checking for ambiguous derived-to-base Douglas Gregor2008-10-241-9/+2
| | | | | | | | | | conversions. Added PerformImplicitConversion, which follows an implicit conversion sequence computed by TryCopyInitialization and actually performs the implicit conversions, including the extra check for ambiguity mentioned above. llvm-svn: 58071
* Fix regression in comparison of qualified id; == operator was beingDaniel Dunbar2008-10-231-1/+3
| | | | | | created with LHS and RHS whose types didn't match. llvm-svn: 58049
* Fix <rdar://problem/6311947> clang on xcode (regression): error: use of ↵Steve Naroff2008-10-221-2/+2
| | | | | | | | undeclared identifier 'expandedValue'. Mea culpa: I introduced this regresson in the following 2 commits: r57529 (10/14), r57841 (10/20). llvm-svn: 58007
* Now that DeclRefExpr accepts a NamedDecl, use a DeclRefExpr for when a ↵Argyrios Kyrtzidis2008-10-221-4/+1
| | | | | | CXXFieldDecl is referenced inside a method. llvm-svn: 58000
* Fix <rdar://problem/6257675> error: member reference base type ↵Steve Naroff2008-10-221-0/+7
| | | | | | | | ('NSUserDefaults *') is not a structure or union. Teach Sema::ActOnMemberReferenceExpr() to look through local category implementations associated with the class. llvm-svn: 57995
* Move Sema::GetNonReferenceType to QualType::getNonReferenceType and make it ↵Douglas Gregor2008-10-221-1/+1
| | | | | | inline llvm-svn: 57951
* Initial step toward supporting qualification conversions (C++ 4.4).Douglas Gregor2008-10-211-3/+24
| | | | | | | | | | | | | | | | | | | | 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
* Fix use of dyn_cast.Daniel Dunbar2008-10-211-1/+1
| | | | llvm-svn: 57927
* Preliminary support for function overloadingDouglas Gregor2008-10-211-13/+71
| | | | llvm-svn: 57909
* Fix <rdar://problem/6268365> Parser rejects property (dot notation) access ↵Steve Naroff2008-10-201-1/+9
| | | | | | on id<protocol>. llvm-svn: 57850
* Sema::CheckCompareOperands() and ASTContext::mergeTypes(): Change handling ↵Steve Naroff2008-10-201-0/+7
| | | | | | of ObjC qualified id types to be consistent with gcc. This changes a handful of test case errors into warnings (diff will tell you which cases have changed). llvm-svn: 57841
* Fix rdar://6257721 by tightening up the block "snapshot" check, andChris Lattner2008-10-201-9/+39
| | | | | | move it to its own predicate to make it more clear. llvm-svn: 57796
* Downgrade incompatibilities with objc qualified types (e.g. id <P>) to warnings.Steve Naroff2008-10-141-1/+13
| | | | | | Note: One day, we should consider moving the actual diags to ObjCQualifiedIdTypesAreCompatible(), since it has more information on the actual problem. GCC currently emits slightly more instructive errors for some cases involving protocols. I added a FIXME to the code. llvm-svn: 57529
* Final phase of converting BlockDecls over to DeclContext. This is ↵Steve Naroff2008-10-101-64/+35
| | | | | | unfortunately a largish/complex diff, however it was necessry to pass all the current block tests. llvm-svn: 57337
* Instantiate the BlockDecl in ActOnBlockStart() so we can use it as a ↵Steve Naroff2008-10-081-4/+4
| | | | | | | | DeclContext. This required changes to attach the compound statement later on (like we do for functions). llvm-svn: 57304
* - Add BlockDecl AST node.Steve Naroff2008-10-081-2/+5
| | | | | | | | | | - 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
* simplify padding, just fold it into the earlier resize.Chris Lattner2008-09-301-7/+2
| | | | llvm-svn: 56880
* fix a potential buffer overrun that Eli noticedChris Lattner2008-09-301-0/+7
| | | | llvm-svn: 56879
* Add diagnostic for .{lo,hi,e,o} on odd-sized extended vectors.Daniel Dunbar2008-09-301-0/+2
| | | | llvm-svn: 56859
* Teach Sema::CheckAssignmentConstraints() to allow assignments between id and ↵Steve Naroff2008-09-291-2/+12
| | | | | | block pointer types (^{}). llvm-svn: 56793
* Change a NOTE to a FIXME based on feedback from clattner.Steve Naroff2008-09-281-2/+11
| | | | llvm-svn: 56775
* Fix <rdar://problem/6252108> assigning to argument passed to block should ↵Steve Naroff2008-09-281-1/+1
| | | | | | not require __block. llvm-svn: 56770
* Fix rdar://6251437, references to enum constant decls in a blockChris Lattner2008-09-281-2/+3
| | | | | | don't need a BlockDeclRefExpr. llvm-svn: 56766
* Fix <rdar://problem/6252216> compare block to NULL.Steve Naroff2008-09-281-0/+11
| | | | llvm-svn: 56764
* Fix <rdar://problem/6252226> parser thinks block argument is undefined ↵Steve Naroff2008-09-281-3/+8
| | | | | | identifier in NSServices.m llvm-svn: 56761
* Tweak Expr::isModifiableLvalue() and Expr::isLvalue() to better deal with ↵Steve Naroff2008-09-261-0/+4
| | | | | | | | BlockDeclRef exprs. This fixes <rdar://problem/6248392> clang: Error when using address of stack variable inside block. llvm-svn: 56652
OpenPOWER on IntegriCloud