summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaStmt.cpp
Commit message (Collapse)AuthorAgeFilesLines
* 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
* Added an assert to IntegerLiteral to ensure that the integer type passed in ↵Richard Trieu2011-05-021-1/+2
| | | | | | | | has the same size as the APInt passed in. Also, updated the comments around IntegerLiteral. Changed the integer type that range-based for-loops used. Switched to pointer difference type, which satisfies the new assert in IntegerLiteral. llvm-svn: 130739
* Parsing/AST support for Structured Exception HandlingJohn Wiegley2011-04-281-0/+33
| | | | | | | | Patch authored by Sohail Somani. Provide parsing and AST support for Windows structured exception handling. llvm-svn: 130366
* If a null statement was preceded by an empty macro keep its instantiation ↵Argyrios Kyrtzidis2011-04-271-2/+3
| | | | | | | | source location in NullStmt. llvm-svn: 130289
* Make yet another placeholder type, this one marking that an expression is a ↵John McCall2011-04-261-6/+0
| | | | | | | | | | | bound member function, i.e. something of the form 'x.f' where 'f' is a non-static member function. Diagnose this in the general case. Some of the new diagnostics are probably worse than the old ones, but we now get this right much more universally, and there's certainly room for improvement in the diagnostics. llvm-svn: 130239
* Fix PR9741. The implicit declarations created for range-based for loops ↵Richard Smith2011-04-181-0/+2
| | | | | | weren't being added to the DeclContext (nor were they being marked as implicit). Also, the declarations were being emitted in the wrong order when building the CFG. llvm-svn: 129700
* Add support for C++0x's range-based for loops, as specified by the C++11 ↵Richard Smith2011-04-141-0/+382
| | | | | | draft standard (N3291). llvm-svn: 129541
* Use ExprResult& instead of Expr *& in SemaJohn Wiegley2011-04-081-14/+42
| | | | | | | | | | | | | | | | | | | | | | | | | This patch authored by Eric Niebler. Many methods on the Sema class (e.g. ConvertPropertyForRValue) take Expr pointers as in/out parameters (Expr *&). This is especially true for the routines that apply implicit conversions to nodes in-place. This design is workable only as long as those conversions cannot fail. If they are allowed to fail, they need a way to report their failures. The typical way of doing this in clang is to use an ExprResult, which has an extra bit to signal a valid/invalid state. Returning ExprResult is de riguour elsewhere in the Sema interface. We suggest changing the Expr *& parameters in the Sema interface to ExprResult &. This increases interface consistency and maintainability. This interface change is important for work supporting MS-style C++ properties. For reasons explained here <http://lists.cs.uiuc.edu/pipermail/cfe-dev/2011-February/013180.html>, seemingly trivial operations like rvalue/lvalue conversions that formerly could not fail now can. (The reason is that given the semantics of the feature, getter/setter method lookup cannot happen until the point of use, at which point it may be found that the method does not exist, or it may have the wrong type, or overload resolution may fail, or it may be inaccessible.) llvm-svn: 129143
* Lookup selector in protocol list of qualified objc typeFariborz Jahanian2011-03-091-1/+2
| | | | | | to avoid a bogus warning. // rdar:// 9072298 llvm-svn: 127355
* Fixed source range for LabelDecl.Abramo Bagnara2011-03-031-3/+2
| | | | llvm-svn: 126952
* Add a -fcxx-exceptions flag to the frontend, which can be used to enableAnders Carlsson2011-02-281-1/+1
| | | | | | | | | | C++ exceptions, even when exceptions have been turned off using -fno-exceptions. Make the -fobjc-exceptions flag do the same thing, but for Objective-C exceptions. C++ and Objective-C exceptions can also be disabled using -fno-cxx-excptions and -fno-objc-exceptions. llvm-svn: 126630
* compute the integer width, not the memory width here. We want to know thatChris Lattner2011-02-241-2/+1
| | | | | | | _Bool is 1 bit, not 8. This fixes an assertion on the testcase, which is PR9304 and rdar://9045501. llvm-svn: 126368
* Don't give an error for 'try' and 'throw' if they occur in system headers.Anders Carlsson2011-02-231-2/+4
| | | | llvm-svn: 126303
* Enhance Sema::DiagRuntimeBehavior() to delay some diagnostics to see if the ↵Ted Kremenek2011-02-231-1/+1
| | | | | | | | | | related code is reachable. This suppresses some diagnostics that occur in unreachable code (e.g., -Warray-bound). We only pay the cost of doing the reachability analysis when we issue one of these diagnostics. llvm-svn: 126290
* Update Sema::DiagRuntimeBehavior() to take an optional Stmt* to indicate the ↵Ted Kremenek2011-02-231-1/+1
| | | | | | | | | code the diagnostic is associated with. This Stmt* is unused, but we will use it shortly for pruning diagnostics associated with unreachable code. llvm-svn: 126286
* add one more case of mismatched input/output constraints. Chris Lattner2011-02-211-2/+16
| | | | | | | | | | | | | | | | | | | When the mismatch is due to a larger input operand that is a constant, truncate it down to the size of the output. This allows us to accept some cases in the linux kernel and elsewhere. Pedantically speaking, we generate different code than GCC, though I can't imagine how it would matter: Clang: movb $-1, %al frob %al GCC: movl $255, %eax frob %al llvm-svn: 126148
* more code restructuring, no functionality change.Chris Lattner2011-02-211-13/+7
| | | | llvm-svn: 126146
* split the iteration loop out to a helper function, no functionality change.Chris Lattner2011-02-211-34/+43
| | | | llvm-svn: 126145
* fix a comment.Chris Lattner2011-02-211-2/+2
| | | | llvm-svn: 126143
* Clean up the tests for warning about unused function results given theChandler Carruth2011-02-211-0/+2
| | | | | | | | appropriate attribute. Add a bit more testing that finds a pretty bad regression (since ~forever) in this warning. Fix it with a nice 2 line change. =] llvm-svn: 126098
* Add a new ObjCExceptions member variable to LangOptions. This controls ↵Anders Carlsson2011-02-191-0/+6
| | | | | | whether Objective-C exceptions are enabled or not (they are by default). llvm-svn: 126061
* There's no need to return early if we encounter a try/throw and exceptions ↵Anders Carlsson2011-02-191-1/+1
| | | | | | are disabled. llvm-svn: 126053
* Disallow try/catch/throw when exceptions are disabled.Anders Carlsson2011-02-191-0/+3
| | | | llvm-svn: 126039
* Switch labels over to using normal name lookup, instead of their Chris Lattner2011-02-181-35/+2
| | | | | | | own weird little DenseMap. Hey look, we now emit unused label warnings deterministically, amazing. llvm-svn: 125813
* Step #2/N of __label__ support: keep pushing LabelDecl forward,Chris Lattner2011-02-171-25/+18
| | | | | | | | | | making them be template instantiated in a more normal way and make them handle attributes like other decls. This fixes the used/unused label handling stuff, making it use the same infrastructure as other decls. llvm-svn: 125771
* Step #1/N of implementing support for __label__: split labels intoChris Lattner2011-02-171-24/+26
| | | | | | | | | | | | | | | | | | | LabelDecl and LabelStmt. There is a 1-1 correspondence between the two, but this simplifies a bunch of code by itself. This is because labels are the only place where we previously had references to random other statements, causing grief for AST serialization and other stuff. This does cause one regression (attr(unused) doesn't silence unused label warnings) which I'll address next. This does fix some minor bugs: 1. "The only valid attribute " diagnostic was capitalized. 2. Various diagnostics printed as ''labelname'' instead of 'labelname' 3. This reduces duplication of label checking between functions and blocks. Review appreciated, particularly for the cindex and template bits. llvm-svn: 125733
* Fix whitespace.NAKAMURA Takumi2011-01-271-85/+85
| | | | llvm-svn: 124364
* 7bit-ize.NAKAMURA Takumi2011-01-271-1/+1
| | | | llvm-svn: 124363
* Generalize the NRVO move-construction-based initialization routine. No ↵Douglas Gregor2011-01-211-30/+32
| | | | | | functionality change llvm-svn: 123996
* Implement the preference for move-construction over copy-constructionDouglas Gregor2011-01-211-12/+84
| | | | | | | | | | | | when returning an NRVO candidate expression. For example, this properly picks the move constructor when dealing with code such as MoveOnlyType f() { MoveOnlyType mot; return mot; } The previously-XFAIL'd rvalue-references test case now works, and has been moved into the appropriate paragraph-specific test case. llvm-svn: 123992
* We love parenthesesDouglas Gregor2011-01-211-2/+2
| | | | llvm-svn: 123983
OpenPOWER on IntegriCloud