Skip to content

Commit f0413f6

Browse files
committed
build: remove last llvm:: reference in stdlib
This removes the last reference to the `llvm::` namespace in the standard library. All uses of the LLVMSupport library now are namespaced into the `__swift::__runtime` namespace. This allows us to incrementally vend the LLVMSupport library and make the separation explicit.
1 parent dca0209 commit f0413f6

File tree

10 files changed

+133
-130
lines changed

10 files changed

+133
-130
lines changed

include/swift/ABI/TypeIdentity.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ class ParsedTypeIdentity {
184184
StringRef FullIdentity;
185185

186186
/// Any extended information that type might have.
187-
Optional<TypeImportInfo<StringRef>> ImportInfo;
187+
llvm::Optional<TypeImportInfo<StringRef>> ImportInfo;
188188

189189
/// The ABI name of the type.
190190
StringRef getABIName() const {

include/swift/Basic/LLVM.h

+4
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ namespace llvm {
4545
template<typename T> class MutableArrayRef;
4646
#endif
4747
template<typename T> class TinyPtrVector;
48+
#if !defined(swiftCore_EXPORTS)
4849
template<typename T> class Optional;
50+
#endif
4951
template <typename ...PTs> class PointerUnion;
5052
template <typename IteratorT> class iterator_range;
5153
class SmallBitVector;
@@ -75,7 +77,9 @@ namespace swift {
7577
#endif
7678
using llvm::iterator_range;
7779
using llvm::None;
80+
#if !defined(swiftCore_EXPORTS)
7881
using llvm::Optional;
82+
#endif
7983
using llvm::PointerUnion;
8084
using llvm::SmallBitVector;
8185
using llvm::SmallPtrSet;

include/swift/Basic/STLExtras.h

+4-5
Original file line numberDiff line numberDiff line change
@@ -528,19 +528,18 @@ makeOptionalTransformRange(Range range, OptionalTransform op) {
528528
/// the result in an optional to indicate success or failure.
529529
template<typename Subclass>
530530
struct DowncastAsOptional {
531-
template<typename Superclass>
531+
template <typename Superclass>
532532
auto operator()(Superclass &value) const
533-
-> Optional<decltype(llvm::cast<Subclass>(value))> {
533+
-> llvm::Optional<decltype(llvm::cast<Subclass>(value))> {
534534
if (auto result = llvm::dyn_cast<Subclass>(value))
535535
return result;
536536

537537
return None;
538538
}
539539

540-
template<typename Superclass>
540+
template <typename Superclass>
541541
auto operator()(const Superclass &value) const
542-
-> Optional<decltype(llvm::cast<Subclass>(value))>
543-
{
542+
-> llvm::Optional<decltype(llvm::cast<Subclass>(value))> {
544543
if (auto result = llvm::dyn_cast<Subclass>(value))
545544
return result;
546545

include/swift/Demangling/TypeDecoder.h

+10-10
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ enum class ImplParameterDifferentiability {
9494
NotDifferentiable
9595
};
9696

97-
static inline Optional<ImplParameterDifferentiability>
97+
static inline llvm::Optional<ImplParameterDifferentiability>
9898
getDifferentiabilityFromString(StringRef string) {
9999
if (string.empty())
100100
return ImplParameterDifferentiability::DifferentiableOrNotApplicable;
@@ -115,7 +115,7 @@ class ImplFunctionParam {
115115
using ConventionType = ImplParameterConvention;
116116
using DifferentiabilityType = ImplParameterDifferentiability;
117117

118-
static Optional<ConventionType>
118+
static llvm::Optional<ConventionType>
119119
getConventionFromString(StringRef conventionString) {
120120
if (conventionString == "@in")
121121
return ConventionType::Indirect_In;
@@ -168,7 +168,7 @@ class ImplFunctionResult {
168168
public:
169169
using ConventionType = ImplResultConvention;
170170

171-
static Optional<ConventionType>
171+
static llvm::Optional<ConventionType>
172172
getConventionFromString(StringRef conventionString) {
173173
if (conventionString == "@out")
174174
return ConventionType::Indirect;
@@ -268,8 +268,8 @@ class ImplFunctionTypeFlags {
268268
#if SWIFT_OBJC_INTEROP
269269
/// For a mangled node that refers to an Objective-C class or protocol,
270270
/// return the class or protocol name.
271-
static inline Optional<StringRef> getObjCClassOrProtocolName(
272-
NodePointer node) {
271+
static inline llvm::Optional<StringRef>
272+
getObjCClassOrProtocolName(NodePointer node) {
273273
if (node->getKind() != Demangle::Node::Kind::Class &&
274274
node->getKind() != Demangle::Node::Kind::Protocol)
275275
return None;
@@ -435,7 +435,7 @@ class TypeDecoder {
435435
case NodeKind::Metatype:
436436
case NodeKind::ExistentialMetatype: {
437437
unsigned i = 0;
438-
Optional<ImplMetatypeRepresentation> repr;
438+
llvm::Optional<ImplMetatypeRepresentation> repr;
439439

440440
// Handle lowered metatypes in a hackish way. If the representation
441441
// was not thin, force the resulting typeref to have a non-empty
@@ -650,7 +650,7 @@ class TypeDecoder {
650650
}
651651
}
652652

653-
Optional<ImplFunctionResult<BuiltType>> errorResult;
653+
llvm::Optional<ImplFunctionResult<BuiltType>> errorResult;
654654
switch (errorResults.size()) {
655655
case 0:
656656
break;
@@ -905,7 +905,7 @@ class TypeDecoder {
905905
return true;
906906

907907
StringRef conventionString = node->getChild(0)->getText();
908-
Optional<typename T::ConventionType> convention =
908+
llvm::Optional<typename T::ConventionType> convention =
909909
T::getConventionFromString(conventionString);
910910
if (!convention)
911911
return true;
@@ -1072,8 +1072,8 @@ class TypeDecoder {
10721072
return true;
10731073
};
10741074

1075-
auto decodeParam = [&](NodePointer paramNode)
1076-
-> Optional<FunctionParam<BuiltType>> {
1075+
auto decodeParam =
1076+
[&](NodePointer paramNode) -> llvm::Optional<FunctionParam<BuiltType>> {
10771077
if (paramNode->getKind() != NodeKind::TupleElement)
10781078
return None;
10791079

include/swift/Reflection/TypeRefBuilder.h

+24-23
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,9 @@ class TypeRefBuilder {
248248

249249
public:
250250
using BuiltType = const TypeRef *;
251-
using BuiltTypeDecl = Optional<std::string>;
252-
using BuiltProtocolDecl = Optional<std::pair<std::string, bool /*isObjC*/>>;
251+
using BuiltTypeDecl = llvm::Optional<std::string>;
252+
using BuiltProtocolDecl =
253+
llvm::Optional<std::pair<std::string, bool /*isObjC*/>>;
253254

254255
TypeRefBuilder(const TypeRefBuilder &other) = delete;
255256
TypeRefBuilder &operator=(const TypeRefBuilder &other) = delete;
@@ -295,8 +296,7 @@ class TypeRefBuilder {
295296
return BuiltinTypeRef::create(*this, mangledName);
296297
}
297298

298-
Optional<std::string>
299-
createTypeDecl(Node *node, bool &typeAlias) {
299+
llvm::Optional<std::string> createTypeDecl(Node *node, bool &typeAlias) {
300300
return Demangle::mangleNode(node);
301301
}
302302

@@ -310,25 +310,25 @@ class TypeRefBuilder {
310310
return std::make_pair(name, true);
311311
}
312312

313-
Optional<std::string> createTypeDecl(std::string &&mangledName,
314-
bool &typeAlias) {
313+
llvm::Optional<std::string> createTypeDecl(std::string &&mangledName,
314+
bool &typeAlias) {
315315
return std::move(mangledName);
316316
}
317-
318-
const NominalTypeRef *createNominalType(
319-
const Optional<std::string> &mangledName) {
317+
318+
const NominalTypeRef *
319+
createNominalType(const llvm::Optional<std::string> &mangledName) {
320320
return NominalTypeRef::create(*this, *mangledName, nullptr);
321321
}
322322

323-
const NominalTypeRef *createNominalType(
324-
const Optional<std::string> &mangledName,
325-
const TypeRef *parent) {
323+
const NominalTypeRef *
324+
createNominalType(const llvm::Optional<std::string> &mangledName,
325+
const TypeRef *parent) {
326326
return NominalTypeRef::create(*this, *mangledName, parent);
327327
}
328328

329-
const TypeRef *createTypeAliasType(
330-
const Optional<std::string> &mangledName,
331-
const TypeRef *parent) {
329+
const TypeRef *
330+
createTypeAliasType(const llvm::Optional<std::string> &mangledName,
331+
const TypeRef *parent) {
332332
// TypeRefs don't contain sugared types
333333
return nullptr;
334334
}
@@ -354,13 +354,13 @@ class TypeRefBuilder {
354354
}
355355

356356
const BoundGenericTypeRef *
357-
createBoundGenericType(const Optional<std::string> &mangledName,
357+
createBoundGenericType(const llvm::Optional<std::string> &mangledName,
358358
const std::vector<const TypeRef *> &args) {
359359
return BoundGenericTypeRef::create(*this, *mangledName, args, nullptr);
360360
}
361361

362362
const BoundGenericTypeRef *
363-
createBoundGenericType(const Optional<std::string> &mangledName,
363+
createBoundGenericType(const llvm::Optional<std::string> &mangledName,
364364
llvm::ArrayRef<const TypeRef *> args,
365365
const TypeRef *parent) {
366366
return BoundGenericTypeRef::create(*this, *mangledName, args, parent);
@@ -420,7 +420,7 @@ class TypeRefBuilder {
420420
Demangle::ImplParameterConvention calleeConvention,
421421
llvm::ArrayRef<Demangle::ImplFunctionParam<const TypeRef *>> params,
422422
llvm::ArrayRef<Demangle::ImplFunctionResult<const TypeRef *>> results,
423-
Optional<Demangle::ImplFunctionResult<const TypeRef *>> errorResult,
423+
llvm::Optional<Demangle::ImplFunctionResult<const TypeRef *>> errorResult,
424424
ImplFunctionTypeFlags flags) {
425425
// Minimal support for lowered function types. These come up in
426426
// reflection as capture types. For the reflection library's
@@ -467,14 +467,15 @@ class TypeRefBuilder {
467467
isClassBound);
468468
}
469469

470-
const ExistentialMetatypeTypeRef *
471-
createExistentialMetatypeType(const TypeRef *instance,
472-
Optional<Demangle::ImplMetatypeRepresentation> repr=None) {
470+
const ExistentialMetatypeTypeRef *createExistentialMetatypeType(
471+
const TypeRef *instance,
472+
llvm::Optional<Demangle::ImplMetatypeRepresentation> repr = None) {
473473
return ExistentialMetatypeTypeRef::create(*this, instance);
474474
}
475475

476-
const MetatypeTypeRef *createMetatypeType(const TypeRef *instance,
477-
Optional<Demangle::ImplMetatypeRepresentation> repr=None) {
476+
const MetatypeTypeRef *createMetatypeType(
477+
const TypeRef *instance,
478+
llvm::Optional<Demangle::ImplMetatypeRepresentation> repr = None) {
478479
bool WasAbstract = (repr && *repr != ImplMetatypeRepresentation::Thin);
479480
return MetatypeTypeRef::create(*this, instance, WasAbstract);
480481
}

0 commit comments

Comments
 (0)