Weak.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===-- UnresolvedSet.h - Unresolved sets of declarations ------*- 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 the WeakInfo class, which is used to store
  15. // information about the target of a #pragma weak directive.
  16. //
  17. //===----------------------------------------------------------------------===//
  18. #ifndef LLVM_CLANG_SEMA_WEAK_H
  19. #define LLVM_CLANG_SEMA_WEAK_H
  20. #include "clang/Basic/SourceLocation.h"
  21. #include "llvm/ADT/DenseMapInfo.h"
  22. namespace clang {
  23. class IdentifierInfo;
  24. /// Captures information about a \#pragma weak directive.
  25. class WeakInfo {
  26. const IdentifierInfo *alias = nullptr; // alias (optional)
  27. SourceLocation loc; // for diagnostics
  28. public:
  29. WeakInfo() = default;
  30. WeakInfo(const IdentifierInfo *Alias, SourceLocation Loc)
  31. : alias(Alias), loc(Loc) {}
  32. inline const IdentifierInfo *getAlias() const { return alias; }
  33. inline SourceLocation getLocation() const { return loc; }
  34. bool operator==(WeakInfo RHS) const = delete;
  35. bool operator!=(WeakInfo RHS) const = delete;
  36. struct DenseMapInfoByAliasOnly
  37. : private llvm::DenseMapInfo<const IdentifierInfo *> {
  38. static inline WeakInfo getEmptyKey() {
  39. return WeakInfo(DenseMapInfo::getEmptyKey(), SourceLocation());
  40. }
  41. static inline WeakInfo getTombstoneKey() {
  42. return WeakInfo(DenseMapInfo::getTombstoneKey(), SourceLocation());
  43. }
  44. static unsigned getHashValue(const WeakInfo &W) {
  45. return DenseMapInfo::getHashValue(W.getAlias());
  46. }
  47. static bool isEqual(const WeakInfo &LHS, const WeakInfo &RHS) {
  48. return DenseMapInfo::isEqual(LHS.getAlias(), RHS.getAlias());
  49. }
  50. };
  51. };
  52. } // end namespace clang
  53. #endif // LLVM_CLANG_SEMA_WEAK_H
  54. #ifdef __GNUC__
  55. #pragma GCC diagnostic pop
  56. #endif