summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaStmt.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Hide the concept of diagnostic levels from lex, parse and semaAlp Toker2014-06-151-9/+5
| | | | | | | | | | | | | | | | The compilation pipeline doesn't actually need to know about the high-level concept of diagnostic mappings, and hiding the final computed level presents several simplifications and other potential benefits. The only exceptions are opportunistic checks to see whether expensive code paths can be avoided for diagnostics that are guaranteed to be ignored at a certain SourceLocation. This commit formalizes that invariant by introducing and using DiagnosticsEngine::isIgnored() in place of individual level checks throughout lex, parse and sema. llvm-svn: 211005
* [OPENMP] Loop canonical form analysis (Sema)Alexander Musman2014-06-031-0/+6
| | | | | | | | | This patch implements semantic analysis to make sure that the loop is in OpenMP canonical form. This is the form required for 'omp simd', 'omp for' and other loop pragmas. Differential revision: http://reviews.llvm.org/D3778 llvm-svn: 210095
* Refactoring. Remove Owned method from Sema.Nikola Smiljanic2014-05-291-59/+50
| | | | llvm-svn: 209812
* Refactoring. Remove release and take methods from ActionResult. Rename ↵Nikola Smiljanic2014-05-291-42/+42
| | | | | | takeAs to getAs. llvm-svn: 209800
* [C++11] Use 'nullptr'. Sema edition.Craig Topper2014-05-261-32/+33
| | | | llvm-svn: 209613
* Improved recovery of switch statementSerge Pavlov2014-05-211-2/+4
| | | | | | | | | Make better diagnostic produced by erroneous switch statement. It fixes PR19022. Differential Revision: http://reviews.llvm.org/D3137 llvm-svn: 209302
* [OPENMP] Fix warning in Release builds.Alexey Bataev2014-05-141-0/+9
| | | | llvm-svn: 208768
* [OPENMP] Initial codegen for '#pragma omp parallel'Alexey Bataev2014-05-061-15/+57
| | | | llvm-svn: 208077
* Rewrite NRVO determination. Track NRVO candidates on the parser Scope and ↵Nick Lewycky2014-05-031-40/+67
| | | | | | | | apply the NRVO candidate flag to all possible NRVO candidates here, and remove the flags in computeNRVO or upon template instantiation. A variable now has NRVO applied if and only if every return statement in that scope returns that variable. This is nearly optimal. Performs NRVO roughly 7% more often in a bootstrap build of clang. Patch co-authored by Richard Smith. llvm-svn: 207890
* Implement [over.match.oper]p3 properly, by filtering the non-candidates outRichard Smith2014-04-171-1/+2
| | | | | | | when building the candidate set, rather than trying to contort name lookup into handling this. llvm-svn: 206436
* [C++11] Replacing DeclStmt iterators decl_begin() and decl_end() with ↵Aaron Ballman2014-03-141-5/+4
| | | | | | iterator_range decls(). Updating all of the usages of the iterators with range-based for loops. llvm-svn: 203947
* [C++11] Add 'override' keyword to virtual methods that override their base ↵Craig Topper2014-03-121-14/+14
| | | | | | class. llvm-svn: 203640
* Move the warning about unused relational comparison from -Wunused-value toRichard Trieu2014-03-111-7/+20
| | | | | | | -Wunused-comparison. Also, newly warn on unused result from overloaded relational comparisons, now also in -Wunused-comparison. llvm-svn: 203535
* Reverting llvm::distance changes to use std::distance with iterators ↵Aaron Ballman2014-03-101-2/+1
| | | | | | | | instead, per post-commit review feedback. Replacing llvm::copy changes with SmallVector range-based construction which is a considerably cleaner approach. llvm-svn: 203461
* [C++11] Replacing RecordDecl iterators field_begin() and field_end() with ↵Aaron Ballman2014-03-081-3/+1
| | | | | | iterator_range fields(). Updating all of the usages of the iterators with range-based for loops. llvm-svn: 203355
* [C++11] Replacing EnumDecl iterators enumerator_begin() and enumerator_end() ↵Aaron Ballman2014-03-081-6/+4
| | | | | | with iterator_range enumerators(). Updating all of the usages of the iterators with range-based for loops. llvm-svn: 203353
* Rename getResultLoc() tooAlp Toker2014-01-251-1/+1
| | | | | | | | Follow up to r200082. Spotted by Dmitri llvm-svn: 200105
* Rename getResultType() on function and method declarations to getReturnType()Alp Toker2014-01-251-6/+6
| | | | | | | | | | | | | | | A return type is the declared or deduced part of the function type specified in the declaration. A result type is the (potentially adjusted) type of the value of an expression that calls the function. Rule of thumb: * Declarations have return types and parameters. * Expressions have result types and arguments. llvm-svn: 200082
* Combine the checks for returns_nonnull and for operator new returning null, ↵Artyom Skrobov2014-01-241-23/+2
| | | | | | in Sema::CheckReturnValExpr. Add the missing handling of value-dependent expressions for returns_nonnull. llvm-svn: 199989
* Fix to PR8880 (clang dies processing a for loop)Serge Pavlov2014-01-231-12/+44
| | | | | | | | | | | | | | | | | | | | | | | Due to statement expressions supported as GCC extension, it is possible to put 'break' or 'continue' into a loop/switch statement but outside its body, for example: for ( ; ({ if (first) { first = 0; continue; } 0; }); ) This code is rejected by GCC if compiled in C mode but is accepted in C++ code. GCC bug 44715 tracks this discrepancy. Clang used code generation that differs from GCC in both modes: only statement of the third expression of 'for' behaves as if it was inside loop body. This change makes code generation more close to GCC, considering 'break' or 'continue' statement in condition and increment expressions of a loop as it was inside the loop body. It also adds error for the cases when 'break'/'continue' appear outside loop due to this syntax. If code generation differ from GCC, warning is issued. Differential Revision: http://llvm-reviews.chandlerc.com/D2518 llvm-svn: 199897
* Add basic checking for returning null from functions/methods marked ↵Ted Kremenek2014-01-221-2/+10
| | | | | | | | | | 'returns_nonnull'. This involved making CheckReturnStackAddr into a static function, which is now called by a top-level return value checking routine called CheckReturnValExpr. llvm-svn: 199790
* Issue a warning if a throwing operator new or operator new[] returns a nullRichard Smith2014-01-171-0/+22
| | | | | | | | pointer, since this invokes undefined behavior. Based on a patch by Artyom Skrobov! Handling of dependent exception specifications and some additional testcases by me. llvm-svn: 199452
* Replacing calls to getAttr with calls to hasAttr for clarity. No functional ↵Aaron Ballman2013-12-191-4/+4
| | | | | | change intended -- this only replaces Boolean uses of getAttr. llvm-svn: 197648
* -Wassign-enum: compare unqualified typesDmitri Gribenko2013-12-051-2/+2
| | | | | | | | | | | | | | This commit changes -Wassign-enum to compare unqualified types. One could think that this does not matter much, because who wants a value of enum type that is const-qualified? But this breaks the intended pattern to silence this warning with an explicit cast: static const enum Foo z = (enum Foo) 42; In this case, source type is 'enum Foo', and destination type is 'const enum Foo', and if we compare qualified types, they don't match, so we used warn. llvm-svn: 196548
* Allow the warning 'case value not in enumerated type' to be silenced withDmitri Gribenko2013-12-051-8/+39
| | | | | | | | | | the following pattern. If 'case' expression refers to a static const variable of the correct enum type, then we count this as a sufficient declaration of intent by the user, so we silence the warning. llvm-svn: 196546
* Issue diagnostic when constructor or destructorFariborz Jahanian2013-12-031-4/+16
| | | | | | | return void expression. // rdar://15366494 pr17759. llvm-svn: 196296
* Remove a whole lot of unused variablesAlp Toker2013-11-271-2/+0
| | | | | | | There are about 30 removed in this patch, generated by a new FixIt I haven't got round to submitting yet. llvm-svn: 195814
* 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
OpenPOWER on IntegriCloud