Skip to content

Commit 173d1e9

Browse files
committed
Formatting
1 parent 07c4afe commit 173d1e9

File tree

3 files changed

+47
-29
lines changed

3 files changed

+47
-29
lines changed

oi/type_graph/LLDBParser.cpp

Lines changed: 35 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));
@@ -152,10 +156,11 @@ Class& LLDBParser::enumerateClass(lldb::SBType& type) {
152156
kind = Class::Kind::Union;
153157
break;
154158
default:
155-
throw LLDBParserError{"Invalid type class for compound type: " + std::to_string(typeClass)};
159+
throw LLDBParserError{"Invalid type class for compound type: " +
160+
std::to_string(typeClass)};
156161
}
157162

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

160165
enumerateClassTemplateParams(type, c.templateParams);
161166
enumerateClassParents(type, c.parents);
@@ -165,7 +170,8 @@ Class& LLDBParser::enumerateClass(lldb::SBType& type) {
165170
return c;
166171
}
167172

168-
void LLDBParser::enumerateClassTemplateParams(lldb::SBType &type, std::vector<TemplateParam>& params) {
173+
void LLDBParser::enumerateClassTemplateParams(
174+
lldb::SBType& type, std::vector<TemplateParam>& params) {
169175
assert(params.empty());
170176
params.reserve(type.GetNumberOfTemplateArguments());
171177

@@ -180,13 +186,15 @@ void LLDBParser::enumerateTemplateParam(lldb::SBType& /*type*/,
180186
uint32_t /*i*/,
181187
std::vector<TemplateParam>& params) {
182188
QualifierSet qualifiers;
183-
qualifiers[Qualifier::Const] = param.GetName() != param.GetUnqualifiedType().GetName(); // TODO: Wonky as hell :/
189+
qualifiers[Qualifier::Const] = // TODO: Wonky as hell :/
190+
param.GetName() != param.GetUnqualifiedType().GetName();
184191
auto& paramType = enumerateType(param);
185192

186193
params.emplace_back(paramType, qualifiers);
187194
}
188195

189-
void LLDBParser::enumerateClassParents(lldb::SBType& type, std::vector<Parent>& parents) {
196+
void LLDBParser::enumerateClassParents(lldb::SBType& type,
197+
std::vector<Parent>& parents) {
190198
assert(parents.empty());
191199
parents.reserve(type.GetNumberOfDirectBaseClasses());
192200

@@ -198,15 +206,16 @@ void LLDBParser::enumerateClassParents(lldb::SBType& type, std::vector<Parent>&
198206
}
199207
}
200208

201-
void LLDBParser::enumerateClassMembers(lldb::SBType& type, std::vector<Member>& members) {
209+
void LLDBParser::enumerateClassMembers(lldb::SBType& type,
210+
std::vector<Member>& members) {
202211
assert(members.empty());
203212
members.reserve(type.GetNumberOfFields());
204213

205214
/* TODO: We are missing the _vptr */
206215
for (uint32_t i = 0; i < type.GetNumberOfFields(); i++) {
207216
auto field = type.GetFieldAtIndex(i);
208217
if (field.GetName() == nullptr)
209-
continue; // Skip anonymous fields (TODO: Why?)
218+
continue; // Skip anonymous fields (TODO: Why?)
210219
auto fieldName = field.GetName();
211220
auto fieldType = field.GetType();
212221
auto bitFieldSize = field.GetBitfieldSizeInBits();
@@ -221,7 +230,8 @@ void LLDBParser::enumerateClassMembers(lldb::SBType& type, std::vector<Member>&
221230
});
222231
}
223232

224-
void LLDBParser::enumerateClassFunctions(lldb::SBType &type, std::vector<Function>& functions) {
233+
void LLDBParser::enumerateClassFunctions(lldb::SBType& type,
234+
std::vector<Function>& functions) {
225235
assert(functions.empty());
226236
functions.reserve(type.GetNumberOfMemberFunctions());
227237

@@ -235,7 +245,7 @@ void LLDBParser::enumerateClassFunctions(lldb::SBType &type, std::vector<Functio
235245
}
236246

237247
Enum& LLDBParser::enumerateEnum(lldb::SBType& type) {
238-
const char *typeName = type.GetName();
248+
const char* typeName = type.GetName();
239249
std::string name = typeName ? typeName : "";
240250
uint64_t size = type.GetByteSize();
241251

@@ -260,9 +270,9 @@ Typedef& LLDBParser::enumerateTypedef(lldb::SBType& type) {
260270
}
261271

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

267277
lldb::SBType pointeeType;
268278
switch (auto kind = type.GetTypeClass()) {
@@ -273,11 +283,12 @@ Type& LLDBParser::enumeratePointer(lldb::SBType& type) {
273283
pointeeType = type.GetDereferencedType();
274284
break;
275285
default:
276-
throw LLDBParserError{"Invalid type class for pointer type: " + std::to_string(kind)};
286+
throw LLDBParserError{"Invalid type class for pointer type: " +
287+
std::to_string(kind)};
277288
}
278289

279290
if (pointeeType.IsFunctionType()) {
280-
return makeType<Primitive>(type, Primitive::Kind::StubbedPointer);
291+
return makeType<Primitive>(type, Primitive::Kind::StubbedPointer);
281292
}
282293

283294
Type& t = enumerateType(pointeeType);
@@ -291,7 +302,8 @@ bool LLDBParser::chasePointer() const {
291302
return options_.chaseRawPointers;
292303
}
293304

294-
Primitive::Kind LLDBParser::primitiveIntKind(lldb::SBType& type, bool is_signed) {
305+
Primitive::Kind LLDBParser::primitiveIntKind(lldb::SBType& type,
306+
bool is_signed) {
295307
switch (auto size = type.GetByteSize()) {
296308
case 1:
297309
return is_signed ? Primitive::Kind::Int8 : Primitive::Kind::UInt8;
@@ -376,7 +388,8 @@ Primitive& LLDBParser::enumeratePrimitive(lldb::SBType& type) {
376388
case lldb::eBasicTypeObjCSel:
377389
case lldb::eBasicTypeOther:
378390
default:
379-
throw LLDBParserError{"Unhandled primitive type: " + std::to_string(kind)};
391+
throw LLDBParserError{"Unhandled primitive type: " +
392+
std::to_string(kind)};
380393
}
381394

382395
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)