|
|
|||
File indexing completed on 2026-05-10 08:42:44
0001 //===-- Declaration.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_DECLARATION_H 0010 #define LLDB_SYMBOL_DECLARATION_H 0011 0012 #include "lldb/Utility/FileSpec.h" 0013 #include "lldb/lldb-private.h" 0014 0015 namespace lldb_private { 0016 0017 /// \class Declaration Declaration.h "lldb/Core/Declaration.h" 0018 /// A class that describes the declaration location of a 0019 /// lldb object. 0020 /// 0021 /// The declarations include the file specification, line number, and the 0022 /// column info and can help track where functions, blocks, inlined functions, 0023 /// types, variables, any many other debug core objects were declared. 0024 class Declaration { 0025 public: 0026 /// Default constructor. 0027 Declaration() = default; 0028 0029 /// Construct with file specification, and optional line and column. 0030 /// 0031 /// \param[in] file_spec 0032 /// The file specification that describes where this was 0033 /// declared. 0034 /// 0035 /// \param[in] line 0036 /// The line number that describes where this was declared. Set 0037 /// to zero if there is no line number information. 0038 /// 0039 /// \param[in] column 0040 /// The column number that describes where this was declared. 0041 /// Set to zero if there is no column number information. 0042 Declaration(const FileSpec &file_spec, uint32_t line = 0, 0043 uint16_t column = LLDB_INVALID_COLUMN_NUMBER) 0044 : m_file(file_spec), m_line(line), m_column(column) {} 0045 0046 /// Construct with a pointer to another Declaration object. 0047 Declaration(const Declaration *decl_ptr) 0048 : m_line(0), m_column(LLDB_INVALID_COLUMN_NUMBER) { 0049 if (decl_ptr) 0050 *this = *decl_ptr; 0051 } 0052 0053 /// Clear the object's state. 0054 /// 0055 /// Sets the file specification to be empty, and the line and column to 0056 /// zero. 0057 void Clear() { 0058 m_file.Clear(); 0059 m_line = 0; 0060 m_column = 0; 0061 } 0062 0063 /// Compare two declaration objects. 0064 /// 0065 /// Compares the two file specifications from \a lhs and \a rhs. If the file 0066 /// specifications are equal, then continue to compare the line number and 0067 /// column numbers respectively. 0068 /// 0069 /// \param[in] lhs 0070 /// The Left Hand Side const Declaration object reference. 0071 /// 0072 /// \param[in] rhs 0073 /// The Right Hand Side const Declaration object reference. 0074 /// 0075 /// \return 0076 /// -1 if lhs < rhs 0077 /// 0 if lhs == rhs 0078 /// 1 if lhs > rhs 0079 static int Compare(const Declaration &lhs, const Declaration &rhs); 0080 0081 /// Checks if this object has the same file and line as another declaration 0082 /// object. 0083 /// 0084 /// \param[in] declaration 0085 /// The const Declaration object to compare with. 0086 /// 0087 /// \param[in] full 0088 /// Same meaning as Full in FileSpec::Equal. True means an empty 0089 /// directory is not equal to a specified one, false means it is equal. 0090 /// 0091 /// \return 0092 /// Returns \b true if \b declaration is at the same file and 0093 /// line, \b false otherwise. 0094 bool FileAndLineEqual(const Declaration &declaration, bool full) const; 0095 0096 /// Dump a description of this object to a Stream. 0097 /// 0098 /// Dump a description of the contents of this object to the supplied stream 0099 /// \a s. 0100 /// 0101 /// \param[in] s 0102 /// The stream to which to dump the object description. 0103 void Dump(Stream *s, bool show_fullpaths) const; 0104 0105 bool DumpStopContext(Stream *s, bool show_fullpaths) const; 0106 0107 /// Get accessor for file specification. 0108 /// 0109 /// \return 0110 /// A reference to the file specification object. 0111 FileSpec &GetFile() { return m_file; } 0112 0113 /// Get const accessor for file specification. 0114 /// 0115 /// \return 0116 /// A const reference to the file specification object. 0117 const FileSpec &GetFile() const { return m_file; } 0118 0119 /// Get accessor for the declaration line number. 0120 /// 0121 /// \return 0122 /// Non-zero indicates a valid line number, zero indicates no 0123 /// line information is available. 0124 uint32_t GetLine() const { return m_line; } 0125 0126 /// Get accessor for the declaration column number. 0127 /// 0128 /// \return 0129 /// Non-zero indicates a valid column number, zero indicates no 0130 /// column information is available. 0131 uint16_t GetColumn() const { return m_column; } 0132 0133 /// Convert to boolean operator. 0134 /// 0135 /// This allows code to check a Declaration object to see if it 0136 /// contains anything valid using code such as: 0137 /// 0138 /// \code 0139 /// Declaration decl(...); 0140 /// if (decl) 0141 /// { ... 0142 /// \endcode 0143 /// 0144 /// \return 0145 /// A \b true if both the file_spec and the line are valid, 0146 /// \b false otherwise. 0147 explicit operator bool() const { return IsValid(); } 0148 0149 bool IsValid() const { 0150 return m_file && m_line != 0 && m_line != LLDB_INVALID_LINE_NUMBER; 0151 } 0152 0153 /// Get the memory cost of this object. 0154 /// 0155 /// \return 0156 /// The number of bytes that this object occupies in memory. 0157 /// The returned value does not include the bytes for any 0158 /// shared string values. 0159 size_t MemorySize() const; 0160 0161 /// Set accessor for the declaration file specification. 0162 /// 0163 /// \param[in] file_spec 0164 /// The new declaration file specification. 0165 void SetFile(const FileSpec &file_spec) { m_file = file_spec; } 0166 0167 /// Set accessor for the declaration line number. 0168 /// 0169 /// \param[in] line 0170 /// Non-zero indicates a valid line number, zero indicates no 0171 /// line information is available. 0172 void SetLine(uint32_t line) { m_line = line; } 0173 0174 /// Set accessor for the declaration column number. 0175 /// 0176 /// \param[in] column 0177 /// Non-zero indicates a valid column number, zero indicates no 0178 /// column information is available. 0179 void SetColumn(uint16_t column) { m_column = column; } 0180 0181 protected: 0182 /// The file specification that points to the source file where the 0183 /// declaration occurred. 0184 FileSpec m_file; 0185 /// Non-zero values indicates a valid line number, zero indicates no line 0186 /// number information is available. 0187 uint32_t m_line = 0; 0188 /// Non-zero values indicates a valid column number, zero indicates no column 0189 /// information is available. 0190 uint16_t m_column = LLDB_INVALID_COLUMN_NUMBER; 0191 }; 0192 0193 bool operator==(const Declaration &lhs, const Declaration &rhs); 0194 0195 } // namespace lldb_private 0196 0197 #endif // LLDB_SYMBOL_DECLARATION_H
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|