summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaStmt.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Improve the error message for attempting to build a for range loop using aRichard Trieu2013-10-111-2/+17
| | | | | | | | | function parameter that has array type. Such a parameter will be treated as a pointer type instead, resulting in a missing begin function error is a suggestion to dereference the pointer. This provides a different, more informative diagnostic as well as point to the parameter declaration. llvm-svn: 192512
* ObjectiveC. ObjectiveC's collection selector expression inFariborz Jahanian2013-10-101-0/+3
| | | | | | | | the fereach loop must be a non-const lvalue expression as it will be assigned to at the beginning of the loop. // rdar://15123684 llvm-svn: 192399
* Remove support for arrays of runtime bound in C++1y, now they have been votedRichard Smith2013-10-011-2/+0
| | | | | | out of the working paper. This reverts r179962 and r179992. llvm-svn: 191718
* Refactor to use C++1y 'auto' semantics directly in lambdas with no specifiedRichard Smith2013-09-251-34/+47
| | | | | | | return type in C++1y mode. No functionality change intended. Extracted and tweaked from a patch by Faisal Vali! llvm-svn: 191354
* Note when a decl is used in AST files.Eli Friedman2013-09-051-2/+2
| | | | | | | | | | | | | | | When an AST file is built based on another AST file, it can use a decl from the fist file, and therefore mark the "isUsed" bit. We need to note this in the AST file so that the bit is set correctly when the second AST file is loaded. This patch introduces the distinction between setIsUsed() and markUsed() so that we don't call into the ASTMutationListener callback when it wouldn't be appropriate. Fixes PR16635. llvm-svn: 190016
* Cleanup of OpaquePtr. No functionality changes.Serge Pavlov2013-08-271-2/+2
| | | | | | | | - Some documenation were added. - Usages of OpaquePtr<A>.getAsVal<A>() were replaced by OpaquePtr<A>.get(). - Methods getAs and getAsVal were renamed to getPtrTo and getPtrAs respectively. llvm-svn: 189346
* Revert "Implement a rudimentary form of generic lambdas."Manuel Klimek2013-08-221-42/+24
| | | | | | This reverts commit 606f5d7a99b11957e057e4cd1f55f931f66a42c7. llvm-svn: 189004
* const'ify Sema::ActOnCXXTryBlock byRobert Wilhelm2013-08-221-7/+4
| | | | | | | | changing Parameter from MutableArrayRef to ArrayRef. No functionality change intended. llvm-svn: 188994
* Implement a rudimentary form of generic lambdas.Faisal Vali2013-08-221-24/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Specifically, the following features are not included in this commit: - any sort of capturing within generic lambdas - nested lambdas - conversion operator for captureless lambdas - ensuring all visitors are generic lambda aware As an example of what compiles: template <class F1, class F2> struct overload : F1, F2 { using F1::operator(); using F2::operator(); overload(F1 f1, F2 f2) : F1(f1), F2(f2) { } }; auto Recursive = [](auto Self, auto h, auto ... rest) { return 1 + Self(Self, rest...); }; auto Base = [](auto Self, auto h) { return 1; }; overload<decltype(Base), decltype(Recursive)> O(Base, Recursive); int num_params = O(O, 5, 3, "abc", 3.14, 'a'); Please see attached tests for more examples. Some implementation notes: - Add a new Declarator context => LambdaExprParameterContext to clang::Declarator to allow the use of 'auto' in declaring generic lambda parameters - Augment AutoType's constructor (similar to how variadic template-type-parameters ala TemplateTypeParmDecl are implemented) to accept an IsParameterPack to encode a generic lambda parameter pack. - Add various helpers to CXXRecordDecl to facilitate identifying and querying a closure class - LambdaScopeInfo (which maintains the current lambda's Sema state) was augmented to house the current depth of the template being parsed (id est the Parser calls Sema::RecordParsingTemplateParameterDepth) so that Sema::ActOnLambdaAutoParameter may use it to create the appropriate list of corresponding TemplateTypeParmDecl for each auto parameter identified within the generic lambda (also stored within the current LambdaScopeInfo). Additionally, a TemplateParameterList data-member was added to hold the invented TemplateParameterList AST node which will be much more useful once we teach TreeTransform how to transform generic lambdas. - SemaLambda.h was added to hold some common lambda utility functions (this file is likely to grow ...) - Teach Sema::ActOnStartOfFunctionDef to check whether it is being called to instantiate a generic lambda's call operator, and if so, push an appropriately prepared LambdaScopeInfo object on the stack. - Teach Sema::ActOnStartOfLambdaDefinition to set the return type of a lambda without a trailing return type to 'auto' in C++1y mode, and teach the return type deduction machinery in SemaStmt.cpp to process either C++11 and C++14 lambda's correctly depending on the flag. - various tests were added - but much more will be needed. A greatful thanks to all reviewers including Eli Friedman, James Dennett and the ever illuminating Richard Smith. And yet I am certain that I have allowed unidentified bugs to creep in; bugs, that I will do my best to slay, once identified! Thanks! llvm-svn: 188977
* If we find an error in the range expression in a range-based for loop, and theRichard Smith2013-08-211-7/+34
| | | | | | | loop variable has a type containing 'auto', set the declaration to be invalid (because we couldn't deduce its type) to prevent follow-on errors. llvm-svn: 188853
* const'ify Sema::ActOnCompoundStmt byRobert Wilhelm2013-08-191-8/+5
| | | | | | | | changing Parameter of Sema::ActOnCompoundStmt from MutableArrayRef to ArrayRef. No functionality change intended. llvm-svn: 188705
* PR16875: The return type of a dependent function type is visible when it'sRichard Smith2013-08-141-6/+20
| | | | | | | | | | | referenced as a member of the current instantiation. In that case, deduce the type of the function to a dependent type rather than exposing an undeduced auto type to the rest of the current instantiation. The standard doesn't really say that the type is dependent in this case; I'll bring this up with CWG. llvm-svn: 188410
* Add a new warning to -Wloop-analysis to detect suspicious increments orRichard Trieu2013-08-061-0/+99
| | | | | | | | decrements inside for loops. Idea for this warning proposed in PR15636: http://llvm.org/bugs/show_bug.cgi?id=15636 llvm-svn: 187817
* Handle a difference in lambda return type deduction between C++11 and C++1y: ifRichard Smith2013-07-261-2/+8
| | | | | | | no return type is specified, C++11 will deduce a cv-qualified return type in some cases, but C++1y never will. llvm-svn: 187275
* PR16708: If a lambda has an implicit return type, don't get confused if its ↵Richard Smith2013-07-261-17/+17
| | | | | | return type has already been determined to be a type containing an 'auto'. llvm-svn: 187266
* Use SmallVectorImpl& instead of SmallVector to avoid repeating small vector ↵Craig Topper2013-07-141-2/+2
| | | | | | size. llvm-svn: 186284
* ObjectiveC arc[qoi]: When due to change of certain methods'Fariborz Jahanian2013-07-111-4/+3
| | | | | | | | result type, a diagnostic being issued, issue a 'note' mentioning reason behind the unexpected warning. // rdar://14121570. llvm-svn: 186105
* ArrayRef'ize Sema::FinalizeDeclaratorGroup, Sema::BuildDeclaratorGroup andRafael Espindola2013-07-091-2/+4
| | | | | | | | Sema::ActOnDocumentableDecls. Patch by Robert Wilhelm. llvm-svn: 185931
* Objective-C: Warn when fast enumeration variable isn't used.Fariborz Jahanian2013-07-061-3/+0
| | | | | | // rdar://14182680. llvm-svn: 185762
* Use SmallVectorImpl instead of SmallVector for iterators and references to ↵Craig Topper2013-07-041-1/+1
| | | | | | avoid specifying the vector size unnecessarily. llvm-svn: 185610
* Fix a crash with -Wassign-enum, where we didn't adjust the APInt type of theJoey Gouly2013-06-061-10/+11
| | | | | | | | | | constant. Also fix some spelling mistakes and formatting issues. Reviewed by Richard Smith over IRC. Fixes PR15069. llvm-svn: 183409
* Fix the indentation on the AST visitors used in -Wloop-analysis.Richard Trieu2013-05-311-102/+103
| | | | llvm-svn: 183056
* Refactor places which perform contextual implicit conversions to go through aRichard Smith2013-05-211-21/+19
| | | | | | | | | | | | | common function. The C++1y contextual implicit conversion rules themselves are not yet implemented, however. This also fixes a subtle bug where template instantiation context notes were dropped for diagnostics coming from conversions for integral constant expressions -- we were implicitly slicing a SemaDiagnosticBuilder into a DiagnosticBuilder when producing these diagnostics, and losing their context notes in the process. llvm-svn: 182406
* First pass of semantic analysis for init-captures: check the initializer, buildRichard Smith2013-05-161-2/+2
| | | | | | | | | | | | | a FieldDecl from it, and propagate both into the closure type and the LambdaExpr. You can't do much useful with them yet -- you can't use them within the body of the lambda, because we don't have a representation for "the this of the lambda, not the this of the enclosing context". We also don't have support or a representation for a nested capture of an init-capture yet, which was intended to work despite not being allowed by the current standard wording. llvm-svn: 181985
* C++1y: provide full 'auto' return type deduction for lambda expressions. ThisRichard Smith2013-05-121-5/+19
| | | | | | completes the implementation of N3638. llvm-svn: 181669
* C++1y auto return type: when a function contains no 'return' statements at all,Richard Smith2013-05-101-3/+1
| | | | | | | substitute 'void' into the return type rather than replacing it with 'void', so that we maintain the 'auto' type sugar. llvm-svn: 181584
* Implement most of N3638 (return type deduction for normal functions).Richard Smith2013-05-041-3/+88
| | | | | | | Missing (somewhat ironically) is support for the new deduction rules in lambda functions, plus PCH support for return type patching. llvm-svn: 181108
* Implement template support for CapturedStmtWei Pan2013-05-041-6/+9
| | | | | | | | - Sema tests added and CodeGen tests are pending Differential Revision: http://llvm-reviews.chandlerc.com/D728 llvm-svn: 181101
* Test commitWei Pan2013-05-031-1/+1
| | | | llvm-svn: 181057
* Move CapturedStmt parameters to CapturedDeclBen Langmuir2013-05-031-5/+16
| | | | | | | | | | | Move the creation of CapturedStmt parameters out of CodeGen and into Sema, making it easier to customize the outlined function. The ImplicitParamDecls are stored in the CapturedDecl using an ASTContext-allocated array. Differential Revision: http://llvm-reviews.chandlerc.com/D722 llvm-svn: 181043
* ArrayRef'ize InitializationSequence constructor and ↵Dmitri Gribenko2013-05-031-2/+2
| | | | | | | | InitializationSequence::Diagnose() Patch by Robert Wilhelm. llvm-svn: 181022
* Move parsing of identifiers in MS-style inline assembly intoJohn McCall2013-05-031-1/+0
| | | | | | | | | | | | | | | | | | | | | the actual parser and support arbitrary id-expressions. We're actually basically set up to do arbitrary expressions here if we wanted to. Assembly operands permit things like A::x to be written regardless of language mode, which forces us to embellish the evaluation context logic somewhat. The logic here under template instantiation is incorrect; we need to preserve the fact that an expression was unevaluated. Of course, template instantiation in general is fishy here because we have no way of delaying semantic analysis in the MC parser. It's all just fishy. I've also fixed the serialization of MS asm statements. This commit depends on an LLVM commit. llvm-svn: 180976
* When deducing an 'auto' type, don't modify the type-as-written.Richard Smith2013-04-301-16/+12
| | | | llvm-svn: 180808
* Don't treat a non-deduced 'auto' type as being type-dependent. Instead, thereRichard Smith2013-04-301-4/+9
| | | | | | | | are now two distinct canonical 'AutoType's: one is the undeduced 'auto' placeholder type, and the other is a deduced-but-dependent type. All deduced-to-a-non-dependent-type cases are still non-canonical. llvm-svn: 180789
* Small CapturedStmt improvementsBen Langmuir2013-04-291-1/+1
| | | | | | | | | | | | | Add a CapturedStmt.h similar to Lambda.h to reduce the typing required to get to the CapturedRegionKind enum. This also allows codegen to access this enum without including Sema/ScopeInfo.h. Also removes some duplicated code for capturing 'this' between CapturedStmt and Lambda. Differential Revision: http://llvm-reviews.chandlerc.com/D712 llvm-svn: 180710
* Test commitBen Langmuir2013-04-291-1/+1
| | | | llvm-svn: 180709
* Disable VLA diagnostic in C++1y mode, and add some tests.Richard Smith2013-04-201-0/+2
| | | | | | | | | | | | Still to do here: - we have a collection of syntactic accepts-invalids to diagnose - support non-PODs in VLAs, including dynamic initialization / destruction - runtime checks (and throw std::bad_array_length) for bad bound - support VLA capture by reference in lambdas - properly support VLAs in range-based for (don't recompute bound) llvm-svn: 179962
* Sema for Captured StatementsTareq A. Siraj2013-04-161-0/+111
| | | | | | | | | | | | | Add CapturedDecl to be the DeclContext for CapturedStmt, and perform semantic analysis. Currently captures all variables by reference. TODO: templates Author: Ben Langmuir <ben.langmuir@intel.com> Differential Revision: http://llvm-reviews.chandlerc.com/D433 llvm-svn: 179618
* <rdar://problem/13540921> Fix a crasher when an Objective-C for-in loop gets ↵Douglas Gregor2013-04-081-8/+25
| | | | | | a non-variable iteration declaration. llvm-svn: 179053
* <rdar://problem/13540921> Cope with deduced 'auto' in a C++11 for-range loop ↵Douglas Gregor2013-04-081-0/+27
| | | | | | that is actually an Objective-C fast enumeration loop. llvm-svn: 179035
* Add 178663 back.Rafael Espindola2013-04-031-1/+1
| | | | | | | | | | | http://lab.llvm.org:8011/builders/clang-x86_64-darwin10-gdb went back green before it processed the reverted 178663, so it could not have been the culprit. Revert "Revert 178663." This reverts commit 4f8a3eb2ce5d4ba422483439e20c8cbb4d953a41. llvm-svn: 178682
* Revert 178663.Rafael Espindola2013-04-031-1/+1
| | | | | | | | | | Looks like it broke http://lab.llvm.org:8011/builders/clang-x86_64-darwin10-gdb Revert "Don't compute a patched/semantic storage class." This reverts commit 8f187f62cb0487d31bc4afdfcd47e11fe9a51d05. llvm-svn: 178681
* Don't compute a patched/semantic storage class.Rafael Espindola2013-04-031-1/+1
| | | | | | | | | | | For variables and functions clang used to store two storage classes. The one "as written" in the code and a patched one, which, for example, propagates static to the following decls. This apparently is from the days clang lacked linkage computation. It is now redundant and this patch removes it. llvm-svn: 178663
* Fix a crash-on-valid where a block capture copy expression wasJohn McCall2013-03-221-0/+5
| | | | | | | | | | | | picking up cleanups from earlier in the statement. Also fix a crash-on-invalid where a reference to an invalid decl from an enclosing scope was causing an expression to fail to build, but only *after* a cleanup was registered from that statement, causing an assertion downstream. The crash-on-valid is rdar://13459289. llvm-svn: 177692
* Add a clarifying note when a return statement is rejected becauseJohn McCall2013-03-191-20/+22
| | | | | | | | we expect a related result type. rdar://12493140 llvm-svn: 177378
* Silence a number of static analyzer warnings with assertions and such.Jordan Rose2013-03-051-0/+1
| | | | | | No functionality change. llvm-svn: 176469
* Warn on dropping the return value from a warn_unused_result function, even inMatt Beaumont-Gay2013-02-261-5/+17
| | | | | | macros. llvm-svn: 176114
* Replace TypeLoc llvm::cast support to be well-defined.David Blaikie2013-02-181-1/+1
| | | | | | | | | | | | | | The TypeLoc hierarchy used the llvm::cast machinery to perform undefined behavior by casting pointers/references to TypeLoc objects to derived types and then using the derived copy constructors (or even returning pointers to derived types that actually point to the original TypeLoc object). Some context is in this thread: http://lists.cs.uiuc.edu/pipermail/llvmdev/2012-December/056804.html Though it's spread over a few months which can be hard to read in the mail archive. llvm-svn: 175462
* When a statement is dropped from the AST because it was invalid, make sureArgyrios Kyrtzidis2013-02-151-0/+7
| | | | | | | we don't do the scope checks otherwise we are going to hit assertion checks since a label may not have been actually added. llvm-svn: 175281
* Patch to check for integer overflow. It has beenFariborz Jahanian2013-01-241-8/+7
| | | | | | commented on and approved by Richard Smith. llvm-svn: 173377
OpenPOWER on IntegriCloud