mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-01 01:31:26 +00:00
[mac/lld] simplify code using PackedVersion instead of VersionTuple
PackedVersion already does the correct range checks. No behavior change. Differential Revision: https://reviews.llvm.org/D93338
This commit is contained in:
parent
3a0352b85c
commit
09edd9df6e
@ -40,6 +40,7 @@
|
|||||||
#include "llvm/Support/Path.h"
|
#include "llvm/Support/Path.h"
|
||||||
#include "llvm/Support/TarWriter.h"
|
#include "llvm/Support/TarWriter.h"
|
||||||
#include "llvm/Support/TargetSelect.h"
|
#include "llvm/Support/TargetSelect.h"
|
||||||
|
#include "llvm/TextAPI/MachO/PackedVersion.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
@ -673,34 +674,13 @@ static uint32_t parseDylibVersion(const opt::ArgList& args, unsigned id) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
llvm::VersionTuple version;
|
PackedVersion version;
|
||||||
if (version.tryParse(arg->getValue()) || version.getBuild().hasValue()) {
|
if (!version.parse32(arg->getValue())) {
|
||||||
error(arg->getAsString(args) + ": malformed version");
|
error(arg->getAsString(args) + ": malformed version");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned major = version.getMajor();
|
return version.rawValue();
|
||||||
if (major > UINT16_MAX) {
|
|
||||||
error(arg->getAsString(args) + ": component " + Twine(major) +
|
|
||||||
" out of range");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned minor = version.getMinor().getValueOr(0);
|
|
||||||
if (minor > UINT8_MAX) {
|
|
||||||
error(arg->getAsString(args) + ": component " + Twine(minor) +
|
|
||||||
" out of range");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned subminor = version.getSubminor().getValueOr(0);
|
|
||||||
if (subminor > UINT8_MAX) {
|
|
||||||
error(arg->getAsString(args) + ": component " + Twine(subminor) +
|
|
||||||
" out of range");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (major << 16) | (minor << 8) | subminor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool macho::link(llvm::ArrayRef<const char *> argsArr, bool canExitEarly,
|
bool macho::link(llvm::ArrayRef<const char *> argsArr, bool canExitEarly,
|
||||||
|
@ -25,19 +25,19 @@
|
|||||||
# RUN: -compatibility_version 80000.1 -current_version 1.2.3 2>&1 | \
|
# RUN: -compatibility_version 80000.1 -current_version 1.2.3 2>&1 | \
|
||||||
# RUN: FileCheck --check-prefix=BADMAJOR %s
|
# RUN: FileCheck --check-prefix=BADMAJOR %s
|
||||||
|
|
||||||
# BADMAJOR: error: -compatibility_version 80000.1: component 80000 out of range
|
# BADMAJOR: error: -compatibility_version 80000.1: malformed version
|
||||||
|
|
||||||
# RUN: not %lld -dylib -o %t/executable %t.o -o /dev/null \
|
# RUN: not %lld -dylib -o %t/executable %t.o -o /dev/null \
|
||||||
# RUN: -compatibility_version 8.300 -current_version 1.2.3 2>&1 | \
|
# RUN: -compatibility_version 8.300 -current_version 1.2.3 2>&1 | \
|
||||||
# RUN: FileCheck --check-prefix=BADMINOR %s
|
# RUN: FileCheck --check-prefix=BADMINOR %s
|
||||||
|
|
||||||
# BADMINOR: error: -compatibility_version 8.300: component 300 out of range
|
# BADMINOR: error: -compatibility_version 8.300: malformed version
|
||||||
|
|
||||||
# RUN: not %lld -dylib -o %t/executable %t.o -o /dev/null \
|
# RUN: not %lld -dylib -o %t/executable %t.o -o /dev/null \
|
||||||
# RUN: -compatibility_version 8.8.300 -current_version 1.2.3 2>&1 | \
|
# RUN: -compatibility_version 8.8.300 -current_version 1.2.3 2>&1 | \
|
||||||
# RUN: FileCheck --check-prefix=BADSUBMINOR %s
|
# RUN: FileCheck --check-prefix=BADSUBMINOR %s
|
||||||
|
|
||||||
# BADSUBMINOR: error: -compatibility_version 8.8.300: component 300 out of range
|
# BADSUBMINOR: error: -compatibility_version 8.8.300: malformed version
|
||||||
|
|
||||||
# RUN: %lld -dylib -o %t/executable %t.o -o %t.dylib \
|
# RUN: %lld -dylib -o %t/executable %t.o -o %t.dylib \
|
||||||
# RUN: -compatibility_version 1.2.3 -current_version 2.5.6
|
# RUN: -compatibility_version 1.2.3 -current_version 2.5.6
|
||||||
|
Loading…
Reference in New Issue
Block a user