1 //===--- AlignedAllocation.h - Aligned Allocation ---------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 /// 10 /// \file 11 /// \brief Defines a function that returns the minimum OS versions supporting 12 /// C++17's aligned allocation functions. 13 /// 14 //===----------------------------------------------------------------------===// 15 16 #ifndef LLVM_CLANG_BASIC_ALIGNED_ALLOCATION_H 17 #define LLVM_CLANG_BASIC_ALIGNED_ALLOCATION_H 18 19 #include "clang/Basic/VersionTuple.h" 20 #include "llvm/ADT/Triple.h" 21 #include "llvm/Support/ErrorHandling.h" 22 23 namespace clang { 24 25 inline VersionTuple alignedAllocMinVersion(llvm::Triple::OSType OS) { 26 switch (OS) { 27 default: 28 break; 29 case llvm::Triple::Darwin: 30 case llvm::Triple::MacOSX: // Earliest supporting version is 10.13. 31 return VersionTuple(10U, 13U); 32 case llvm::Triple::IOS: 33 case llvm::Triple::TvOS: // Earliest supporting version is 11.0.0. 34 return VersionTuple(11U); 35 case llvm::Triple::WatchOS: // Earliest supporting version is 4.0.0. 36 return VersionTuple(4U); 37 } 38 39 llvm_unreachable("Unexpected OS"); 40 } 41 42 } // end namespace clang 43 44 #endif // LLVM_CLANG_BASIC_ALIGNED_ALLOCATION_H 45