SymbolVisitorCallbackPipeline.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- SymbolVisitorCallbackPipeline.h --------------------------*- 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. #ifndef LLVM_DEBUGINFO_CODEVIEW_SYMBOLVISITORCALLBACKPIPELINE_H
  14. #define LLVM_DEBUGINFO_CODEVIEW_SYMBOLVISITORCALLBACKPIPELINE_H
  15. #include "llvm/DebugInfo/CodeView/SymbolRecord.h"
  16. #include "llvm/DebugInfo/CodeView/SymbolVisitorCallbacks.h"
  17. #include "llvm/Support/Error.h"
  18. #include <vector>
  19. namespace llvm {
  20. namespace codeview {
  21. class SymbolVisitorCallbackPipeline : public SymbolVisitorCallbacks {
  22. public:
  23. SymbolVisitorCallbackPipeline() = default;
  24. Error visitUnknownSymbol(CVSymbol &Record) override {
  25. for (auto *Visitor : Pipeline) {
  26. if (auto EC = Visitor->visitUnknownSymbol(Record))
  27. return EC;
  28. }
  29. return Error::success();
  30. }
  31. Error visitSymbolBegin(CVSymbol &Record, uint32_t Offset) override {
  32. for (auto *Visitor : Pipeline) {
  33. if (auto EC = Visitor->visitSymbolBegin(Record, Offset))
  34. return EC;
  35. }
  36. return Error::success();
  37. }
  38. Error visitSymbolBegin(CVSymbol &Record) override {
  39. for (auto *Visitor : Pipeline) {
  40. if (auto EC = Visitor->visitSymbolBegin(Record))
  41. return EC;
  42. }
  43. return Error::success();
  44. }
  45. Error visitSymbolEnd(CVSymbol &Record) override {
  46. for (auto *Visitor : Pipeline) {
  47. if (auto EC = Visitor->visitSymbolEnd(Record))
  48. return EC;
  49. }
  50. return Error::success();
  51. }
  52. void addCallbackToPipeline(SymbolVisitorCallbacks &Callbacks) {
  53. Pipeline.push_back(&Callbacks);
  54. }
  55. #define SYMBOL_RECORD(EnumName, EnumVal, Name) \
  56. Error visitKnownRecord(CVSymbol &CVR, Name &Record) override { \
  57. for (auto Visitor : Pipeline) { \
  58. if (auto EC = Visitor->visitKnownRecord(CVR, Record)) \
  59. return EC; \
  60. } \
  61. return Error::success(); \
  62. }
  63. #define SYMBOL_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
  64. #include "llvm/DebugInfo/CodeView/CodeViewSymbols.def"
  65. private:
  66. std::vector<SymbolVisitorCallbacks *> Pipeline;
  67. };
  68. } // end namespace codeview
  69. } // end namespace llvm
  70. #endif // LLVM_DEBUGINFO_CODEVIEW_SYMBOLVISITORCALLBACKPIPELINE_H
  71. #ifdef __GNUC__
  72. #pragma GCC diagnostic pop
  73. #endif