Skip to content

Replace Hand-Rolled MAX/MIN with std::max/std::min #78819

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions lib/Basic/Platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,8 +434,6 @@ llvm::Triple swift::getUnversionedTriple(const llvm::Triple &triple) {
std::optional<llvm::VersionTuple>
swift::getSwiftRuntimeCompatibilityVersionForTarget(
const llvm::Triple &Triple) {
#define MAX(a, b) ((a) > (b) ? (a) : (b))

if (Triple.isMacOSX()) {
llvm::VersionTuple OSVersion;
Triple.getMacOSXVersion(OSVersion);
Expand All @@ -445,7 +443,7 @@ swift::getSwiftRuntimeCompatibilityVersionForTarget(
auto floorFor64 = [&Triple](llvm::VersionTuple v) {
if (!Triple.isAArch64()) return v;
// macOS got first arm64(e) support in 11.0, i.e. VersionTuple(5, 3)
return MAX(v, llvm::VersionTuple(5, 3));
return std::max(v, llvm::VersionTuple(5, 3));
};

if (Major == 10) {
Expand Down Expand Up @@ -489,13 +487,13 @@ swift::getSwiftRuntimeCompatibilityVersionForTarget(
if (Triple.isAArch64() && Major <= 14 &&
(Triple.isSimulatorEnvironment() ||
Triple.isMacCatalystEnvironment()))
return MAX(v, llvm::VersionTuple(5, 3));
return std::max(v, llvm::VersionTuple(5, 3));

if (Triple.getArchName() != "arm64e") return v;

// iOS got first arm64e support in 12.0, which has a Swift runtime version
// older than 5.0, so let's floor at VersionTuple(5, 0) instead.
return MAX(v, llvm::VersionTuple(5, 0));
return std::max(v, llvm::VersionTuple(5, 0));
};

if (Major <= 12) {
Expand Down Expand Up @@ -532,7 +530,7 @@ swift::getSwiftRuntimeCompatibilityVersionForTarget(
auto floorFor64bits = [&Triple](llvm::VersionTuple v) {
if (!Triple.isArch64Bit()) return v;
// 64-bit watchOS was introduced with Swift 5.3
return MAX(v, llvm::VersionTuple(5, 3));
return std::max(v, llvm::VersionTuple(5, 3));
};

if (Major <= 5) {
Expand Down
2 changes: 0 additions & 2 deletions stdlib/tools/swift-reflection-test/swift-reflection-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
// on live swift executables.
//===----------------------------------------------------------------------===//

#define MIN(a,b) (((a)<(b))?(a):(b))
#define MAX(a,b) (((a)>(b))?(a):(b))
#define SECTIONS_PER_INFO 6

#include "swift/SwiftRemoteMirror/SwiftRemoteMirror.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
#include <cstddef>
#include "enums.h"

#define MAX(a, b) ((a) >= (b) ? (a) : (b))

int main() {
using namespace Enums;

Expand Down