aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/llvm/lib/TextAPI/TextStubV5.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm-project/llvm/lib/TextAPI/TextStubV5.cpp')
-rw-r--r--contrib/llvm-project/llvm/lib/TextAPI/TextStubV5.cpp43
1 files changed, 26 insertions, 17 deletions
diff --git a/contrib/llvm-project/llvm/lib/TextAPI/TextStubV5.cpp b/contrib/llvm-project/llvm/lib/TextAPI/TextStubV5.cpp
index 5b3d69b8d94a..2f82bc03480b 100644
--- a/contrib/llvm-project/llvm/lib/TextAPI/TextStubV5.cpp
+++ b/contrib/llvm-project/llvm/lib/TextAPI/TextStubV5.cpp
@@ -27,7 +27,7 @@ All library level keys, accept target values and are defaulted if not specified.
"target_info": [ # Required: target information
{
"target": "x86_64-macos",
- "min_deployment": "10.14" # Required: minimum OS deployment version
+ "min_deployment": "10.14" # Optional: minOS defaults to 0
},
{
"target": "arm64-macos",
@@ -283,17 +283,16 @@ Expected<TargetList> getTargetsSection(const Object *Section) {
getRequiredValue<StringRef>(TBDKey::Target, Obj, &Object::getString);
if (!TargetStr)
return make_error<JSONStubError>(getParseErrorMsg(TBDKey::Target));
- auto VersionStr = getRequiredValue<StringRef>(TBDKey::Deployment, Obj,
- &Object::getString);
- if (!VersionStr)
- return make_error<JSONStubError>(getParseErrorMsg(TBDKey::Deployment));
- VersionTuple Version;
- if (Version.tryParse(*VersionStr))
- return make_error<JSONStubError>(getParseErrorMsg(TBDKey::Deployment));
auto TargetOrErr = Target::create(*TargetStr);
if (!TargetOrErr)
return make_error<JSONStubError>(getParseErrorMsg(TBDKey::Target));
+
+ auto VersionStr = Obj->getString(Keys[TBDKey::Deployment]);
+ VersionTuple Version;
+ if (VersionStr && Version.tryParse(*VersionStr))
+ return make_error<JSONStubError>(getParseErrorMsg(TBDKey::Deployment));
TargetOrErr->MinDeployment = Version;
+
// Convert to LLVM::Triple to accurately compute minOS + platform + arch
// pairing.
IFTargets.push_back(
@@ -548,11 +547,11 @@ Expected<PackedVersion> getPackedVersion(const Object *File, TBDKey Key) {
Expected<TBDFlags> getFlags(const Object *File) {
TBDFlags Flags = TBDFlags::None;
const Array *Section = File->getArray(Keys[TBDKey::Flags]);
- if (!Section)
+ if (!Section || Section->empty())
return Flags;
for (auto &Val : *Section) {
- // TODO: Just take first for now.
+ // FIXME: Flags currently apply to all target triples.
const auto *Obj = Val.getAsObject();
if (!Obj)
return make_error<JSONStubError>(getParseErrorMsg(TBDKey::Flags));
@@ -564,6 +563,9 @@ Expected<TBDFlags> getFlags(const Object *File) {
.Case("flat_namespace", TBDFlags::FlatNamespace)
.Case("not_app_extension_safe",
TBDFlags::NotApplicationExtensionSafe)
+ .Case("sim_support", TBDFlags::SimulatorSupport)
+ .Case("not_for_dyld_shared_cache",
+ TBDFlags::OSLibNotForSharedCache)
.Default(TBDFlags::None);
Flags |= TBDFlag;
});
@@ -654,6 +656,8 @@ Expected<IFPtr> parseToInterfaceFile(const Object *File) {
F->setTwoLevelNamespace(!(Flags & TBDFlags::FlatNamespace));
F->setApplicationExtensionSafe(
!(Flags & TBDFlags::NotApplicationExtensionSafe));
+ F->setSimulatorSupport((Flags & TBDFlags::SimulatorSupport));
+ F->setOSLibNotForSharedCache((Flags & TBDFlags::OSLibNotForSharedCache));
for (auto &T : Targets)
F->addTarget(T);
for (auto &[Lib, Targets] : Clients)
@@ -753,9 +757,9 @@ std::vector<std::string> serializeTargets(const AggregateT Targets,
if (Targets.size() == ActiveTargets.size())
return TargetsStr;
- llvm::for_each(Targets, [&TargetsStr](const MachO::Target &Target) {
+ for (const MachO::Target &Target : Targets)
TargetsStr.emplace_back(getFormattedStr(Target));
- });
+
return TargetsStr;
}
@@ -763,7 +767,8 @@ Array serializeTargetInfo(const TargetList &ActiveTargets) {
Array Targets;
for (const auto Targ : ActiveTargets) {
Object TargetInfo;
- TargetInfo[Keys[TBDKey::Deployment]] = Targ.MinDeployment.getAsString();
+ if (!Targ.MinDeployment.empty())
+ TargetInfo[Keys[TBDKey::Deployment]] = Targ.MinDeployment.getAsString();
TargetInfo[Keys[TBDKey::Target]] = getFormattedStr(Targ);
Targets.emplace_back(std::move(TargetInfo));
}
@@ -920,6 +925,10 @@ Array serializeFlags(const InterfaceFile *File) {
Flags.emplace_back("flat_namespace");
if (!File->isApplicationExtensionSafe())
Flags.emplace_back("not_app_extension_safe");
+ if (File->hasSimulatorSupport())
+ Flags.emplace_back("sim_support");
+ if (File->isOSLibNotForSharedCache())
+ Flags.emplace_back("not_for_dyld_shared_cache");
return serializeScalar(TBDKey::Attributes, std::move(Flags));
}
@@ -983,9 +992,8 @@ Expected<Object> serializeIF(const InterfaceFile *File) {
return std::move(Library);
}
-Expected<Object> getJSON(const InterfaceFile *File) {
- assert(File->getFileType() == FileType::TBD_V5 &&
- "unexpected json file format version");
+Expected<Object> getJSON(const InterfaceFile *File, const FileType FileKind) {
+ assert(FileKind == FileType::TBD_V5 && "unexpected json file format version");
Object Root;
auto MainLibOrErr = serializeIF(File);
@@ -1009,8 +1017,9 @@ Expected<Object> getJSON(const InterfaceFile *File) {
Error MachO::serializeInterfaceFileToJSON(raw_ostream &OS,
const InterfaceFile &File,
+ const FileType FileKind,
bool Compact) {
- auto TextFile = getJSON(&File);
+ auto TextFile = getJSON(&File, FileKind);
if (!TextFile)
return TextFile.takeError();
if (Compact)