llvm-capstone/lldb/source/Core/SourceLocationSpec.cpp
Elliot Goodrich 5551657b31 [lldb] Add missing StringExtras.h includes
In preparation for removing the `#include "llvm/ADT/StringExtras.h"`
from the header to source file of `llvm/Support/Error.h`, first add in
all the missing includes that were previously included transitively
through this header.

This is fixing all files missed in b0abd4893f, 39d8e6e22c, and
a11efd4926.

Differential Revision: https://reviews.llvm.org/D154775
2023-07-09 14:09:21 +01:00

84 lines
2.8 KiB
C++

//===-- SourceLocationSpec.cpp --------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/Core/SourceLocationSpec.h"
#include "lldb/Utility/StreamString.h"
#include "llvm/ADT/StringExtras.h"
#include <optional>
using namespace lldb;
using namespace lldb_private;
SourceLocationSpec::SourceLocationSpec(FileSpec file_spec, uint32_t line,
std::optional<uint16_t> column,
bool check_inlines, bool exact_match)
: m_declaration(file_spec, line,
column.value_or(LLDB_INVALID_COLUMN_NUMBER)),
m_check_inlines(check_inlines), m_exact_match(exact_match) {}
SourceLocationSpec::operator bool() const { return m_declaration.IsValid(); }
bool SourceLocationSpec::operator!() const { return !operator bool(); }
bool SourceLocationSpec::operator==(const SourceLocationSpec &rhs) const {
return m_declaration == rhs.m_declaration &&
m_check_inlines == rhs.GetCheckInlines() &&
m_exact_match == rhs.GetExactMatch();
}
bool SourceLocationSpec::operator!=(const SourceLocationSpec &rhs) const {
return !(*this == rhs);
}
bool SourceLocationSpec::operator<(const SourceLocationSpec &rhs) const {
return SourceLocationSpec::Compare(*this, rhs) < 0;
}
Stream &lldb_private::operator<<(Stream &s, const SourceLocationSpec &loc) {
loc.Dump(s);
return s;
}
int SourceLocationSpec::Compare(const SourceLocationSpec &lhs,
const SourceLocationSpec &rhs) {
return Declaration::Compare(lhs.m_declaration, rhs.m_declaration);
}
bool SourceLocationSpec::Equal(const SourceLocationSpec &lhs,
const SourceLocationSpec &rhs, bool full) {
return full ? lhs == rhs
: (lhs.GetFileSpec() == rhs.GetFileSpec() &&
lhs.GetLine() == rhs.GetLine());
}
void SourceLocationSpec::Dump(Stream &s) const {
s << "check inlines = " << llvm::toStringRef(m_check_inlines);
s << ", exact match = " << llvm::toStringRef(m_exact_match);
m_declaration.Dump(&s, true);
}
std::string SourceLocationSpec::GetString() const {
StreamString ss;
Dump(ss);
return ss.GetString().str();
}
std::optional<uint32_t> SourceLocationSpec::GetLine() const {
uint32_t line = m_declaration.GetLine();
if (line == 0 || line == LLDB_INVALID_LINE_NUMBER)
return std::nullopt;
return line;
}
std::optional<uint16_t> SourceLocationSpec::GetColumn() const {
uint16_t column = m_declaration.GetColumn();
if (column == LLDB_INVALID_COLUMN_NUMBER)
return std::nullopt;
return column;
}