StreamUtil.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. //===- Streamutil.h - PDB stream utilities ----------------------*- 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. #ifndef LLVM_TOOLS_LLVMPDBDUMP_STREAMUTIL_H
  9. #define LLVM_TOOLS_LLVMPDBDUMP_STREAMUTIL_H
  10. #include "llvm/ADT/Optional.h"
  11. #include "llvm/ADT/SmallVector.h"
  12. #include "llvm/ADT/StringRef.h"
  13. #include <string>
  14. namespace llvm {
  15. namespace pdb {
  16. class PDBFile;
  17. enum class StreamPurpose {
  18. NamedStream,
  19. ModuleStream,
  20. Symbols,
  21. PDB,
  22. DBI,
  23. TPI,
  24. IPI,
  25. GlobalHash,
  26. PublicHash,
  27. TpiHash,
  28. IpiHash,
  29. Other
  30. };
  31. struct StreamInfo {
  32. public:
  33. StreamInfo() {}
  34. uint32_t getModuleIndex() const { return *ModuleIndex; }
  35. StreamPurpose getPurpose() const { return Purpose; }
  36. StringRef getShortName() const { return Name; }
  37. uint32_t getStreamIndex() const { return StreamIndex; }
  38. std::string getLongName() const;
  39. static StreamInfo createStream(StreamPurpose Purpose, StringRef Name,
  40. uint32_t StreamIndex);
  41. static StreamInfo createModuleStream(StringRef Module, uint32_t StreamIndex,
  42. uint32_t Modi);
  43. private:
  44. StreamPurpose Purpose;
  45. uint32_t StreamIndex;
  46. std::string Name;
  47. Optional<uint32_t> ModuleIndex;
  48. };
  49. void discoverStreamPurposes(PDBFile &File,
  50. SmallVectorImpl<StreamInfo> &Streams);
  51. }
  52. }
  53. #endif