summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaStmt.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Move block return type inference diagnostic to a common place whereFariborz Jahanian2011-12-031-14/+15
| | | | | | Function or array lvalue conversions happens. llvm-svn: 145782
* If block literal return type is not specified, return type of the block is Fariborz Jahanian2011-12-031-1/+11
| | | | | | | inferred from return types. All the return statements have to agree about the type. // rdar://10466373 llvm-svn: 145774
* Use Sema::RequireCompleteType to check for the completeness ofDouglas Gregor2011-11-141-7/+7
| | | | | | | | | | Objective-C classes. This has two purposes: to consistently provide "forward declaration here" notes when we hit an incomplete type, and to give LLDB a chance to complete the type. RequireCompleteType bits from Sean Callanan! llvm-svn: 144573
* Don't apply NRVO to over-aligned variables. The caller onlyJohn McCall2011-11-111-7/+23
| | | | | | guarantees alignment up to the ABI alignment of the return type. llvm-svn: 144364
* Change the AST representation of operations on Objective-CJohn McCall2011-11-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | property references to use a new PseudoObjectExpr expression which pairs a syntactic form of the expression with a set of semantic expressions implementing it. This should significantly reduce the complexity required elsewhere in the compiler to deal with these kinds of expressions (e.g. IR generation's special l-value kind, the static analyzer's Message abstraction), at the lower cost of specifically dealing with the odd AST structure of these expressions. It should also greatly simplify efforts to implement similar language features in the future, most notably Managed C++'s properties and indexed properties. Most of the effort here is in dealing with the various clients of the AST. I've gone ahead and simplified the ObjC rewriter's use of properties; other clients, like IR-gen and the static analyzer, have all the old complexity *and* all the new complexity, at least temporarily. Many thanks to Ted for writing and advising on the necessary changes to the static analyzer. I've xfailed a small diagnostics regression in the static analyzer at Ted's request. llvm-svn: 143867
* Rename Expr::Evaluate to Expr::EvaluateAsRValue to make it clear that it willRichard Smith2011-10-291-1/+2
| | | | | | | | implicitly perform an lvalue-to-rvalue conversion if used on an lvalue expression. Also improve the documentation of Expr::Evaluate* to indicate which of them will accept expressions with side-effects. llvm-svn: 143263
* Fix some cases where a CK_IntegralCast was being used to convert an lvalue to anRichard Smith2011-10-271-1/+7
| | | | | | | | | rvalue. An assertion to catch this is in ImpCastExprToType will follow, but vector operations currently trip over this (due to omitting the usual arithmetic conversions). Also add an assert to catch missing lvalue-to-rvalue conversions on the LHS of ->. llvm-svn: 143155
* objc: fix an ir-gen crash caused by recent Fariborz Jahanian2011-10-271-1/+1
| | | | | | property refactoring. // rdar://10327068 llvm-svn: 143139
* Restore r142914 and r142915, now with missing file and apparentJohn McCall2011-10-251-0/+4
| | | | | | GCC compiler workaround. llvm-svn: 142931
* Revert r142914 and r142915, due to possibly missing file.NAKAMURA Takumi2011-10-251-4/+0
| | | | | | r142914: "Introduce a placeholder type for "pseudo object"" r142915: "Pull the pseudo-object stuff into its own file." llvm-svn: 142921
* Introduce a placeholder type for "pseudo object"John McCall2011-10-251-0/+4
| | | | | | | | | | | | | | | expressions: expressions which refer to a logical rather than a physical l-value, where the logical object is actually accessed via custom getter/setter code. A subsequent patch will generalize the AST for these so that arbitrary "implementing" sub-expressions can be provided. Right now the only client is ObjC properties, but this should be generalizable to similar language features, e.g. Managed C++'s __property methods. llvm-svn: 142914
* Implement support for dependent Microsoft __if_exists/__if_not_existsDouglas Gregor2011-10-251-0/+23
| | | | | | | | | | statements. As noted in the documentation for the AST node, the semantics of __if_exists/__if_not_exists are somewhat different from the way Visual C++ implements them, because our parsed-template representation can't accommodate VC++ semantics without serious contortions. Hopefully this implementation is "good enough". llvm-svn: 142901
* Rework construction of CXXForRangeStmt not to recycle the same DeclRefExpr ↵Ted Kremenek2011-10-101-11/+33
| | | | | | | | | | in multiple subexpressions. This breaks the tree structure of the AST and completely breaks the CFG invariants. Patch by Jim Goodnow II and reviewed by Richard Smith! llvm-svn: 141586
* Constant expression evaluation refactoring:Richard Smith2011-10-101-4/+6
| | | | | | | | | | | - Remodel Expr::EvaluateAsInt to behave like the other EvaluateAs* functions, and add Expr::EvaluateKnownConstInt to capture the current fold-or-assert behaviour. - Factor out evaluation of bitfield bit widths. - Fix a few places which would evaluate an expression twice: once to determine whether it is a constant expression, then again to get the value. llvm-svn: 141561
* Removing a bunch of dead returns/breaks after llvm_unreachables.David Blaikie2011-09-231-1/+0
| | | | llvm-svn: 140407
* Switch assert(0/false) llvm_unreachable.David Blaikie2011-09-231-1/+1
| | | | llvm-svn: 140367
* PR10864: make sure we correctly delay type-checking for inline asm tied ↵Eli Friedman2011-09-141-0/+4
| | | | | | operands with dependent type. Patch by Likai Liu. llvm-svn: 139716
* Extend the ASTContext constructor to delay the initialization ofDouglas Gregor2011-09-021-3/+3
| | | | | | | | builtin types (When requested). This is another step toward making ASTUnit build the ASTContext as needed when loading an AST file, rather than doing so after the fact. No actual functionality change (yet). llvm-svn: 138985
* Don't try keeping a 'LeadingEmptyMacroLoc' in NullStmt. This failsArgyrios Kyrtzidis2011-09-011-2/+2
| | | | | | in the face of buffering C++/ObjC method bodies. llvm-svn: 138972
* Remove the last FIXMEs on -Wunused-comparison since it got moved toChandler Carruth2011-08-181-0/+4
| | | | | | | entirely use the existing -Wunused-value infrastructure. This also fixes a few missed cases for -Wunused in general. llvm-svn: 137916
* Reorganize the return-type vs. expression checking code inJohn McCall2011-08-171-30/+30
| | | | | | block returns; no functionality change. llvm-svn: 137884
* Gather cleanups correctly in block return statements.John McCall2011-08-171-12/+7
| | | | | | Thanks to Ted for finding this with magic tools. llvm-svn: 137877
* Treating the unused equality comparisons as something other than part ofChandler Carruth2011-08-171-66/+12
| | | | | | | | | | | | | | | | | | | | | -Wunused was a mistake. It resulted in duplicate warnings and lots of other hacks. Instead, this should be a special sub-category to -Wunused-value, much like -Wunused-result is. Moved to -Wunused-comparison, moved the implementation to piggy back on the -Wunused-value implementation instead of rolling its own, different mechanism for catching all of the "interesting" statements. I like the unused-value mechanism for this better, but its currently missing several top-level statements. For now, I've FIXME-ed out those test cases. I'll enhance the generic infrastructure to catch these statements in a subsequent patch. This patch also removes the cast-to-void fixit hint. This hint isn't available on any of the other -Wunused-value diagnostics, and if we want it to be, we should add it generically rather than in one specific case. llvm-svn: 137822
* Don't suggest assignment in implausible situation. We still warn, as theChandler Carruth2011-08-171-9/+15
| | | | | | | code is very likely to be buggy, but its going to require more significant changes on the part of the user to correct it in this case. llvm-svn: 137820
* Introduce a new warning, -Wtop-level-comparison. This warning isChandler Carruth2011-08-171-0/+101
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | a complement to the warnings we provide in condition expressions. Much like we warn on conditions such as: int x, y; ... if (x = y) ... // Almost always a typo of '==' This warning applies the complementary logic to "top-level" statements, or statements whose value is not consumed or used in some way: int x, y; ... x == y; // Almost always a type for '=' We also mirror the '!=' vs. '|=' logic. The warning is designed to fire even for overloaded operators for two reasons: 1) Especially in the presence of widespread templates that assume operator== and operator!= perform the expected comparison operations, it seems unreasonable to suppress warnings on the offchance that a user has written a class that abuses these operators, embedding side-effects or other magic within them. 2) There is a trivial source modification to silence the warning for truly exceptional cases: (void)(x == y); // No warning A (greatly reduced) form of this warning has already caught a number of bugs in our codebase, so there is precedent for it actually firing. That said, its currently off by default, but enabled under -Wall. There are several fixmes left here that I'm working on in follow-up patches, including de-duplicating warnings from -Wunused, sharing code with -Wunused's implementation (and creating a nice place to hook diagnostics on "top-level" statements), and handling cases where a proxy object with a bool conversion is returned, hiding the operation in the cleanup AST nodes. Suggestions for any of this code more than welcome. Also, I'd really love suggestions for better naming than "top-level". llvm-svn: 137819
* Do l-value conversion, etc., on a switch condition expression inJohn McCall2011-08-061-19/+16
| | | | | | | | | | ActOnStartOfSwitchStmt (i.e. before binding up a full-expression) instead of ActOnFinishSwitchStmt. Among other things, this means that property l-values are properly converted inside the full-expression. llvm-svn: 137014
* Specialize diag::warn_unused_call for the "warn_unused_result" attribute, soMatt Beaumont-Gay2011-08-041-2/+2
| | | | | | it can be controlled with a distinct flag. llvm-svn: 136941
* The lock operand to an @synchronized statement is also John McCall2011-07-271-15/+22
| | | | | | | supposed to be a full-expression; make it so. In ARC, make sure we retain the lock for the entire protected block. llvm-svn: 136271
* Add support for C++0x unicode string and character literals, from Craig Topper!Douglas Gregor2011-07-271-4/+4
| | | | llvm-svn: 136210
* Clean up the analysis of the collection operand to ObjCJohn McCall2011-07-271-32/+71
| | | | | | | | | | | for-in statements; specifically, make sure to close over any temporaries or cleanups it might require. In ARC, this has implications for the lifetime of the collection, so emit it with a retain and release it upon exit from the loop. rdar://problem/9817306 llvm-svn: 136204
* Move ArrayRef to LLVM.h and eliminate now-redundant qualifiers, patch by Jon ↵Chris Lattner2011-07-231-1/+1
| | | | | | Mulder! llvm-svn: 135855
* remove unneeded llvm:: namespace qualifiers on some core types now that ↵Chris Lattner2011-07-231-12/+12
| | | | | | | | LLVM.h imports them into the clang namespace. llvm-svn: 135852
* objc-arc: Fixes a crash @throw'ing an objc message.Fariborz Jahanian2011-07-201-1/+2
| | | | | | // pr10411 llvm-svn: 135638
* Properly implement the scope restriction on the NRVO forDouglas Gregor2011-07-061-2/+4
| | | | | | | | | | | | throw-expressions, such that we don't consider the NRVO when the non-volatile automatic object comes from outside the innermost try scope (C++0x [class.copymove]p13). In C++98/03, our ASTs were incorrect but it didn't matter because IR generation doesn't actually apply the NRVO here. In C++0x, however, we were moving from an object when in fact we should have copied from it. Fixes PR10142 / <rdar://problem/9714312>. llvm-svn: 134548
* Improve the wording of the warning when returning a value fromChandler Carruth2011-06-301-1/+10
| | | | | | | | a constructor or destructor. Patch by Hans Wennborg. llvm-svn: 134138
* Split out logic for valid clobbers and valid inline asm registers.Eric Christopher2011-06-281-2/+1
| | | | | | Fixes rdar://9281377 llvm-svn: 134016
* First part of PR9968: the __range variable in a dependent C++11 for-range ↵Richard Smith2011-06-211-0/+3
| | | | | | statement is implicitly used by that statement. llvm-svn: 133572
* Objective-C fast enumeration loop variables are not retained in ARC, butJohn McCall2011-06-171-15/+16
| | | | | | | | | | | | they should still be officially __strong for the purposes of errors, block capture, etc. Make a new bit on variables, isARCPseudoStrong(), and set this for 'self' and these enumeration-loop variables. Change the code that was looking for the old patterns to look for this bit, and change IR generation to find this bit and treat the resulting variable as __unsafe_unretained for the purposes of init/destroy in the two places it can come up. llvm-svn: 133243
* Be sure to try a final ARC-production even in Objective-C++.John McCall2011-06-161-1/+1
| | | | llvm-svn: 133215
* Automatic Reference Counting.John McCall2011-06-151-7/+44
| | | | | | | | | | Language-design credit goes to a lot of people, but I particularly want to single out Blaine Garst and Patrick Beard for their contributions. Compiler implementation credit goes to Argyrios, Doug, Fariborz, and myself, in no particular order. llvm-svn: 133103
* Implement Objective-C Related Result Type semantics.Douglas Gregor2011-06-111-3/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Related result types apply Cocoa conventions to the type of message sends and property accesses to Objective-C methods that are known to always return objects whose type is the same as the type of the receiving class (or a subclass thereof), such as +alloc and -init. This tightens up static type safety for Objective-C, so that we now diagnose mistakes like this: t.m:4:10: warning: incompatible pointer types initializing 'NSSet *' with an expression of type 'NSArray *' [-Wincompatible-pointer-types] NSSet *array = [[NSArray alloc] init]; ^ ~~~~~~~~~~~~~~~~~~~~~~ /System/Library/Frameworks/Foundation.framework/Headers/NSObject.h:72:1: note: instance method 'init' is assumed to return an instance of its receiver type ('NSArray *') - (id)init; ^ It also means that we get decent type inference when writing code in Objective-C++0x: auto array = [[NSMutableArray alloc] initWithObjects:@"one", @"two",nil]; // ^ now infers NSMutableArray* rather than id llvm-svn: 132868
* Remove all references to InitializationSequence::FailedSequence from outside ↵Sebastian Redl2011-06-051-3/+2
| | | | | | SemaInit.cpp. Replace them with the boolean conversion or the new Failed() function. This is a first step towards removing InitializationSequence::SequenceKind. No functionality change. llvm-svn: 132664
* Allow block returns in C++ with the formDouglas Gregor2011-06-051-2/+6
| | | | | | | | | return <expression> ; in blocks with a 'void' result type, so long as <expression> has type 'void'. This follows the rules for C++ functions. llvm-svn: 132658
* When inferring the result type of a block based on a return statementDouglas Gregor2011-06-051-9/+13
| | | | | | | | with a type-dependent expression, infer the placeholder type 'Context.DependentTy' to indicate that this is just a placeholder. Fixes PR9982 / <rdar://problem/9486685>. llvm-svn: 132657
* Fix 80-column violation.Francois Pichet2011-06-021-3/+6
| | | | llvm-svn: 132447
* Even a return statement of an expression with a dependent type in a voidNick Lewycky2011-06-011-20/+23
| | | | | | function might need to clean up its temporaries. Fixes PR10057. llvm-svn: 132390
* Introduce Type::isSignedIntegerOrEnumerationType() andDouglas Gregor2011-05-201-1/+2
| | | | | | | | | | | | | Type::isUnsignedIntegerOrEnumerationType(), which are like Type::isSignedIntegerType() and Type::isUnsignedIntegerType() but also consider the underlying type of a C++0x scoped enumeration type. Audited all callers to the existing functions, switching those that need to also handle scoped enumeration types (e.g., those that deal with constant values) over to the new functions. Fixes PR9923 / <rdar://problem/9447851>. llvm-svn: 131735
* Diagnose unexpanded parameter packs in return statements. ThisDouglas Gregor2011-05-201-0/+4
| | | | | | | manifested in a crash with blocks in PR9953, but it was a ticking time bomb for normal functions, too. Fixes PR9953. llvm-svn: 131731
* Clean up two commentsDouglas Gregor2011-05-201-1/+4
| | | | llvm-svn: 131727
* Use a heralded conversion to bool in inline-asm constraints.John McCall2011-05-101-1/+3
| | | | llvm-svn: 131170
OpenPOWER on IntegriCloud