summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/ScopeInfo.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [coroutines] Pass coro func args to promise ctorBrian Gesiak2018-01-241-0/+1
| | | | | | | | | | | | | | | | | | | Summary: Use corutine function arguments to initialize a promise type, but only if the promise type defines a constructor that takes those arguments. Otherwise, fall back to the default constructor. Test Plan: check-clang Reviewers: rsmith, GorNishanov, eric_niebler Reviewed By: GorNishanov Subscribers: toby-allsopp, lewissbaker, EricWF, cfe-commits Differential Revision: https://reviews.llvm.org/D41820 llvm-svn: 323381
* [coroutines] Fix diagnostics depending on the first coroutine statement.Eric Fiselier2017-03-111-3/+5
| | | | | | | | | | | | | | | | | | Summary: Some coroutine diagnostics need to point to the location of the first coroutine keyword in the function, like when diagnosing a `return` inside a coroutine. Previously we did this by storing each *valid* coroutine statement in a list and select the first one to use in diagnostics. However if every coroutine statement is invalid we would have no location to point to. This patch fixes the storage of the first coroutine statement location, ensuring that it gets stored even when the resulting AST node would be invalid. This patch also removes the `CoroutineStmts` list in `FunctionScopeInfo` because it was unused. Reviewers: rsmith, GorNishanov, aaron.ballman Reviewed By: GorNishanov Subscribers: mehdi_amini, cfe-commits Differential Revision: https://reviews.llvm.org/D30776 llvm-svn: 297547
* [coroutines] Add DependentCoawaitExpr and fix re-building CoroutineBodyStmt.Eric Fiselier2017-03-061-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: The changes contained in this patch are: 1. Defines a new AST node `CoawaitDependentExpr` for representing co_await expressions while the promise type is still dependent. 2. Correctly detect and transform the 'co_await' operand to `p.await_transform(<expr>)` when possible. 3. Change the initial/final suspend points to build during the initial parse, so they have the correct operator co_await lookup results. 4. Fix transformation of the CoroutineBodyStmt so that it doesn't re-build the final/initial suspends. @rsmith: This change is a little big, but it's not trivial for me to split it up. Please let me know if you would prefer this submitted as multiple patches. Reviewers: rsmith, GorNishanov Reviewed By: rsmith Subscribers: ABataev, rsmith, mehdi_amini, cfe-commits Differential Revision: https://reviews.llvm.org/D26057 llvm-svn: 297093
* [Sema][ObjC] Don't pass a DeclRefExpr that doesn't reference a VarDeclAkira Hatanaka2017-02-011-5/+5
| | | | | | | | | | to WeakObjectProfileTy's constructor. This fixes an assertion failure in WeakObjectProfileTy's constructor. rdar://problem/30112633 llvm-svn: 293808
* [Sema][NFC] Reset HasFallthroughStmt when clearing FunctionScopeInfoErik Pilkington2016-11-091-0/+1
| | | | | | Differential revision: https://reviews.llvm.org/D22770 llvm-svn: 286409
* [ObjC] Warn on unguarded use of partial declarationErik Pilkington2016-08-161-0/+1
| | | | | | | | | | | | | | This commit adds a traversal of the AST after Sema of a function that diagnoses unguarded references to declarations that are partially available (based on availability attributes). This traversal is only done when we would otherwise emit -Wpartial-availability. This commit is part of a feature I proposed here: http://lists.llvm.org/pipermail/cfe-dev/2016-July/049851.html Differential revision: https://reviews.llvm.org/D23003 llvm-svn: 278826
* Use ranges to concisely express iterationDavid Majnemer2016-06-231-1/+1
| | | | | | | No functional change is intended, this should just clean things up a little. llvm-svn: 273522
* [Objective-c] Do not set IsExact to true when the receiver is a class.Akira Hatanaka2016-03-221-3/+1
| | | | | | | | | | | | IsExact shouldn't be set to true in WeakObjectProfileTy::getBaseInfo when the receiver is a class because having a class as the receiver doesn't guarantee that the Base is exact. This is a follow-up to r263818. rdar://problem/25208167 llvm-svn: 264025
* [Objective-c] Fix a crash in WeakObjectProfileTy::getBaseInfo.Akira Hatanaka2016-03-181-5/+9
| | | | | | | | | | | | | The crash occurs in WeakObjectProfileTy::getBaseInfo when getBase() is called on an ObjCPropertyRefExpr object whose receiver is an interface. This commit fixes the crash by checking the type of the receiver and setting IsExact to true if it is an interface. rdar://problem/25208167 Differential Revision: http://reviews.llvm.org/D18268 llvm-svn: 263818
* [OPENMP 4.0] Initial support for 'omp declare reduction' construct.Alexey Bataev2016-03-031-0/+1
| | | | | | | | | | | | | | | | | Add parsing, sema analysis and serialization/deserialization for 'declare reduction' construct. User-defined reductions are defined as #pragma omp declare reduction( reduction-identifier : typename-list : combiner ) [initializer ( initializer-expr )] These custom reductions may be used in 'reduction' clauses of OpenMP constructs. The combiner specifies how partial results can be combined into a single value. The combiner can use the special variable identifiers omp_in and omp_out that are of the type of the variables being reduced with this reduction-identifier. Each of them will denote one of the values to be combined before executing the combiner. It is assumed that the special omp_out identifier will refer to the storage that holds the resulting combined value after executing the combiner. As the initializer-expr value of a user-defined reduction is not known a priori the initializer-clause can be used to specify one. Then the contents of the initializer-clause will be used as the initializer for private copies of reduction list items where the omp_priv identifier will refer to the storage to be initialized. The special identifier omp_orig can also appear in the initializer-clause and it will refer to the storage of the original variable to be reduced. Differential Revision: http://reviews.llvm.org/D11182 llvm-svn: 262582
* Properly clear current coroutine promise on FunctionScopeInfo reuse. ShouldRichard Smith2015-10-271-0/+1
| | | | | | hopefully make bots happy again. llvm-svn: 251397
* [coroutines] Creation of promise object, lookup of operator co_await, buildingRichard Smith2015-10-271-0/+2
| | | | | | of await_* calls, and AST representation for same. llvm-svn: 251387
* Roll-back r250822.Angel Garcia Gomez2015-10-201-3/+3
| | | | | | | | | | Summary: It breaks the build for the ASTMatchers Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D13893 llvm-svn: 250827
* Apply modernize-use-default to clang.Angel Garcia Gomez2015-10-201-3/+3
| | | | | | | | | | | | Summary: Replace empty bodies of default constructors and destructors with '= default'. Reviewers: bkramer, klimek Subscribers: klimek, alexfh, cfe-commits Differential Revision: http://reviews.llvm.org/D13890 llvm-svn: 250822
* Wdeprecated: LambdaScopeInfos are copied in TreeTransform, so make sure ↵David Blaikie2015-08-131-1/+0
| | | | | | | | | | | they're copyable. Partly addressed by r244843, but the explicit dtor in LambdaScopeInfo was still thwarting the implicit copy ctor. This does remove the key function from LambdaScopeInfo unfortunately, but it seems neater than having to explicitly default any special members LambdaScopeInfo needs. llvm-svn: 244957
* SEH: Diagnose use of C++ EH and SEH in the same functionReid Kleckner2015-02-021-0/+2
| | | | | | | | This check does not apply when Borland extensions are enabled, as they have a checked in test case indicating that mixed usage of SEH and C++ is supported. llvm-svn: 227876
* Objective-C ARC. Fixes a crash when checking for 'weak' propery Fariborz Jahanian2014-11-211-0/+2
| | | | | | whose base is not an expression. rdar://19053620 llvm-svn: 222570
* [Sema] Patch to issue warning on comparing parameters withFariborz Jahanian2014-11-181-0/+1
| | | | | | | | | | | nonnull attribute when comparison is always true/false. Original patch by Steven Wu. I have added extra code to prevent issuing of warning when the nonnull parameter is modified prior to the comparison. This addition prevents false positives in the most obvious cases. There may still be false positive warnings in some cases (as one of my tests indicates), but benefit far outweighs such cases. rdar://18712242 llvm-svn: 222264
* Improved capturing variable-length array types in CapturedStmt.Alexey Bataev2014-10-291-1/+7
| | | | | | | | An updated implemnentation of VLA types capturing based on previously committed solution for Lambdas. This version captures the whole VLA type instead of particular variables which are part of VLA size expression and allows to use previusly calculated size of VLA type in captured regions. Required for OpenMP. Differential Revision: http://reviews.llvm.org/D5099 llvm-svn: 220850
* [C++11] Support for capturing of variable length arrays in lambda expression.Alexey Bataev2014-08-281-0/+10
| | | | | | Differential Revision: http://reviews.llvm.org/D4368 llvm-svn: 216649
* Objective-C ARC. Do not warn about properties with bothFariborz Jahanian2014-06-171-2/+8
| | | | | | | | | IBOutlet and weak attributes when accessed being unpredictably set to nil because usage of such properties are always single threaded and its ivar cannot be set to nil asynchronously. // rdar://15885642 llvm-svn: 211132
* [C++11] Use 'nullptr'. Sema edition.Craig Topper2014-05-261-5/+4
| | | | llvm-svn: 209613
* [REFACTOR] Refactored some of the generic-lambda capturing code.Faisal Vali2013-12-071-3/+4
| | | | | | | | | | | | | | | Employed the following refactorings: - Renamed some functions - Introduced explaining variables - Cleaned up & added comments - Used Optional<unsigned> for return value instead of an out parameter - Added assertions - Constified a few member functions No functionality change. All regressions pass. llvm-svn: 196662
* [objc] Emit warning when the implementation of a secondary initializer calls onArgyrios Kyrtzidis2013-12-031-0/+2
| | | | | | | | | | | super another initializer and when the implementation does not delegate to another initializer via a call on 'self'. A secondary initializer is an initializer method not marked as a designated initializer within a class that has at least one initializer marked as a designated initializer. llvm-svn: 196318
* [objc] Emit a warning when the implementation of a designated initializer ↵Argyrios Kyrtzidis2013-12-031-0/+4
| | | | | | | | does not chain to an init method that is a designated initializer for the superclass. llvm-svn: 196316
* Remove an unnecessary condition that I added hastily: Unsigned numbers are ↵Faisal Vali2013-11-071-1/+1
| | | | | | | | obviously >= 0 ;) Also - others have complained about some white space issues - sorry about that - continues to be a pain point for me - will try and see what I can do with clang-format this evening after work - as a short term fix, if anyone can email me the files that they have already identified with issues, it would help me speed up a focused fix. sorry. llvm-svn: 194206
* This patch implements capturing of variables within generic lambdas.Faisal Vali2013-11-071-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Both Richard and I felt that the current wording in the working paper needed some tweaking - Please see http://llvm-reviews.chandlerc.com/D2035 for additional context and references to core-reflector messages that discuss wording tweaks. What is implemented is what we had intended to specify in Bristol; but, recently felt that the specification might benefit from some tweaking and fleshing. As a rough attempt to explain the semantics: If a nested lambda with a default-capture names a variable within its body, and if the enclosing full expression that contains the name of that variable is instantiation-dependent - then an enclosing lambda that is capture-ready (i.e. within a non-dependent context) must capture that variable, if all intervening nested lambdas can potentially capture that variable if they need to, and all intervening parent lambdas of the capture-ready lambda can and do capture the variable. Of note, 'this' capturing is also currently underspecified in the working paper for generic lambdas. What is implemented here is if the set of candidate functions in a nested generic lambda includes both static and non-static member functions (regardless of viability checking - i.e. num and type of parameters/arguments) - and if all intervening nested-inner lambdas between the capture-ready lambda and the function-call containing nested lambda can capture 'this' and if all enclosing lambdas of the capture-ready lambda can capture 'this', then 'this' is speculatively captured by that capture-ready lambda. Hopefully a paper for the C++ committee (that Richard and I had started some preliminary work on) is forthcoming. This essentially makes generic lambdas feature complete, except for known bugs. The more prominent ones (and the ones I am currently aware of) being: - generic lambdas and init-captures are broken - but a patch that fixes this is already in the works ... - nested variadic expansions such as: auto K = [](auto ... OuterArgs) { vp([=](auto ... Is) { decltype(OuterArgs) OA = OuterArgs; return 0; }(5)...); return 0; }; auto M = K('a', ' ', 1, " -- ", 3.14); currently cause crashes. I think I know how to fix this (since I had done so in my initial implementation) - but it will probably take some work and back & forth with Doug and Richard. A warm thanks to all who provided feedback - and especially to Doug Gregor and Richard Smith for their pivotal guidance: their insight and prestidigitation in such matters is boundless! Now let's hope this commit doesn't upset the buildbot gods ;) Thanks! llvm-svn: 194188
* Sema for Captured StatementsTareq A. Siraj2013-04-161-0/+1
| | | | | | | | | | | | | 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
* -Warc-repeated-use-of-weak: fix a use-of-uninitialized and add a test case.Jordan Rose2012-10-111-1/+1
| | | | | | Fix-up for r165718, should get the buildbots back online. llvm-svn: 165723
* -Warc-repeated-use-of-weak: Check messages to property accessors as well.Jordan Rose2012-10-111-3/+29
| | | | | | | | | | | | | | | | | | | Previously, [foo weakProp] was not being treated the same as foo.weakProp. Now, for every explicit message send, we check if it's a property access, and if so, if the property is weak. Then for every assignment of a message, we have to do the same thing again. This is a potentially expensive increase because determining whether a method is a property accessor requires searching through the methods it overrides. However, without it -Warc-repeated-use-of-weak will miss cases from people who prefer not to use dot syntax. If this turns out to be too expensive, we can try caching the result somewhere, or even lose precision by not checking superclass methods. The warning is off-by-default, though. <rdar://problem/12407765> llvm-svn: 165718
* -Warc-repeated-use-of-weak: look through explicit casts on assigned values.Jordan Rose2012-10-101-1/+1
| | | | | | | Reading from a weak property, casting the result, and assigning to a strong pointer should still be considered safe. llvm-svn: 165629
* Move isObjCSelf into Expr.Anna Zaks2012-10-011-20/+2
| | | | llvm-svn: 164966
* Pull ScopeInfo implementation into its own file.Jordan Rose2012-09-281-0/+181
The infrastructure for -Warc-repeated-use-of-weak got a little too heavy to leave sitting at the top of Sema.cpp. No functionality change. llvm-svn: 164856
OpenPOWER on IntegriCloud