[iOS/OS X] Allow base::scoped_nsobject<> to be used when ARC is enabled.

Add annotations (http://clang-analyzer.llvm.org/annotations.html) to
prevent clang from mucking with the objects reference count while
generating base::scoped_nsobject<> code when Automatic Reference
Counting (a.k.a. ARC) is enabled.

Use static function to perform explicit reference counting without
causing compilation errors when the file is included from a source
file with ARC enabled.

When using ARC, base::scoped_nsobject<> constructor and reset() method
have a different signature that does not allow passing the policy and
default to base::scoped_policy::RETAIN (this cause no visible change as
ARC insert a call to release). The ns_consumed annotation is supposed
to inform ARC not to insert that call, but does not work (see upstream
issue https://llvm.org/bugs/show_bug.cgi?id=27887).

Design document:
https://docs.google.com/document/d/1dEZ-pdHP6Q32yffHtrQjeUDGAD1MuPGaGOrMfdi1ihk/edit#

BUG=599992

Review-Url: https://codereview.chromium.org/1855483004
Cr-Commit-Position: refs/heads/master@{#400132}


CrOS-Libchrome-Original-Commit: fd625125b8a6a3aceaf09993a5f74cfe5368b17f
2 files changed
tree: 0828a96aaa7c4f3edd760846ce60f09b44567979
  1. base/
  2. build/
  3. components/
  4. dbus/
  5. device/
  6. ipc/
  7. mojo/
  8. testing/
  9. third_party/
  10. ui/