ObjCMethodList.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===--- ObjCMethodList.h - A singly linked list of methods -----*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. //
  14. // This file defines ObjCMethodList, a singly-linked list of methods.
  15. //
  16. //===----------------------------------------------------------------------===//
  17. #ifndef LLVM_CLANG_SEMA_OBJCMETHODLIST_H
  18. #define LLVM_CLANG_SEMA_OBJCMETHODLIST_H
  19. #include "clang/AST/DeclObjC.h"
  20. #include "llvm/ADT/PointerIntPair.h"
  21. namespace clang {
  22. class ObjCMethodDecl;
  23. /// a linked list of methods with the same selector name but different
  24. /// signatures.
  25. struct ObjCMethodList {
  26. // NOTE: If you add any members to this struct, make sure to serialize them.
  27. /// If there is more than one decl with this signature.
  28. llvm::PointerIntPair<ObjCMethodDecl *, 1> MethodAndHasMoreThanOneDecl;
  29. /// The next list object and 2 bits for extra info.
  30. llvm::PointerIntPair<ObjCMethodList *, 2> NextAndExtraBits;
  31. ObjCMethodList() { }
  32. ObjCMethodList(ObjCMethodDecl *M)
  33. : MethodAndHasMoreThanOneDecl(M, 0) {}
  34. ObjCMethodList(const ObjCMethodList &L)
  35. : MethodAndHasMoreThanOneDecl(L.MethodAndHasMoreThanOneDecl),
  36. NextAndExtraBits(L.NextAndExtraBits) {}
  37. ObjCMethodList &operator=(const ObjCMethodList &L) {
  38. MethodAndHasMoreThanOneDecl = L.MethodAndHasMoreThanOneDecl;
  39. NextAndExtraBits = L.NextAndExtraBits;
  40. return *this;
  41. }
  42. ObjCMethodList *getNext() const { return NextAndExtraBits.getPointer(); }
  43. unsigned getBits() const { return NextAndExtraBits.getInt(); }
  44. void setNext(ObjCMethodList *L) { NextAndExtraBits.setPointer(L); }
  45. void setBits(unsigned B) { NextAndExtraBits.setInt(B); }
  46. ObjCMethodDecl *getMethod() const {
  47. return MethodAndHasMoreThanOneDecl.getPointer();
  48. }
  49. void setMethod(ObjCMethodDecl *M) {
  50. return MethodAndHasMoreThanOneDecl.setPointer(M);
  51. }
  52. bool hasMoreThanOneDecl() const {
  53. return MethodAndHasMoreThanOneDecl.getInt();
  54. }
  55. void setHasMoreThanOneDecl(bool B) {
  56. return MethodAndHasMoreThanOneDecl.setInt(B);
  57. }
  58. };
  59. }
  60. #endif
  61. #ifdef __GNUC__
  62. #pragma GCC diagnostic pop
  63. #endif