ObjCARCUtil.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. //===- ObjCARCUtil.h - ObjC ARC Utility Functions ---------------*- C++ -*-===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. /// \file
  9. /// This file defines ARC utility functions which are used by various parts of
  10. /// the compiler.
  11. ///
  12. //===----------------------------------------------------------------------===//
  13. #ifndef LLVM_IR_OBJCARCUTIL_H
  14. #define LLVM_IR_OBJCARCUTIL_H
  15. #include "llvm/IR/InstrTypes.h"
  16. #include "llvm/IR/LLVMContext.h"
  17. namespace llvm {
  18. namespace objcarc {
  19. inline const char *getRVMarkerModuleFlagStr() {
  20. return "clang.arc.retainAutoreleasedReturnValueMarker";
  21. }
  22. enum AttachedCallOperandBundle : unsigned { RVOB_Retain, RVOB_Claim };
  23. inline AttachedCallOperandBundle
  24. getAttachedCallOperandBundleEnum(bool IsRetain) {
  25. return IsRetain ? RVOB_Retain : RVOB_Claim;
  26. }
  27. inline bool hasAttachedCallOpBundle(const CallBase *CB, bool IsRetain) {
  28. auto B = CB->getOperandBundle(LLVMContext::OB_clang_arc_attachedcall);
  29. if (!B.hasValue())
  30. return false;
  31. return cast<ConstantInt>(B->Inputs[0])->getZExtValue() ==
  32. getAttachedCallOperandBundleEnum(IsRetain);
  33. }
  34. inline bool hasAttachedCallOpBundle(const CallBase *CB) {
  35. return CB->getOperandBundle(LLVMContext::OB_clang_arc_attachedcall)
  36. .hasValue();
  37. }
  38. } // end namespace objcarc
  39. } // end namespace llvm
  40. #endif