mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Ownership is truly a property not of a declaration, but of a function body. So it makes sense to just match what we deserialize. This also helps us to avoid mismatches if we lower ownership from a function, delete it, and then relink it. I also used this as an opportunity to clean up where we set that flag in deserialization to only happen in one place for both declarations/definitions.
45 lines
1.5 KiB
C++
45 lines
1.5 KiB
C++
//===--- SerializationFunctionBuilder.h -----------------------------------===//
|
|
//
|
|
// This source file is part of the Swift.org open source project
|
|
//
|
|
// Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors
|
|
// Licensed under Apache License v2.0 with Runtime Library Exception
|
|
//
|
|
// See https://swift.org/LICENSE.txt for license information
|
|
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef SWIFT_SERIALIZATION_SERIALIZATIONFUNCTIONBUILDER_H
|
|
#define SWIFT_SERIALIZATION_SERIALIZATIONFUNCTIONBUILDER_H
|
|
|
|
#include "swift/SIL/SILFunctionBuilder.h"
|
|
|
|
namespace swift {
|
|
|
|
class LLVM_LIBRARY_VISIBILITY SILSerializationFunctionBuilder {
|
|
SILFunctionBuilder builder;
|
|
|
|
public:
|
|
SILSerializationFunctionBuilder(SILModule &mod) : builder(mod) {}
|
|
|
|
/// Create a SILFunction declaration for use either as a forward reference or
|
|
/// for the eventual deserialization of a function body.
|
|
SILFunction *createDeclaration(StringRef name, SILType type,
|
|
SILLocation loc) {
|
|
return builder.createFunction(
|
|
SILLinkage::Private, name, type.getAs<SILFunctionType>(), nullptr,
|
|
loc, IsNotBare, IsNotTransparent,
|
|
IsNotSerialized, IsNotDynamic, ProfileCounter(), IsNotThunk,
|
|
SubclassScope::NotApplicable);
|
|
}
|
|
|
|
void setHasOwnership(SILFunction *f, bool newValue) {
|
|
builder.setHasOwnership(f, newValue);
|
|
}
|
|
};
|
|
|
|
} // namespace swift
|
|
|
|
#endif
|