Skip to content

Commit 54b3dc1

Browse files
[lldb][NFC] Fix style issues with StackID.h (#157483)
Some comments were "suffixed" to member variable declarations; these are moved to before the variable. Some constructors and operators were just defaulted and not necessary. Some comments dividing the class into logical sections, like "// constructors and destructors", were not applied everywhere. These were removed. They are used in some parts of LLDB, but are the exception. An include was not needed. The operator != can be defined in terms of ==.
1 parent 659ed24 commit 54b3dc1

File tree

2 files changed

+17
-44
lines changed

2 files changed

+17
-44
lines changed

lldb/include/lldb/Target/StackID.h

Lines changed: 16 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,18 @@
1010
#define LLDB_TARGET_STACKID_H
1111

1212
#include "lldb/Core/AddressRange.h"
13-
#include "lldb/lldb-private.h"
1413

1514
namespace lldb_private {
1615

1716
class Process;
1817

1918
class StackID {
2019
public:
21-
// Constructors and Destructors
2220
StackID() = default;
2321

2422
explicit StackID(lldb::addr_t pc, lldb::addr_t cfa,
2523
SymbolContextScope *symbol_scope, Process *process);
2624

27-
StackID(const StackID &rhs)
28-
: m_pc(rhs.m_pc), m_cfa(rhs.m_cfa), m_symbol_scope(rhs.m_symbol_scope) {}
29-
3025
~StackID() = default;
3126

3227
lldb::addr_t GetPC() const { return m_pc; }
@@ -51,41 +46,28 @@ class StackID {
5146

5247
void Dump(Stream *s);
5348

54-
// Operators
55-
const StackID &operator=(const StackID &rhs) {
56-
if (this != &rhs) {
57-
m_pc = rhs.m_pc;
58-
m_cfa = rhs.m_cfa;
59-
m_symbol_scope = rhs.m_symbol_scope;
60-
}
61-
return *this;
62-
}
63-
6449
protected:
6550
friend class StackFrame;
6651

6752
void SetPC(lldb::addr_t pc, Process *process);
6853
void SetCFA(lldb::addr_t cfa, Process *process);
6954

70-
lldb::addr_t m_pc =
71-
LLDB_INVALID_ADDRESS; // The pc value for the function/symbol for this
72-
// frame. This will
73-
// only get used if the symbol scope is nullptr (the code where we are
74-
// stopped is not represented by any function or symbol in any shared
75-
// library).
76-
lldb::addr_t m_cfa =
77-
LLDB_INVALID_ADDRESS; // The call frame address (stack pointer) value
78-
// at the beginning of the function that uniquely
79-
// identifies this frame (along with m_symbol_scope
80-
// below)
81-
SymbolContextScope *m_symbol_scope =
82-
nullptr; // If nullptr, there is no block or symbol for this frame.
83-
// If not nullptr, this will either be the scope for the
84-
// lexical block for the frame, or the scope for the
85-
// symbol. Symbol context scopes are always be unique
86-
// pointers since the are part of the Block and Symbol
87-
// objects and can easily be used to tell if a stack ID
88-
// is the same as another.
55+
/// The pc value for the function/symbol for this frame. This will only get
56+
/// used if the symbol scope is nullptr (the code where we are stopped is not
57+
/// represented by any function or symbol in any shared library).
58+
lldb::addr_t m_pc = LLDB_INVALID_ADDRESS;
59+
60+
/// The call frame address (stack pointer) value at the beginning of the
61+
/// function that uniquely identifies this frame (along with m_symbol_scope
62+
/// below)
63+
lldb::addr_t m_cfa = LLDB_INVALID_ADDRESS;
64+
65+
/// If nullptr, there is no block or symbol for this frame. If not nullptr,
66+
/// this will either be the scope for the lexical block for the frame, or the
67+
/// scope for the symbol. Symbol context scopes are always be unique pointers
68+
/// since the are part of the Block and Symbol objects and can easily be used
69+
/// to tell if a stack ID is the same as another.
70+
SymbolContextScope *m_symbol_scope = nullptr;
8971
};
9072

9173
bool operator==(const StackID &lhs, const StackID &rhs);

lldb/source/Target/StackID.cpp

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,7 @@ bool lldb_private::operator==(const StackID &lhs, const StackID &rhs) {
6363
}
6464

6565
bool lldb_private::operator!=(const StackID &lhs, const StackID &rhs) {
66-
if (lhs.GetCallFrameAddress() != rhs.GetCallFrameAddress())
67-
return true;
68-
69-
SymbolContextScope *lhs_scope = lhs.GetSymbolContextScope();
70-
SymbolContextScope *rhs_scope = rhs.GetSymbolContextScope();
71-
72-
if (lhs_scope == nullptr && rhs_scope == nullptr)
73-
return lhs.GetPC() != rhs.GetPC();
74-
75-
return lhs_scope != rhs_scope;
66+
return !(lhs == rhs);
7667
}
7768

7869
bool lldb_private::operator<(const StackID &lhs, const StackID &rhs) {

0 commit comments

Comments
 (0)