DWARFDebugMacro.h revision 353358
150276Speter//===- DWARFDebugMacro.h ----------------------------------------*- C++ -*-===// 2176187Srafan// 350276Speter// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 450276Speter// See https://llvm.org/LICENSE.txt for license information. 550276Speter// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 650276Speter// 750276Speter//===----------------------------------------------------------------------===// 850276Speter 950276Speter#ifndef LLVM_DEBUGINFO_DWARF_DWARFDEBUGMACRO_H 1050276Speter#define LLVM_DEBUGINFO_DWARF_DWARFDEBUGMACRO_H 1150276Speter 1250276Speter#include "llvm/ADT/SmallVector.h" 1350276Speter#include "llvm/Support/DataExtractor.h" 1450276Speter#include <cstdint> 1550276Speter 1650276Speternamespace llvm { 1750276Speter 1850276Speterclass raw_ostream; 1950276Speter 2050276Speterclass DWARFDebugMacro { 2150276Speter /// A single macro entry within a macro list. 2250276Speter struct Entry { 2350276Speter /// The type of the macro entry. 2450276Speter uint32_t Type; 2550276Speter union { 2650276Speter /// The source line where the macro is defined. 2750276Speter uint64_t Line; 2850276Speter /// Vendor extension constant value. 2950276Speter uint64_t ExtConstant; 30166124Srafan }; 3150276Speter 3250276Speter union { 3350276Speter /// The string (name, value) of the macro entry. 3450276Speter const char *MacroStr; 3550276Speter // An unsigned integer indicating the identity of the source file. 3650276Speter uint64_t File; 3750276Speter /// Vendor extension string. 3850276Speter const char *ExtStr; 3950276Speter }; 4050276Speter }; 4150276Speter 4250276Speter using MacroList = SmallVector<Entry, 4>; 4350276Speter 44184989Srafan /// A list of all the macro entries in the debug_macinfo section. 4550276Speter MacroList Macros; 46166124Srafan 47166124Srafanpublic: 48174993Srafan DWARFDebugMacro() = default; 49174993Srafan 50174993Srafan /// Print the macro list found within the debug_macinfo section. 51174993Srafan void dump(raw_ostream &OS) const; 52174993Srafan 53174993Srafan /// Parse the debug_macinfo section accessible via the 'data' parameter. 54174993Srafan void parse(DataExtractor data); 55166124Srafan 56166124Srafan /// Return whether the section has any entries. 57174993Srafan bool empty() const { return Macros.empty(); } 58174993Srafan}; 59174993Srafan 60174993Srafan} // end namespace llvm 61174993Srafan 62166124Srafan#endif // LLVM_DEBUGINFO_DWARF_DWARFDEBUGMACRO_H 63166124Srafan