Commit Graph

8 Commits

Author SHA1 Message Date
Josh Learn
6c881f52a3 [Sema] Fix constantness diagnostics for single expression closures
Due to the way miscellaneous diagnostics work with closure bodies, the
function argument constantness sema check does not produce proper
diagnostics for single-expression closures. This change fixes the
problem by having the ASTWalker manually walk in the closure body
if it is a single expression.

rdar://65577070
2021-06-23 19:43:40 -04:00
Josh Learn
1fd6ef95ce [OSLog] Update compiler stubs and tests
The compiler stubs for testing the OSLog implementation are in need of an update. This change updates the stubs to be consistent with the current OSLog implementation, updates the existing tests, and adds new tests for String and metatype interpolations.

rdar://69719729
2020-10-01 12:14:08 -07:00
Ravi Kandhadai
49b0984e19 [Sema][os_log] Allow wrapping os_log strings within constant evaluable functions.
As of now, the sema checks for os_log allow only string interpolations to be passed
to the log calls. E.g. logger.log(foo("message")) would not be allowed. This PR
relaxes this requirement and allows it as long as foo is annotated as
@_semantics("constant_evaluable").

<rdar://problem/65215054>
2020-07-15 10:54:08 -07:00
Robert Widmann
50159d15b7 [Gardening] Use Vendor=apple Where Possible
This simplifies the usual bundle of OS checks

OS=macosx || OS=ios || OS=tvos || OS=watchos

into

VENDOR=apple

which was added in apple/swift#27307
2020-06-30 23:03:01 -07:00
Doug Gregor
836bc57fe5 [AST Walker] Stop visiting the bodies of closures as expressions.
Single-expression closures have always been traversed differently
from multi-statement closures. The former were traversed as if the
expression was their only child, skipping the BraceStmt and implicit
return, while the later was traversed as a normal BraceStmt.
Unify on the latter treatment, so that traversal

There are a few places where we unintentionally relied on this
expression-as-child behavior. Clean those up to work with arbitrary
closures, which is an overall simplification in the logic.
2020-06-04 23:06:32 -07:00
Ravi Kandhadai
2e0457ab0d [OSLog Diagnostics] Improve diagnostics emitted in the SIL and Sema diagnostic passes
for the os log APIs. These improvements are aimed at covering some rare corner cases.
2020-04-18 15:29:22 -07:00
Ravi Kandhadai
03d726c5c2 [Sema Diagnostics][OSLog] Make the miscellaneous diagnostics that
checks the constantness of arguments passed to the new os log APIs
ignore the log level and log object which can be dynamic.
2020-04-17 14:38:13 -07:00
Ravi Kandhadai
b57a1d7c0e [Sema] Add miscellaneous sema diagnostics to check that the new os log
APIs and atomic operations are passed compile-time constants for
certain arguments.
2020-04-06 18:41:13 -07:00