Skip to content

Commit dcd19a5

Browse files
committed
Formatting
1 parent 07c4afe commit dcd19a5

File tree

3 files changed

+48
-29
lines changed

3 files changed

+48
-29
lines changed

oi/type_graph/LLDBParser.cpp

Lines changed: 36 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
#include <glog/logging.h>
1919
#include <lldb/API/LLDB.h>
20+
2021
#include <cassert>
2122

2223
namespace std {
@@ -29,25 +30,28 @@ namespace std {
2930
* Is there a better way to do this?
3031
*/
3132
size_t hash<lldb::SBType>::operator()(const lldb::SBType& key) const {
32-
auto *name = const_cast<lldb::SBType&>(key).GetName();
33+
auto* name = const_cast<lldb::SBType&>(key).GetName();
3334
auto Hasher = std::hash<const char*>();
3435
{ /* Debugging
35-
auto &keyAsSP = reinterpret_cast<const lldb::TypeImplSP&>(key);
36+
auto& keyAsSP = reinterpret_cast<const lldb::TypeImplSP&>(key);
3637
fprintf(stderr, "LLDBType::hash(key@0x%08zx = (0x%08zx, %s)) = 0x%08zx\n",
3738
(uintptr_t)keyAsSP.get(), (uintptr_t)name, name, Hasher(name));
3839
// Debugging */
3940
}
4041
return Hasher(name);
4142
}
4243

43-
bool equal_to<lldb::SBType>::operator()(const lldb::SBType& lhs, const lldb::SBType& rhs) const {
44+
bool equal_to<lldb::SBType>::operator()(const lldb::SBType& lhs,
45+
const lldb::SBType& rhs) const {
4446
auto* lhsName = const_cast<lldb::SBType&>(lhs).GetName();
4547
auto* rhsName = const_cast<lldb::SBType&>(rhs).GetName();
4648
auto EqualTo = std::equal_to<const char*>();
4749
{ /* Debugging
48-
auto &lhsAsSP = reinterpret_cast<const lldb::TypeImplSP&>(lhs);
49-
auto &rhsAsSP = reinterpret_cast<const lldb::TypeImplSP&>(rhs);
50-
fprintf(stderr, "LLDBType::equal_to(lhs@0x%08zx = (0x%08zx, %s), rhs@0x%08zx = (0x%08zx, %s)) = %d\n",
50+
auto& lhsAsSP = reinterpret_cast<const lldb::TypeImplSP&>(lhs);
51+
auto& rhsAsSP = reinterpret_cast<const lldb::TypeImplSP&>(rhs);
52+
fprintf(stderr, "LLDBType::equal_to("
53+
"lhs@0x%08zx = (0x%08zx, %s), "
54+
"rhs@0x%08zx = (0x%08zx, %s)) = %d\n",
5155
(uintptr_t)lhsAsSP.get(), (uintptr_t)lhsName, lhsName,
5256
(uintptr_t)rhsAsSP.get(), (uintptr_t)rhsName, rhsName,
5357
EqualTo(lhsName, rhsName));
@@ -71,6 +75,7 @@ struct DepthGuard {
7175
~DepthGuard() {
7276
--depth_;
7377
}
78+
7479
private:
7580
int& depth_;
7681
};
@@ -152,10 +157,11 @@ Class& LLDBParser::enumerateClass(lldb::SBType& type) {
152157
kind = Class::Kind::Union;
153158
break;
154159
default:
155-
throw LLDBParserError{"Invalid type class for compound type: " + std::to_string(typeClass)};
160+
throw LLDBParserError{"Invalid type class for compound type: " +
161+
std::to_string(typeClass)};
156162
}
157163

158-
auto &c = makeType<Class>(type, kind, displayName, name, size, virtuality);
164+
auto& c = makeType<Class>(type, kind, displayName, name, size, virtuality);
159165

160166
enumerateClassTemplateParams(type, c.templateParams);
161167
enumerateClassParents(type, c.parents);
@@ -165,7 +171,8 @@ Class& LLDBParser::enumerateClass(lldb::SBType& type) {
165171
return c;
166172
}
167173

168-
void LLDBParser::enumerateClassTemplateParams(lldb::SBType &type, std::vector<TemplateParam>& params) {
174+
void LLDBParser::enumerateClassTemplateParams(
175+
lldb::SBType& type, std::vector<TemplateParam>& params) {
169176
assert(params.empty());
170177
params.reserve(type.GetNumberOfTemplateArguments());
171178

@@ -180,13 +187,15 @@ void LLDBParser::enumerateTemplateParam(lldb::SBType& /*type*/,
180187
uint32_t /*i*/,
181188
std::vector<TemplateParam>& params) {
182189
QualifierSet qualifiers;
183-
qualifiers[Qualifier::Const] = param.GetName() != param.GetUnqualifiedType().GetName(); // TODO: Wonky as hell :/
190+
qualifiers[Qualifier::Const] = // TODO: Wonky as hell :/
191+
param.GetName() != param.GetUnqualifiedType().GetName();
184192
auto& paramType = enumerateType(param);
185193

186194
params.emplace_back(paramType, qualifiers);
187195
}
188196

189-
void LLDBParser::enumerateClassParents(lldb::SBType& type, std::vector<Parent>& parents) {
197+
void LLDBParser::enumerateClassParents(lldb::SBType& type,
198+
std::vector<Parent>& parents) {
190199
assert(parents.empty());
191200
parents.reserve(type.GetNumberOfDirectBaseClasses());
192201

@@ -198,15 +207,16 @@ void LLDBParser::enumerateClassParents(lldb::SBType& type, std::vector<Parent>&
198207
}
199208
}
200209

201-
void LLDBParser::enumerateClassMembers(lldb::SBType& type, std::vector<Member>& members) {
210+
void LLDBParser::enumerateClassMembers(lldb::SBType& type,
211+
std::vector<Member>& members) {
202212
assert(members.empty());
203213
members.reserve(type.GetNumberOfFields());
204214

205215
/* TODO: We are missing the _vptr */
206216
for (uint32_t i = 0; i < type.GetNumberOfFields(); i++) {
207217
auto field = type.GetFieldAtIndex(i);
208218
if (field.GetName() == nullptr)
209-
continue; // Skip anonymous fields (TODO: Why?)
219+
continue; // Skip anonymous fields (TODO: Why?)
210220
auto fieldName = field.GetName();
211221
auto fieldType = field.GetType();
212222
auto bitFieldSize = field.GetBitfieldSizeInBits();
@@ -221,7 +231,8 @@ void LLDBParser::enumerateClassMembers(lldb::SBType& type, std::vector<Member>&
221231
});
222232
}
223233

224-
void LLDBParser::enumerateClassFunctions(lldb::SBType &type, std::vector<Function>& functions) {
234+
void LLDBParser::enumerateClassFunctions(lldb::SBType& type,
235+
std::vector<Function>& functions) {
225236
assert(functions.empty());
226237
functions.reserve(type.GetNumberOfMemberFunctions());
227238

@@ -235,7 +246,7 @@ void LLDBParser::enumerateClassFunctions(lldb::SBType &type, std::vector<Functio
235246
}
236247

237248
Enum& LLDBParser::enumerateEnum(lldb::SBType& type) {
238-
const char *typeName = type.GetName();
249+
const char* typeName = type.GetName();
239250
std::string name = typeName ? typeName : "";
240251
uint64_t size = type.GetByteSize();
241252

@@ -260,9 +271,9 @@ Typedef& LLDBParser::enumerateTypedef(lldb::SBType& type) {
260271
}
261272

262273
Type& LLDBParser::enumeratePointer(lldb::SBType& type) {
263-
if (!chasePointer()) {
264-
return makeType<Primitive>(type, Primitive::Kind::StubbedPointer);
265-
}
274+
if (!chasePointer()) {
275+
return makeType<Primitive>(type, Primitive::Kind::StubbedPointer);
276+
}
266277

267278
lldb::SBType pointeeType;
268279
switch (auto kind = type.GetTypeClass()) {
@@ -273,11 +284,12 @@ Type& LLDBParser::enumeratePointer(lldb::SBType& type) {
273284
pointeeType = type.GetDereferencedType();
274285
break;
275286
default:
276-
throw LLDBParserError{"Invalid type class for pointer type: " + std::to_string(kind)};
287+
throw LLDBParserError{"Invalid type class for pointer type: " +
288+
std::to_string(kind)};
277289
}
278290

279291
if (pointeeType.IsFunctionType()) {
280-
return makeType<Primitive>(type, Primitive::Kind::StubbedPointer);
292+
return makeType<Primitive>(type, Primitive::Kind::StubbedPointer);
281293
}
282294

283295
Type& t = enumerateType(pointeeType);
@@ -291,7 +303,8 @@ bool LLDBParser::chasePointer() const {
291303
return options_.chaseRawPointers;
292304
}
293305

294-
Primitive::Kind LLDBParser::primitiveIntKind(lldb::SBType& type, bool is_signed) {
306+
Primitive::Kind LLDBParser::primitiveIntKind(lldb::SBType& type,
307+
bool is_signed) {
295308
switch (auto size = type.GetByteSize()) {
296309
case 1:
297310
return is_signed ? Primitive::Kind::Int8 : Primitive::Kind::UInt8;
@@ -376,7 +389,8 @@ Primitive& LLDBParser::enumeratePrimitive(lldb::SBType& type) {
376389
case lldb::eBasicTypeObjCSel:
377390
case lldb::eBasicTypeOther:
378391
default:
379-
throw LLDBParserError{"Unhandled primitive type: " + std::to_string(kind)};
392+
throw LLDBParserError{"Unhandled primitive type: " +
393+
std::to_string(kind)};
380394
}
381395

382396
return makeType<Primitive>(type, primitiveKind);

oi/type_graph/LLDBParser.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
*/
1616
#pragma once
1717

18+
#include <lldb/API/SBType.h>
19+
1820
#include "TypeGraph.h"
1921
#include "Types.h"
2022

21-
#include <lldb/API/SBType.h>
22-
2323
namespace std {
2424
/* lldb::SBType doesn't provide a hash and equality operators.
2525
* So we define our own specialization of them here.
@@ -61,11 +61,16 @@ class LLDBParser {
6161
Primitive::Kind primitiveIntKind(lldb::SBType& type, bool is_signed);
6262
Primitive::Kind primitiveFloatKind(lldb::SBType& type);
6363

64-
void enumerateClassTemplateParams(lldb::SBType &type, std::vector<TemplateParam>& params);
65-
void enumerateTemplateParam(lldb::SBType& type, lldb::SBType& param, uint32_t i, std::vector<TemplateParam>& params);
64+
void enumerateClassTemplateParams(lldb::SBType& type,
65+
std::vector<TemplateParam>& params);
66+
void enumerateTemplateParam(lldb::SBType& type,
67+
lldb::SBType& param,
68+
uint32_t i,
69+
std::vector<TemplateParam>& params);
6670
void enumerateClassParents(lldb::SBType& type, std::vector<Parent>& parents);
6771
void enumerateClassMembers(lldb::SBType& type, std::vector<Member>& members);
68-
void enumerateClassFunctions(lldb::SBType &type, std::vector<Function>& functions);
72+
void enumerateClassFunctions(lldb::SBType& type,
73+
std::vector<Function>& functions);
6974

7075
bool chasePointer() const;
7176

test/test_lldb_parser.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ void LLDBParserTest::test(std::string_view function,
8383
std::string_view expected) {
8484
// Enable options in unit tests so we get more coverage
8585
LLDBParserOptions options = {
86-
.chaseRawPointers = true,
87-
.readEnumValues = true,
86+
.chaseRawPointers = true,
87+
.readEnumValues = true,
8888
};
8989
test(function, expected, options);
9090
}

0 commit comments

Comments
 (0)