<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - Idea: Extend @available so that it can imply an upper bound too"
href="https://bugs.llvm.org/show_bug.cgi?id=33815">33815</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Idea: Extend @available so that it can imply an upper bound too
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Frontend
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>nicolasweber@gmx.de
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>(Feature idea; not important; feel free to WontFix.)
This is a somewhat common pattern:
if (@available(macos 10.10, *)) {
DoThingUsingNewAPIs()
} else {
DoThingUsingOldAPIs()
}
(e.g. here:
<a href="https://cs.chromium.org/chromium/src/content/common/quarantine/quarantine_mac.mm?l=239">https://cs.chromium.org/chromium/src/content/common/quarantine/quarantine_mac.mm?l=239</a>)
@available helps with the first half of that branch, but the implementation of
DoThingUsingOldAPIs() often has to suppress Wdeprecated-declaration (see e.g.
the above-linked file). It'd be cool if the else of an if
(@available(macos10.10)) was a "at most macOS 10.9" region, which could call
functions marked with attrib(availability(deprecated=10.10), and then in those
functions calls to deprecated functions wouldn't be emitted.
...hmm, looking more at this example, there's this comment:
// Once Chrome no longer supports macOS 10.9, this code will no longer be
// necessary. Note that LSCopyItemAttribute was deprecated in macOS 10.8, but
// the replacement to kLSItemQuarantineProperties did not exist until macOS
// 10.10.
So I think this only helps in situations where the availability annotation in
the SDK is wrong. Suppressing warnings for that is OK, I suppose.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>