[llvm-bugs] [Bug 33815] New: Idea: Extend @available so that it can imply an upper bound too

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Jul 17 07:38:57 PDT 2017


https://bugs.llvm.org/show_bug.cgi?id=33815

            Bug ID: 33815
           Summary: Idea: Extend @available so that it can imply an upper
                    bound too
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: nicolasweber at gmx.de
                CC: llvm-bugs at lists.llvm.org

(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: 
https://cs.chromium.org/chromium/src/content/common/quarantine/quarantine_mac.mm?l=239)

@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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170717/12360d56/attachment.html>


More information about the llvm-bugs mailing list