Symbol.cpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. //===- Symbol.cpp ---------------------------------------------------------===//
  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. //
  9. // Implements the Symbol.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. #include "llvm/TextAPI/Symbol.h"
  13. #include <string>
  14. namespace llvm {
  15. namespace MachO {
  16. #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
  17. LLVM_DUMP_METHOD void Symbol::dump(raw_ostream &OS) const {
  18. std::string Result;
  19. if (isUndefined())
  20. Result += "(undef) ";
  21. if (isWeakDefined())
  22. Result += "(weak-def) ";
  23. if (isWeakReferenced())
  24. Result += "(weak-ref) ";
  25. if (isThreadLocalValue())
  26. Result += "(tlv) ";
  27. switch (Kind) {
  28. case SymbolKind::GlobalSymbol:
  29. Result += Name.str();
  30. break;
  31. case SymbolKind::ObjectiveCClass:
  32. Result += "(ObjC Class) " + Name.str();
  33. break;
  34. case SymbolKind::ObjectiveCClassEHType:
  35. Result += "(ObjC Class EH) " + Name.str();
  36. break;
  37. case SymbolKind::ObjectiveCInstanceVariable:
  38. Result += "(ObjC IVar) " + Name.str();
  39. break;
  40. }
  41. OS << Result;
  42. }
  43. #endif
  44. Symbol::const_filtered_target_range
  45. Symbol::targets(ArchitectureSet Architectures) const {
  46. std::function<bool(const Target &)> FN =
  47. [Architectures](const Target &Target) {
  48. return Architectures.has(Target.Arch);
  49. };
  50. return make_filter_range(Targets, FN);
  51. }
  52. } // end namespace MachO.
  53. } // end namespace llvm.