Skip to content

Commit 290e083

Browse files
Merge pull request #4890 from swiftwasm/main
[pull] swiftwasm from main
2 parents e74f0c3 + 435af14 commit 290e083

34 files changed

+3051
-959
lines changed

include/swift/AST/Attr.def

Lines changed: 0 additions & 794 deletions
This file was deleted.

include/swift/AST/Attr.def.gyb

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
%{
2+
# -*- mode: C++ -*-
3+
from gyb_syntax_support import *
4+
from gyb_syntax_support.AttributeKinds import *
5+
# Ignore the following admonition; it applies to the resulting .def file only
6+
}%
7+
//// Automatically Generated From Attr.def.gyb.
8+
//// Do Not Edit Directly!
9+
//===--- Attr.def - Swift Attributes Metaprogramming ------------*- C++ -*-===//
10+
//
11+
// This source file is part of the Swift.org open source project
12+
//
13+
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
14+
// Licensed under Apache License v2.0 with Runtime Library Exception
15+
//
16+
// See https://swift.org/LICENSE.txt for license information
17+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
18+
//
19+
//===----------------------------------------------------------------------===//
20+
//
21+
// This file defines macros used for macro-metaprogramming with attributes.
22+
//
23+
//===----------------------------------------------------------------------===//
24+
25+
#ifndef DECL_ATTR
26+
#define DECL_ATTR(SPELLING, CLASS, OPTIONS, CODE)
27+
#endif
28+
29+
#ifndef CONTEXTUAL_DECL_ATTR
30+
#define CONTEXTUAL_DECL_ATTR(SPELLING, CLASS, OPTIONS, CODE) \
31+
DECL_ATTR(SPELLING, CLASS, OPTIONS, CODE)
32+
#endif
33+
34+
#ifndef SIMPLE_DECL_ATTR
35+
#define SIMPLE_DECL_ATTR(X, CLASS, OPTIONS, CODE) \
36+
DECL_ATTR(X, CLASS, OPTIONS, CODE)
37+
#endif
38+
39+
#ifndef CONTEXTUAL_SIMPLE_DECL_ATTR
40+
#define CONTEXTUAL_SIMPLE_DECL_ATTR(X, CLASS, OPTIONS, CODE) \
41+
SIMPLE_DECL_ATTR(X, CLASS, OPTIONS, CODE)
42+
#endif
43+
44+
#ifndef DECL_ATTR_ALIAS
45+
#define DECL_ATTR_ALIAS(SPELLING, CLASS)
46+
#endif
47+
48+
#ifndef CONTEXTUAL_DECL_ATTR_ALIAS
49+
#define CONTEXTUAL_DECL_ATTR_ALIAS(SPELLING, CLASS) \
50+
DECL_ATTR_ALIAS(SPELLING, CLASS)
51+
#endif
52+
53+
#ifndef TYPE_ATTR
54+
#define TYPE_ATTR(X)
55+
#endif
56+
57+
// Type attributes
58+
% for attr in TYPE_ATTR_KINDS:
59+
TYPE_ATTR(${attr.name})
60+
% end
61+
62+
// SIL-specific attributes
63+
TYPE_ATTR(block_storage)
64+
TYPE_ATTR(box)
65+
TYPE_ATTR(dynamic_self)
66+
#define REF_STORAGE(Name, name, ...) TYPE_ATTR(sil_##name)
67+
#include "swift/AST/ReferenceStorage.def"
68+
TYPE_ATTR(error)
69+
TYPE_ATTR(out)
70+
TYPE_ATTR(in)
71+
TYPE_ATTR(inout)
72+
TYPE_ATTR(inout_aliasable)
73+
TYPE_ATTR(in_guaranteed)
74+
TYPE_ATTR(in_constant)
75+
TYPE_ATTR(owned)
76+
TYPE_ATTR(unowned_inner_pointer)
77+
TYPE_ATTR(guaranteed)
78+
TYPE_ATTR(autoreleased)
79+
TYPE_ATTR(callee_owned)
80+
TYPE_ATTR(callee_guaranteed)
81+
TYPE_ATTR(objc_metatype)
82+
TYPE_ATTR(opened)
83+
TYPE_ATTR(pseudogeneric)
84+
TYPE_ATTR(yields)
85+
TYPE_ATTR(yield_once)
86+
TYPE_ATTR(yield_many)
87+
TYPE_ATTR(captures_generics)
88+
// Used at the SIL level to mark a type as moveOnly.
89+
TYPE_ATTR(moveOnly)
90+
91+
// SIL metatype attributes.
92+
TYPE_ATTR(thin)
93+
TYPE_ATTR(thick)
94+
95+
// Declaration Attributes and Modifers
96+
// To add a new entry here, update https://github.com/apple/swift-syntax
97+
% for attr in DECL_ATTR_KINDS + DECL_MODIFIER_KINDS + DEPRECATED_MODIFIER_KINDS:
98+
% if type(attr) is ContextualDeclAttributeAlias:
99+
CONTEXTUAL_DECL_ATTR_ALIAS(${attr.name}, ${attr.class_name})
100+
% elif type(attr) is DeclAttributeAlias:
101+
DECL_ATTR_ALIAS(${attr.name}, ${attr.class_name})
102+
% elif type(attr) is ContextualSimpleDeclAttribute:
103+
CONTEXTUAL_SIMPLE_DECL_ATTR(${attr.name}, ${attr.class_name},
104+
${' | '.join(attr.options)},
105+
${str(attr.code)})
106+
% elif type(attr) is ContextualDeclAttribute:
107+
CONTEXTUAL_DECL_ATTR(${attr.name}, ${attr.class_name},
108+
${' | '.join(attr.options)},
109+
${str(attr.code)})
110+
% elif type(attr) is SimpleDeclAttribute:
111+
SIMPLE_DECL_ATTR(${attr.name}, ${attr.class_name},
112+
${' | '.join(attr.options)},
113+
${str(attr.code)})
114+
% elif type(attr) is DeclAttribute:
115+
DECL_ATTR(${attr.name}, ${attr.class_name},
116+
${' | '.join(attr.options)},
117+
${str(attr.code)})
118+
% elif type(attr) is BuiltinDeclModifier:
119+
% # These are not actually decl attributes, ignore them.
120+
% pass
121+
% else:
122+
% raise RuntimeError(f'Unhandled attribute class {type(attr)}')
123+
% end
124+
% end
125+
126+
#undef TYPE_ATTR
127+
#undef DECL_ATTR_ALIAS
128+
#undef CONTEXTUAL_DECL_ATTR_ALIAS
129+
#undef SIMPLE_DECL_ATTR
130+
#undef CONTEXTUAL_SIMPLE_DECL_ATTR
131+
#undef DECL_ATTR
132+
#undef CONTEXTUAL_DECL_ATTR

include/swift/AST/CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
if(CMAKE_HOST_SYSTEM_NAME STREQUAL Windows)
2+
set(SWIFT_GYB_FLAGS --line-directive "^\"#line %(line)d \\\"%(file)s\\\"^\"")
3+
else()
4+
set(SWIFT_GYB_FLAGS --line-directive "\'#line" "%(line)d" "\"%(file)s\"\'")
5+
endif()
6+
7+
set(generated_include_sources
8+
Attr.def.gyb)
9+
10+
add_gyb_target(swift-ast-generated-headers
11+
"${generated_include_sources}")
12+
set_property(TARGET swift-ast-generated-headers
13+
PROPERTY FOLDER "Miscellaneous")

include/swift/Basic/FlagSet.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class FlagSet {
6666

6767
/// Read a multi-bit field.
6868
template <unsigned FirstBit, unsigned BitWidth, typename FieldType = IntType>
69-
FieldType getField() const {
69+
constexpr FieldType getField() const {
7070
return FieldType((Bits >> FirstBit) & lowMaskFor<BitWidth>());
7171
}
7272

@@ -92,7 +92,7 @@ class FlagSet {
9292
// A convenient macro for defining a getter and setter for a field.
9393
// Intended to be used in the body of a subclass of FlagSet.
9494
#define FLAGSET_DEFINE_FIELD_ACCESSORS(BIT, WIDTH, TYPE, GETTER, SETTER) \
95-
TYPE GETTER() const { \
95+
constexpr TYPE GETTER() const { \
9696
return this->template getField<BIT, WIDTH, TYPE>(); \
9797
} \
9898
void SETTER(TYPE value) { \

include/swift/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ endif()
77
if(SWIFT_INCLUDE_TOOLS)
88
configure_file(Config.h.in ${CMAKE_CURRENT_BINARY_DIR}/Config.h
99
ESCAPE_QUOTES @ONLY)
10+
add_subdirectory(AST)
1011
add_subdirectory(Option)
1112
add_subdirectory(Parse)
1213
add_subdirectory(Syntax)

lib/AST/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,5 +177,6 @@ endif()
177177
# headers.
178178
# For more information see the comment at the top of lib/CMakeLists.txt.
179179
add_dependencies(swiftAST intrinsics_gen clang-tablegen-targets)
180+
add_dependencies(swiftAST swift-ast-generated-headers)
180181

181182
set_swift_llvm_is_available(swiftAST)

lib/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ list(APPEND LLVM_COMMON_DEPENDS intrinsics_gen clang-tablegen-targets)
1212

1313
# Add generated libSyntax headers to global dependencies.
1414
list(APPEND LLVM_COMMON_DEPENDS swift-syntax-generated-headers)
15+
list(APPEND LLVM_COMMON_DEPENDS swift-ast-generated-headers)
1516
list(APPEND LLVM_COMMON_DEPENDS swift-parse-syntax-generated-headers)
1617

1718
add_subdirectory(APIDigester)

lib/IDE/CompletionLookup.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2091,9 +2091,7 @@ bool CompletionLookup::handleEnumElement(ValueDecl *D,
20912091
/*HasTypeContext=*/true);
20922092
return true;
20932093
} else if (auto *ED = dyn_cast<EnumDecl>(D)) {
2094-
llvm::DenseSet<EnumElementDecl *> Elements;
2095-
ED->getAllElements(Elements);
2096-
for (auto *Ele : Elements) {
2094+
for (auto *Ele : ED->getAllElements()) {
20972095
addEnumElementRef(Ele, Reason, dynamicLookupInfo,
20982096
/*HasTypeContext=*/true);
20992097
}

lib/SIL/IR/SILFunctionType.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2702,6 +2702,8 @@ static bool isCFTypedef(const TypeLowering &tl, clang::QualType type) {
27022702
static ParameterConvention getIndirectCParameterConvention(clang::QualType type) {
27032703
// Non-trivial C++ types would be Indirect_Inout (at least in Itanium).
27042704
// A trivial const * parameter in C should be considered @in.
2705+
if (type->isReferenceType() && type->getPointeeType().isConstQualified())
2706+
return ParameterConvention::Indirect_In_Guaranteed;
27052707
return ParameterConvention::Indirect_In;
27062708
}
27072709

lib/SILGen/LValue.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ class PathComponent {
105105
CoroutineAccessorKind, // coroutine accessor
106106
ValueKind, // random base pointer as an lvalue
107107
PhysicalKeyPathApplicationKind, // applying a key path
108-
ABISafeConversionKind, // unchecked_addr_cast
109108

110109
// Logical LValue kinds
111110
GetterSetterKind, // property or subscript getter/setter
@@ -118,6 +117,7 @@ class PathComponent {
118117
// Translation LValue kinds (a subtype of logical)
119118
OrigToSubstKind, // generic type substitution
120119
SubstToOrigKind, // generic type substitution
120+
UncheckedConversionKind, // unchecked_X_cast
121121

122122
FirstLogicalKind = GetterSetterKind,
123123
FirstTranslationKind = OrigToSubstKind,

0 commit comments

Comments
 (0)