Skip to content

Commit 233ce3c

Browse files
committed
Simplify depth handling
1 parent e1f7076 commit 233ce3c

File tree

2 files changed

+6
-17
lines changed

2 files changed

+6
-17
lines changed

oi/type_graph/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ add_dependencies(type_graph libdrgn)
2424
target_link_libraries(type_graph
2525
container_info
2626
symbol_service
27+
Boost::headers
2728

2829
LLDB
2930
"-L${DRGN_PATH}/.libs"

oi/type_graph/LLDBParser.cpp

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
#include "LLDBParser.h"
1717

18+
#include <boost/scope_exit.hpp>
1819
#include <glog/logging.h>
1920
#include <lldb/API/LLDB.h>
2021

@@ -68,26 +69,13 @@ Type& LLDBParser::parse(lldb::SBType& root) {
6869
return enumerateType(root);
6970
}
7071

71-
struct DepthGuard {
72-
explicit DepthGuard(int& depth) : depth_(depth) {
73-
++depth_;
74-
}
75-
~DepthGuard() {
76-
--depth_;
77-
}
78-
79-
private:
80-
int& depth_;
81-
};
82-
8372
Type& LLDBParser::enumerateType(lldb::SBType& type) {
8473
// Avoid re-enumerating an already-processsed type
8574
if (auto it = lldb_types_.find(type); it != lldb_types_.end())
8675
return it->second;
8776

88-
DepthGuard guard(depth_);
89-
90-
bool isTypeIncomplete = !type.IsTypeComplete();
77+
++depth_;
78+
BOOST_SCOPE_EXIT_ALL(&) { --depth_; };
9179

9280
std::optional<std::reference_wrapper<Type>> t;
9381
try {
@@ -128,11 +116,11 @@ Type& LLDBParser::enumerateType(lldb::SBType& type) {
128116
throw LLDBParserError{"Unhandled type class: " + std::to_string(kind)};
129117
}
130118
} catch (const LLDBParserError& e) {
131-
if (!isTypeIncomplete)
119+
if (type.IsTypeComplete())
132120
throw;
133121
}
134122

135-
if (isTypeIncomplete) {
123+
if (!type.IsTypeComplete()) {
136124
return makeType<Incomplete>(type, *t);
137125
}
138126

0 commit comments

Comments
 (0)