Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Sema Diagnostics] Add Miscellaneous Sema diagnostics to enforce that the new os log APIs and atomics are passed constants for certain arguments #26969

Merged
merged 1 commit into from
Apr 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions include/swift/AST/DiagnosticsSema.def
Original file line number Diff line number Diff line change
Expand Up @@ -5031,6 +5031,29 @@ ERROR(differentiable_programming_attr_used_without_required_module, none,
"'@%0' attribute used without importing module %1",
(StringRef, Identifier))

ERROR(oslog_arg_must_be_bool_literal, none,
"argument must be a bool literal", ())
ERROR(oslog_arg_must_be_integer_literal, none,
"argument must be an integer literal", ())
ERROR(oslog_arg_must_be_string_literal, none,
"argument must be a string literal", ())
ERROR(oslog_arg_must_be_float_literal, none,
"argument must be a floating-point literal", ())
ERROR(oslog_arg_must_be_metatype_literal, none,
"argument must be a <Type>.self", ())
ERROR(oslog_arg_must_be_closure, none, "argument must be a closure", ())
ERROR(argument_must_be_constant, none,
"argument must be an expression with only literals", ())
ERROR(oslog_message_must_be_string_interpolation, none,
"argument must be a string interpolation", ())
ERROR(oslog_arg_must_be_enum_case, none,
"argument must be a case of enum %0", (Identifier))
ERROR(oslog_arg_must_be_type_member_access, none,
"argument must be a static method or property of %0", (Identifier))
ERROR(atomics_ordering_must_be_constant, none,
"ordering argument must be a static method or property of %0",
(Identifier))

#ifndef DIAG_NO_UNDEF
# if defined(DIAG)
# undef DIAG
Expand Down
5 changes: 5 additions & 0 deletions include/swift/AST/KnownIdentifiers.def
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,11 @@ IDENTIFIER_(nsError)
// Custom string interpolation type used by os log APIs.
IDENTIFIER(OSLogMessage)

// Atomics ordering type identifiers.
IDENTIFIER(AtomicLoadOrdering)
IDENTIFIER(AtomicStoreOrdering)
IDENTIFIER(AtomicUpdateOrdering)

// Differentiable programming
IDENTIFIER(along)
IDENTIFIER(differential)
Expand Down
3 changes: 2 additions & 1 deletion include/swift/AST/SemanticAttrs.def
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,10 @@ SEMANTICS_ATTR(OPTIMIZE_SIL_SPECIALIZE_GENERIC_PARTIAL_NEVER,
SEMANTICS_ATTR(OPTIMIZE_SIL_SPECIALIZE_GENERIC_SIZE_NEVER,
"optimize.sil.specialize.generic.size.never")

SEMANTICS_ATTR(OSLOG_INTERPOLATION_INIT, "oslog.interpolation.init")
SEMANTICS_ATTR(OSLOG_MESSAGE_INIT_INTERPOLATION, "oslog.message.init_interpolation")
SEMANTICS_ATTR(OSLOG_MESSAGE_INIT_STRING_LITERAL, "oslog.message.init_stringliteral")
SEMANTICS_ATTR(OSLOG_REQUIRES_CONSTANT_ARGUMENTS, "oslog.requires_constant_arguments")
SEMANTICS_ATTR(ATOMICS_REQUIRES_CONSTANT_ORDERINGS, "atomics.requires_constant_orderings")

SEMANTICS_ATTR(TYPE_CHECKER_OPEN_EXISTENTIAL, "typechecker._openExistential(_:do:)")
SEMANTICS_ATTR(TYPE_CHECKER_TYPE, "typechecker.type(of:)")
Expand Down
1 change: 1 addition & 0 deletions lib/Sema/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ add_swift_host_library(swiftSema STATIC
CSFix.cpp
CSDiagnostics.cpp
CodeSynthesis.cpp
ConstantnessSemaDiagnostics.cpp
Constraint.cpp
ConstraintGraph.cpp
ConstraintLocator.cpp
Expand Down
Loading