1 //===-- Declaration.h -------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_Declaration_h_
11 #define liblldb_Declaration_h_
13 #include "lldb/lldb-private.h"
14 #include "lldb/Host/FileSpec.h"
16 namespace lldb_private {
18 //----------------------------------------------------------------------
19 /// @class Declaration Declaration.h "lldb/Symbol/Declaration.h"
20 /// @brief A class that describes the declaration location of a
23 /// The declarations include the file specification, line number, and
24 /// the column info and can help track where functions, blocks, inlined
25 /// functions, types, variables, any many other debug core objects were
27 //----------------------------------------------------------------------
31 //------------------------------------------------------------------
32 /// Default constructor.
33 //------------------------------------------------------------------
37 #ifdef LLDB_ENABLE_DECLARATION_COLUMNS
44 //------------------------------------------------------------------
45 /// Construct with file specification, and optional line and column.
47 /// @param[in] file_spec
48 /// The file specification that describes where this was
52 /// The line number that describes where this was declared. Set
53 /// to zero if there is no line number information.
56 /// The column number that describes where this was declared.
57 /// Set to zero if there is no column number information.
58 //------------------------------------------------------------------
59 Declaration (const FileSpec& file_spec, uint32_t line = 0, uint32_t column = 0) :
62 #ifdef LLDB_ENABLE_DECLARATION_COLUMNS
68 //------------------------------------------------------------------
69 /// Construct with a reference to another Declaration object.
70 //------------------------------------------------------------------
71 Declaration (const Declaration& rhs) :
74 #ifdef LLDB_ENABLE_DECLARATION_COLUMNS
75 ,m_column (rhs.m_column)
81 //------------------------------------------------------------------
82 /// Construct with a pointer to another Declaration object.
83 //------------------------------------------------------------------
84 Declaration(const Declaration* decl_ptr) :
87 #ifdef LLDB_ENABLE_DECLARATION_COLUMNS
95 //------------------------------------------------------------------
96 /// Clear the object's state.
98 /// Sets the file specification to be empty, and the line and column
100 //------------------------------------------------------------------
106 #ifdef LLDB_ENABLE_DECLARATION_COLUMNS
111 //------------------------------------------------------------------
112 /// Compare two declaration objects.
114 /// Compares the two file specifications from \a lhs and \a rhs. If
115 /// the file specifications are equal, then continue to compare the
116 /// line number and column numbers respectively.
119 /// The Left Hand Side const Declaration object reference.
122 /// The Right Hand Side const Declaration object reference.
125 /// @li -1 if lhs < rhs
126 /// @li 0 if lhs == rhs
127 /// @li 1 if lhs > rhs
128 //------------------------------------------------------------------
130 Compare (const Declaration& lhs, const Declaration& rhs);
132 //------------------------------------------------------------------
133 /// Dump a description of this object to a Stream.
135 /// Dump a description of the contents of this object to the
136 /// supplied stream \a s.
139 /// The stream to which to dump the object descripton.
140 //------------------------------------------------------------------
142 Dump (Stream *s, bool show_fullpaths) const;
145 DumpStopContext (Stream *s, bool show_fullpaths) const;
146 //------------------------------------------------------------------
147 /// Get accessor for the declaration column number.
150 /// Non-zero indicates a valid column number, zero indicates no
151 /// column information is available.
152 //------------------------------------------------------------------
156 #ifdef LLDB_ENABLE_DECLARATION_COLUMNS
163 //------------------------------------------------------------------
164 /// Get accessor for file specification.
167 /// A reference to the file specification object.
168 //------------------------------------------------------------------
175 //------------------------------------------------------------------
176 /// Get const accessor for file specification.
179 /// A const reference to the file specification object.
180 //------------------------------------------------------------------
187 //------------------------------------------------------------------
188 /// Get accessor for the declaration line number.
191 /// Non-zero indicates a valid line number, zero indicates no
192 /// line information is available.
193 //------------------------------------------------------------------
204 return m_file && m_line != 0;
207 //------------------------------------------------------------------
208 /// Get the memory cost of this object.
211 /// The number of bytes that this object occupies in memory.
212 /// The returned value does not include the bytes for any
213 /// shared string values.
215 /// @see ConstString::StaticMemorySize ()
216 //------------------------------------------------------------------
220 //------------------------------------------------------------------
221 /// Set accessor for the declaration column number.
223 /// @param[in] column
224 /// Non-zero indicates a valid column number, zero indicates no
225 /// column information is available.
226 //------------------------------------------------------------------
228 SetColumn (uint32_t column)
230 #ifdef LLDB_ENABLE_DECLARATION_COLUMNS
235 //------------------------------------------------------------------
236 /// Set accessor for the declaration file specification.
238 /// @param[in] file_spec
239 /// The new declaration file specifciation.
240 //------------------------------------------------------------------
242 SetFile (const FileSpec& file_spec)
247 //------------------------------------------------------------------
248 /// Set accessor for the declaration line number.
251 /// Non-zero indicates a valid line number, zero indicates no
252 /// line information is available.
253 //------------------------------------------------------------------
255 SetLine (uint32_t line)
260 //------------------------------------------------------------------
261 /// Member variables.
262 //------------------------------------------------------------------
263 FileSpec m_file; ///< The file specification that points to the
264 ///< source file where the declaration occurred.
265 uint32_t m_line; ///< Non-zero values indicates a valid line number,
266 ///< zero indicates no line number information is available.
267 #ifdef LLDB_ENABLE_DECLARATION_COLUMNS
268 uint32_t m_column; ///< Non-zero values indicates a valid column number,
269 ///< zero indicates no column information is available.
274 operator == (const Declaration &lhs, const Declaration &rhs);
276 } // namespace lldb_private
278 #endif // liblldb_Declaration_h_