Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:42:51

0001 //===-- DebugMacros.h -------------------------------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLDB_SYMBOL_DEBUGMACROS_H
0010 #define LLDB_SYMBOL_DEBUGMACROS_H
0011 
0012 #include <memory>
0013 #include <vector>
0014 
0015 #include "lldb/Utility/ConstString.h"
0016 #include "lldb/lldb-private.h"
0017 
0018 namespace lldb_private {
0019 
0020 class CompileUnit;
0021 class DebugMacros;
0022 typedef std::shared_ptr<DebugMacros> DebugMacrosSP;
0023 
0024 class DebugMacroEntry {
0025 public:
0026   enum EntryType : uint8_t {
0027       INVALID, DEFINE, UNDEF, START_FILE, END_FILE, INDIRECT
0028   };
0029 
0030   static DebugMacroEntry CreateDefineEntry(uint32_t line, const char *str);
0031 
0032   static DebugMacroEntry CreateUndefEntry(uint32_t line, const char *str);
0033 
0034   static DebugMacroEntry CreateStartFileEntry(uint32_t line,
0035                                               uint32_t debug_line_file_idx);
0036 
0037   static DebugMacroEntry CreateEndFileEntry();
0038 
0039   static DebugMacroEntry
0040   CreateIndirectEntry(const DebugMacrosSP &debug_macros_sp);
0041 
0042   DebugMacroEntry() : m_type(INVALID), m_line(0), m_debug_line_file_idx(0) {}
0043 
0044   ~DebugMacroEntry() = default;
0045 
0046   EntryType GetType() const { return static_cast<EntryType>(m_type); }
0047 
0048   uint64_t GetLineNumber() const { return m_line; }
0049 
0050   ConstString GetMacroString() const { return m_str; }
0051 
0052   const FileSpec &GetFileSpec(CompileUnit *comp_unit) const;
0053 
0054   DebugMacros *GetIndirectDebugMacros() const {
0055     return m_debug_macros_sp.get();
0056   }
0057 
0058 private:
0059   DebugMacroEntry(EntryType type, uint32_t line, uint32_t debug_line_file_idx,
0060                   const char *str);
0061 
0062   DebugMacroEntry(EntryType type, const DebugMacrosSP &debug_macros_sp);
0063 
0064   uint32_t m_type : 3;
0065   uint32_t m_line : 29;
0066   uint32_t m_debug_line_file_idx;
0067   ConstString m_str;
0068   DebugMacrosSP m_debug_macros_sp;
0069 };
0070 
0071 class DebugMacros {
0072 public:
0073   DebugMacros() = default;
0074 
0075   ~DebugMacros() = default;
0076 
0077   void AddMacroEntry(const DebugMacroEntry &entry) {
0078     m_macro_entries.push_back(entry);
0079   }
0080 
0081   size_t GetNumMacroEntries() const { return m_macro_entries.size(); }
0082 
0083   DebugMacroEntry GetMacroEntryAtIndex(const size_t index) const {
0084     if (index < m_macro_entries.size())
0085       return m_macro_entries[index];
0086     else
0087       return DebugMacroEntry();
0088   }
0089 
0090 private:
0091   DebugMacros(const DebugMacros &) = delete;
0092   const DebugMacros &operator=(const DebugMacros &) = delete;
0093 
0094   std::vector<DebugMacroEntry> m_macro_entries;
0095 };
0096 
0097 } // namespace lldb_private
0098 
0099 #endif // LLDB_SYMBOL_DEBUGMACROS_H