Changeset View
Changeset View
Standalone View
Standalone View
llvm/include/llvm/ObjectYAML/DWARFYAML.h
Show All 15 Lines | |||||
#define LLVM_OBJECTYAML_DWARFYAML_H | #define LLVM_OBJECTYAML_DWARFYAML_H | ||||
#include "llvm/ADT/SetVector.h" | #include "llvm/ADT/SetVector.h" | ||||
#include "llvm/ADT/StringRef.h" | #include "llvm/ADT/StringRef.h" | ||||
#include "llvm/BinaryFormat/Dwarf.h" | #include "llvm/BinaryFormat/Dwarf.h" | ||||
#include "llvm/ObjectYAML/YAML.h" | #include "llvm/ObjectYAML/YAML.h" | ||||
#include "llvm/Support/YAMLTraits.h" | #include "llvm/Support/YAMLTraits.h" | ||||
#include <cstdint> | #include <cstdint> | ||||
#include <unordered_map> | |||||
#include <vector> | #include <vector> | ||||
namespace llvm { | namespace llvm { | ||||
namespace DWARFYAML { | namespace DWARFYAML { | ||||
struct AttributeAbbrev { | struct AttributeAbbrev { | ||||
llvm::dwarf::Attribute Attribute; | llvm::dwarf::Attribute Attribute; | ||||
llvm::dwarf::Form Form; | llvm::dwarf::Form Form; | ||||
llvm::yaml::Hex64 Value; // Some DWARF5 attributes have values | llvm::yaml::Hex64 Value; // Some DWARF5 attributes have values | ||||
}; | }; | ||||
struct Abbrev { | struct Abbrev { | ||||
Optional<yaml::Hex64> Code; | Optional<yaml::Hex64> Code; | ||||
llvm::dwarf::Tag Tag; | llvm::dwarf::Tag Tag; | ||||
llvm::dwarf::Constants Children; | llvm::dwarf::Constants Children; | ||||
std::vector<AttributeAbbrev> Attributes; | std::vector<AttributeAbbrev> Attributes; | ||||
}; | }; | ||||
struct AbbrevTable { | struct AbbrevTable { | ||||
Optional<uint64_t> ID; | |||||
std::vector<Abbrev> Table; | std::vector<Abbrev> Table; | ||||
}; | }; | ||||
struct ARangeDescriptor { | struct ARangeDescriptor { | ||||
llvm::yaml::Hex64 Address; | llvm::yaml::Hex64 Address; | ||||
yaml::Hex64 Length; | yaml::Hex64 Length; | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | |||||
}; | }; | ||||
struct Unit { | struct Unit { | ||||
dwarf::DwarfFormat Format; | dwarf::DwarfFormat Format; | ||||
Optional<yaml::Hex64> Length; | Optional<yaml::Hex64> Length; | ||||
uint16_t Version; | uint16_t Version; | ||||
Optional<uint8_t> AddrSize; | Optional<uint8_t> AddrSize; | ||||
llvm::dwarf::UnitType Type; // Added in DWARF 5 | llvm::dwarf::UnitType Type; // Added in DWARF 5 | ||||
Optional<uint64_t> AbbrevTableID; | |||||
yaml::Hex64 AbbrOffset; | yaml::Hex64 AbbrOffset; | ||||
std::vector<Entry> Entries; | std::vector<Entry> Entries; | ||||
}; | }; | ||||
struct File { | struct File { | ||||
StringRef Name; | StringRef Name; | ||||
uint64_t DirIdx; | uint64_t DirIdx; | ||||
uint64_t ModTime; | uint64_t ModTime; | ||||
▲ Show 20 Lines • Show All 102 Lines • ▼ Show 20 Lines | struct Data { | ||||
std::vector<LineTable> DebugLines; | std::vector<LineTable> DebugLines; | ||||
Optional<std::vector<ListTable<RnglistEntry>>> DebugRnglists; | Optional<std::vector<ListTable<RnglistEntry>>> DebugRnglists; | ||||
Optional<std::vector<ListTable<LoclistEntry>>> DebugLoclists; | Optional<std::vector<ListTable<LoclistEntry>>> DebugLoclists; | ||||
bool isEmpty() const; | bool isEmpty() const; | ||||
SetVector<StringRef> getNonEmptySectionNames() const; | SetVector<StringRef> getNonEmptySectionNames() const; | ||||
Expected<uint64_t> getAbbrevTableIndexByID(uint64_t ID); | |||||
private: | |||||
std::unordered_map<uint64_t, uint64_t> AbbrevTableID2Index; | |||||
jhenderson: Something to consider here: the user-visible behaviour of this class is that this is a `const`… | |||||
}; | }; | ||||
} // end namespace DWARFYAML | } // end namespace DWARFYAML | ||||
} // end namespace llvm | } // end namespace llvm | ||||
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::AttributeAbbrev) | LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::AttributeAbbrev) | ||||
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::Abbrev) | LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::Abbrev) | ||||
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::AbbrevTable) | LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::AbbrevTable) | ||||
▲ Show 20 Lines • Show All 236 Lines • Show Last 20 Lines |
Something to consider here: the user-visible behaviour of this class is that this is a const operation, but because this method causes AbbrevTableID2Index to be populated on the first call, it technically isn't. I would say this is a reasonable use case for mutable - the cache (in this case AbbrevTableID2Index) is marked as mutable, and then you can continue to pass this class around as const.