Skip to content

Commit 78b6f48

Browse files
[lldb][NFC] Fix style issues with StackID.h (llvm#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 ==. (cherry picked from commit 54b3dc1) (cherry picked from commit 8cc7914)
1 parent 76c2941 commit 78b6f48

File tree

2 files changed

+22
-46
lines changed

2 files changed

+22
-46
lines changed

lldb/include/lldb/Target/StackID.h

Lines changed: 21 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +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) = default;
28-
2925
~StackID() = default;
3026

3127
lldb::addr_t GetPC() const { return m_pc; }
@@ -51,17 +47,6 @@ class StackID {
5147

5248
void Dump(Stream *s);
5349

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_cfa_on_stack = rhs.m_cfa_on_stack;
60-
m_symbol_scope = rhs.m_symbol_scope;
61-
}
62-
return *this;
63-
}
64-
6550
/// Check if the CFA is on the stack, or elsewhere in the process, such as on
6651
/// the heap.
6752
bool IsCFAOnStack(Process &process) const;
@@ -76,28 +61,28 @@ class StackID {
7661
void SetPC(lldb::addr_t pc, Process *process);
7762
void SetCFA(lldb::addr_t cfa, Process *process);
7863

79-
lldb::addr_t m_pc =
80-
LLDB_INVALID_ADDRESS; // The pc value for the function/symbol for this
81-
// frame. This will
82-
// only get used if the symbol scope is nullptr (the code where we are
83-
// stopped is not represented by any function or symbol in any shared
84-
// library).
85-
lldb::addr_t m_cfa =
86-
LLDB_INVALID_ADDRESS; // The call frame address (stack pointer) value
87-
// at the beginning of the function that uniquely
88-
// identifies this frame (along with m_symbol_scope
89-
// below)
90-
// True if the CFA is an address on the stack, false if it's an address
91-
// elsewhere (ie heap).
64+
/// The pc value for the function/symbol for this frame. This will only get
65+
/// used if the symbol scope is nullptr (the code where we are stopped is not
66+
/// represented by any function or symbol in any shared library).
67+
lldb::addr_t m_pc = LLDB_INVALID_ADDRESS;
68+
69+
/// The call frame address (stack pointer) value at the beginning of the
70+
/// function that uniquely identifies this frame (along with m_symbol_scope
71+
/// below)
72+
lldb::addr_t m_cfa = LLDB_INVALID_ADDRESS;
73+
74+
/// If nullptr, there is no block or symbol for this frame. If not nullptr,
75+
/// this will either be the scope for the lexical block for the frame, or the
76+
/// scope for the symbol. Symbol context scopes are always be unique pointers
77+
/// since the are part of the Block and Symbol objects and can easily be used
78+
/// to tell if a stack ID is the same as another.
79+
SymbolContextScope *m_symbol_scope = nullptr;
80+
81+
// BEGIN SWIFT
82+
/// True if the CFA is an address on the stack, false if it's an address
83+
/// elsewhere (ie heap).
9284
mutable LazyBool m_cfa_on_stack = eLazyBoolCalculate;
93-
SymbolContextScope *m_symbol_scope =
94-
nullptr; // If nullptr, there is no block or symbol for this frame.
95-
// If not nullptr, this will either be the scope for the
96-
// lexical block for the frame, or the scope for the
97-
// symbol. Symbol context scopes are always be unique
98-
// pointers since the are part of the Block and Symbol
99-
// objects and can easily be used to tell if a stack ID
100-
// is the same as another.
85+
// END SWIFT
10186
};
10287

10388
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
@@ -81,16 +81,7 @@ bool lldb_private::operator==(const StackID &lhs, const StackID &rhs) {
8181
}
8282

8383
bool lldb_private::operator!=(const StackID &lhs, const StackID &rhs) {
84-
if (lhs.GetCallFrameAddress() != rhs.GetCallFrameAddress())
85-
return true;
86-
87-
SymbolContextScope *lhs_scope = lhs.GetSymbolContextScope();
88-
SymbolContextScope *rhs_scope = rhs.GetSymbolContextScope();
89-
90-
if (lhs_scope == nullptr && rhs_scope == nullptr)
91-
return lhs.GetPC() != rhs.GetPC();
92-
93-
return lhs_scope != rhs_scope;
84+
return !(lhs == rhs);
9485
}
9586

9687
// BEGIN SWIFT

0 commit comments

Comments
 (0)