|
|
|||
File indexing completed on 2026-05-10 08:42:46
0001 //===-- SourceLocationSpec.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_UTILITY_SOURCELOCATIONSPEC_H 0010 #define LLDB_UTILITY_SOURCELOCATIONSPEC_H 0011 0012 #include "lldb/Core/Declaration.h" 0013 #include "lldb/lldb-defines.h" 0014 0015 #include <optional> 0016 #include <string> 0017 0018 namespace lldb_private { 0019 0020 /// \class SourceLocationSpec SourceLocationSpec.h 0021 /// "lldb/Core/SourceLocationSpec.h" A source location specifier class. 0022 /// 0023 /// A source location specifier class that holds a Declaration object containing 0024 /// a FileSpec with line and column information. The column line is optional. 0025 /// It also holds search flags that can be fetched by resolvers to look inlined 0026 /// declarations and/or exact matches. 0027 class SourceLocationSpec { 0028 public: 0029 /// Constructor. 0030 /// 0031 /// Takes a \a file_spec with a \a line number and a \a column number. If 0032 /// \a column is null or not provided, it is set to std::nullopt. 0033 /// 0034 /// \param[in] file_spec 0035 /// The full or partial path to a file. 0036 /// 0037 /// \param[in] line 0038 /// The line number in the source file. 0039 /// 0040 /// \param[in] column 0041 /// The column number in the line of the source file. 0042 /// 0043 /// \param[in] check_inlines 0044 /// Whether to look for a match in inlined declaration. 0045 /// 0046 /// \param[in] exact_match 0047 /// Whether to look for an exact match. 0048 /// 0049 explicit SourceLocationSpec(FileSpec file_spec, uint32_t line, 0050 std::optional<uint16_t> column = std::nullopt, 0051 bool check_inlines = false, 0052 bool exact_match = false); 0053 0054 SourceLocationSpec() = delete; 0055 0056 /// Convert to boolean operator. 0057 /// 0058 /// This allows code to check a SourceLocationSpec object to see if it 0059 /// contains anything valid using code such as: 0060 /// 0061 /// \code 0062 /// SourceLocationSpec location_spec(...); 0063 /// if (location_spec) 0064 /// { ... 0065 /// \endcode 0066 /// 0067 /// \return 0068 /// A pointer to this object if both the file_spec and the line are valid, 0069 /// nullptr otherwise. 0070 explicit operator bool() const; 0071 0072 /// Logical NOT operator. 0073 /// 0074 /// This allows code to check a SourceLocationSpec object to see if it is 0075 /// invalid using code such as: 0076 /// 0077 /// \code 0078 /// SourceLocationSpec location_spec(...); 0079 /// if (!location_spec) 0080 /// { ... 0081 /// \endcode 0082 /// 0083 /// \return 0084 /// Returns \b true if the object has an invalid file_spec or line number, 0085 /// \b false otherwise. 0086 bool operator!() const; 0087 0088 /// Equal to operator 0089 /// 0090 /// Tests if this object is equal to \a rhs. 0091 /// 0092 /// \param[in] rhs 0093 /// A const SourceLocationSpec object reference to compare this object 0094 /// to. 0095 /// 0096 /// \return 0097 /// \b true if this object is equal to \a rhs, \b false 0098 /// otherwise. 0099 bool operator==(const SourceLocationSpec &rhs) const; 0100 0101 /// Not equal to operator 0102 /// 0103 /// Tests if this object is not equal to \a rhs. 0104 /// 0105 /// \param[in] rhs 0106 /// A const SourceLocationSpec object reference to compare this object 0107 /// to. 0108 /// 0109 /// \return 0110 /// \b true if this object is equal to \a rhs, \b false 0111 /// otherwise. 0112 bool operator!=(const SourceLocationSpec &rhs) const; 0113 0114 /// Less than to operator 0115 /// 0116 /// Tests if this object is less than \a rhs. 0117 /// 0118 /// \param[in] rhs 0119 /// A const SourceLocationSpec object reference to compare this object 0120 /// to. 0121 /// 0122 /// \return 0123 /// \b true if this object is less than \a rhs, \b false 0124 /// otherwise. 0125 bool operator<(const SourceLocationSpec &rhs) const; 0126 0127 /// Compare two SourceLocationSpec objects. 0128 /// 0129 /// If \a full is true, then the file_spec, the line and column must match. 0130 /// If \a full is false, then only the file_spec and line number for \a lhs 0131 /// and \a rhs are compared. This allows a SourceLocationSpec object that have 0132 /// no column information to match a SourceLocationSpec objects that have 0133 /// column information with matching file_spec and line component. 0134 /// 0135 /// \param[in] lhs 0136 /// A const reference to the Left Hand Side object to compare. 0137 /// 0138 /// \param[in] rhs 0139 /// A const reference to the Right Hand Side object to compare. 0140 /// 0141 /// \param[in] full 0142 /// If true, then the file_spec, the line and column must match for a 0143 /// compare to return zero (equal to). If false, then only the file_spec 0144 /// and line number for \a lhs and \a rhs are compared, else a full 0145 /// comparison is done. 0146 /// 0147 /// \return -1 if \a lhs is less than \a rhs, 0 if \a lhs is equal to \a rhs, 0148 /// 1 if \a lhs is greater than \a rhs 0149 static int Compare(const SourceLocationSpec &lhs, 0150 const SourceLocationSpec &rhs); 0151 0152 static bool Equal(const SourceLocationSpec &lhs, 0153 const SourceLocationSpec &rhs, bool full); 0154 0155 /// Dump this object to a Stream. 0156 /// 0157 /// Dump the object to the supplied stream \a s, starting with the file name, 0158 /// then the line number and if available the column number. 0159 /// 0160 /// \param[in] s 0161 /// The stream to which to dump the object description. 0162 void Dump(Stream &s) const; 0163 0164 std::string GetString() const; 0165 0166 FileSpec GetFileSpec() const { return m_declaration.GetFile(); } 0167 0168 std::optional<uint32_t> GetLine() const; 0169 0170 std::optional<uint16_t> GetColumn() const; 0171 0172 bool GetCheckInlines() const { return m_check_inlines; } 0173 0174 bool GetExactMatch() const { return m_exact_match; } 0175 0176 protected: 0177 Declaration m_declaration; 0178 /// Tells if the resolver should look in inlined declaration. 0179 bool m_check_inlines; 0180 /// Tells if the resolver should look for an exact match. 0181 bool m_exact_match; 0182 }; 0183 0184 /// Dump a SourceLocationSpec object to a stream 0185 Stream &operator<<(Stream &s, const SourceLocationSpec &loc); 0186 } // namespace lldb_private 0187 0188 #endif // LLDB_UTILITY_SOURCELOCATIONSPEC_H
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|