Skip to content

Commit 4a64fc5

Browse files
committed
clang-format: set BinPackParameters=false
1 parent 789fb7e commit 4a64fc5

26 files changed

+241
-113
lines changed

.clang-format

+1
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ AllowShortIfStatementsOnASingleLine: false
88
AllowShortLoopsOnASingleLine: false
99
DerivePointerAlignment: false
1010
PointerAlignment: Left
11+
BinPackParameters: false

examples/oil-metrics/Metrics.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ void Metrics::save(std::string object) {
5454
}
5555
}
5656

57-
void Metrics::saveArg(const char* name, const char* argName, ArgTiming timing,
57+
void Metrics::saveArg(const char* name,
58+
const char* argName,
59+
ArgTiming timing,
5860
size_t size) {
5961
std::string out = "{\"type\": \"size\", \"traceName\": \"";
6062
out += name;

examples/oil-metrics/Metrics.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ class Metrics {
5858
}
5959

6060
static void save(std::string object);
61-
static void saveArg(const char* name, const char* argName, ArgTiming timing,
61+
static void saveArg(const char* name,
62+
const char* argName,
63+
ArgTiming timing,
6264
size_t size);
6365
static void saveDuration(const char* name,
6466
std::chrono::milliseconds duration);

include/ObjectIntrospection.h

+9-4
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,10 @@ class CodegenHandler {
145145
return lib->getObjectSize((void*)&objectAddr, objectSize);
146146
}
147147

148-
static int getObjectSize(const T& objectAddr, size_t& objectSize,
149-
const options& opts, bool checkOptions = true) {
148+
static int getObjectSize(const T& objectAddr,
149+
size_t& objectSize,
150+
const options& opts,
151+
bool checkOptions = true) {
150152
OILibrary* lib;
151153
if (int responseCode = getLibrary(lib, opts, checkOptions);
152154
responseCode != Response::OIL_SUCCESS) {
@@ -180,7 +182,8 @@ class CodegenHandler {
180182
return Response::OIL_SUCCESS;
181183
}
182184

183-
static int getLibrary(OILibrary*& result, const options& opts,
185+
static int getLibrary(OILibrary*& result,
186+
const options& opts,
184187
bool checkOptions) {
185188
std::atomic<OILibrary*>* curBoxedLib = getBoxedLib()->load();
186189

@@ -224,7 +227,9 @@ class CodegenHandler {
224227
* Ahead-Of-Time (AOT) compilation.
225228
*/
226229
template <class T>
227-
int getObjectSize(const T& objectAddr, size_t& objectSize, const options& opts,
230+
int getObjectSize(const T& objectAddr,
231+
size_t& objectSize,
232+
const options& opts,
228233
bool checkOptions = true) {
229234
return CodegenHandler<T>::getObjectSize(objectAddr, objectSize, opts,
230235
checkOptions);

src/ContainerInfo.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,11 @@ struct ContainerInfo {
3636
ContainerInfo& operator=(const ContainerInfo& other) = delete;
3737

3838
ContainerInfo() = default;
39-
ContainerInfo(std::string typeName_, std::regex matcher_,
39+
ContainerInfo(std::string typeName_,
40+
std::regex matcher_,
4041
std::optional<size_t> numTemplateParams_,
41-
ContainerTypeEnum ctype_, std::string header_,
42+
ContainerTypeEnum ctype_,
43+
std::string header_,
4244
std::vector<std::string> ns_,
4345
std::vector<size_t> replaceTemplateParamIndex_,
4446
std::optional<size_t> allocatorIndex_,

src/DrgnUtils.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ const char* symbol::name(drgn_symbol* sym) {
9898

9999
namespace drgn_utils {
100100

101-
void getDrgnArrayElementType(drgn_type* type, drgn_type** outElemType,
101+
void getDrgnArrayElementType(drgn_type* type,
102+
drgn_type** outElemType,
102103
size_t& outNumElems) {
103104
size_t elems = 1;
104105

src/DrgnUtils.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ namespace drgn_utils {
137137
* data can be moved here.
138138
*/
139139

140-
void getDrgnArrayElementType(drgn_type* type, drgn_type** outElemType,
140+
void getDrgnArrayElementType(drgn_type* type,
141+
drgn_type** outElemType,
141142
size_t& outNumElems);
142143
std::string typeToName(drgn_type* type);
143144

src/OICodeGen.cpp

+40-19
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,8 @@ std::string OICodeGen::stripFullyQualifiedNameWithSeparators(
330330
// Replace a specific template parameter with a generic DummySizedOperator
331331
void OICodeGen::replaceTemplateOperator(
332332
TemplateParamList& template_params,
333-
std::vector<std::string>& template_params_strings, size_t index) {
333+
std::vector<std::string>& template_params_strings,
334+
size_t index) {
334335
if (index >= template_params.size()) {
335336
// Should this happen?
336337
return;
@@ -365,7 +366,8 @@ void OICodeGen::replaceTemplateOperator(
365366
}
366367

367368
void OICodeGen::replaceTemplateParameters(
368-
drgn_type* type, TemplateParamList& template_params,
369+
drgn_type* type,
370+
TemplateParamList& template_params,
369371
std::vector<std::string>& template_params_strings,
370372
const std::string& nameWithoutTemplate) {
371373
auto optContainerInfo = getContainerInfo(type);
@@ -393,7 +395,8 @@ void OICodeGen::replaceTemplateParameters(
393395
}
394396
}
395397

396-
bool OICodeGen::buildName(drgn_type* type, std::string& text,
398+
bool OICodeGen::buildName(drgn_type* type,
399+
std::string& text,
397400
std::string& outName) {
398401
int ptrDepth = 0;
399402
drgn_type* ut = type;
@@ -418,7 +421,8 @@ bool OICodeGen::buildName(drgn_type* type, std::string& text,
418421
return true;
419422
}
420423

421-
bool OICodeGen::buildNameInt(drgn_type* type, std::string& nameWithoutTemplate,
424+
bool OICodeGen::buildNameInt(drgn_type* type,
425+
std::string& nameWithoutTemplate,
422426
std::string& outName) {
423427
// Calling buildName only makes sense if a type is a container and has
424428
// template parameters. For a generic template class, we just flatten the
@@ -588,7 +592,8 @@ bool OICodeGen::buildNameInt(drgn_type* type, std::string& nameWithoutTemplate,
588592
}
589593

590594
bool OICodeGen::getTemplateParams(
591-
drgn_type* type, size_t numTemplateParams,
595+
drgn_type* type,
596+
size_t numTemplateParams,
592597
std::vector<std::pair<drgn_qualified_type, std::string>>& v) {
593598
drgn_type_template_parameter* tParams = drgn_type_template_parameters(type);
594599

@@ -1662,8 +1667,10 @@ std::optional<std::string> OICodeGen::getNameForType(drgn_type* type) {
16621667
}
16631668

16641669
void OICodeGen::getFuncDefClassMembers(
1665-
std::string& code, drgn_type* type,
1666-
std::unordered_map<std::string, int>& memberNames, bool skipPadding) {
1670+
std::string& code,
1671+
drgn_type* type,
1672+
std::unordered_map<std::string, int>& memberNames,
1673+
bool skipPadding) {
16671674
if (drgn_type_kind(type) == DRGN_TYPE_TYPEDEF) {
16681675
// Handle case where parent is a typedef
16691676
getFuncDefClassMembers(code, drgnUnderlyingType(type), memberNames);
@@ -1761,7 +1768,8 @@ void OICodeGen::enumerateDescendants(drgn_type* type, drgn_type* baseType) {
17611768
}
17621769
}
17631770

1764-
void OICodeGen::getFuncDefinitionStr(std::string& code, drgn_type* type,
1771+
void OICodeGen::getFuncDefinitionStr(std::string& code,
1772+
drgn_type* type,
17651773
const std::string& typeName) {
17661774
if (classMembersMap.find(type) == classMembersMap.end()) {
17671775
return;
@@ -2380,8 +2388,10 @@ bool OICodeGen::addPadding(uint64_t padding_bits, std::string& code) {
23802388
return true;
23812389
}
23822390

2383-
static inline void addSizeComment(bool genPaddingStats, std::string& code,
2384-
size_t offset, size_t sizeInBits) {
2391+
static inline void addSizeComment(bool genPaddingStats,
2392+
std::string& code,
2393+
size_t offset,
2394+
size_t sizeInBits) {
23852395
if (!genPaddingStats) {
23862396
return;
23872397
}
@@ -2417,8 +2427,10 @@ void OICodeGen::deduplicateMemberName(
24172427

24182428
std::optional<uint64_t> OICodeGen::generateMember(
24192429
const DrgnClassMemberInfo& m,
2420-
std::unordered_map<std::string, int>& memberNames, uint64_t currOffsetBits,
2421-
std::string& code, bool isInUnion) {
2430+
std::unordered_map<std::string, int>& memberNames,
2431+
uint64_t currOffsetBits,
2432+
std::string& code,
2433+
bool isInUnion) {
24222434
// Generate unique name for member
24232435
std::string memberName = m.member_name;
24242436
deduplicateMemberName(memberNames, memberName);
@@ -2513,8 +2525,11 @@ std::optional<uint64_t> OICodeGen::generateMember(
25132525
}
25142526

25152527
bool OICodeGen::generateParent(
2516-
drgn_type* p, std::unordered_map<std::string, int>& memberNames,
2517-
uint64_t& currOffsetBits, std::string& code, size_t offsetToNextMember) {
2528+
drgn_type* p,
2529+
std::unordered_map<std::string, int>& memberNames,
2530+
uint64_t& currOffsetBits,
2531+
std::string& code,
2532+
size_t offsetToNextMember) {
25182533
// Parent class could be a typedef
25192534
PaddingInfo paddingInfo{};
25202535
bool violatesAlignmentRequirement = false;
@@ -2606,9 +2621,13 @@ std::optional<uint64_t> OICodeGen::getAlignmentRequirements(drgn_type* e) {
26062621
}
26072622

26082623
bool OICodeGen::generateStructMembers(
2609-
drgn_type* e, std::unordered_map<std::string, int>& memberNames,
2610-
std::string& code, uint64_t& out_offset_bits, PaddingInfo& paddingInfo,
2611-
bool& violatesAlignmentRequirement, size_t offsetToNextMemberInSubclass) {
2624+
drgn_type* e,
2625+
std::unordered_map<std::string, int>& memberNames,
2626+
std::string& code,
2627+
uint64_t& out_offset_bits,
2628+
PaddingInfo& paddingInfo,
2629+
bool& violatesAlignmentRequirement,
2630+
size_t offsetToNextMemberInSubclass) {
26122631
if (classMembersMap.find(e) == classMembersMap.end()) {
26132632
VLOG(1) << "Failed to find type in classMembersMap: " << e;
26142633
}
@@ -3632,8 +3651,10 @@ bool OICodeGen::generate(std::string& code) {
36323651
* Generate static_asserts for the offsets of each member of the given type
36333652
*/
36343653
bool OICodeGen::staticAssertMemberOffsets(
3635-
const std::string& struct_name, drgn_type* struct_type,
3636-
std::string& assert_str, std::unordered_map<std::string, int>& memberNames,
3654+
const std::string& struct_name,
3655+
drgn_type* struct_type,
3656+
std::string& assert_str,
3657+
std::unordered_map<std::string, int>& memberNames,
36373658
uint64_t base_offset) {
36383659
if (knownDummyTypeList.find(struct_type) != knownDummyTypeList.end()) {
36393660
return true;

src/OICodeGen.h

+23-11
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,8 @@ class OICodeGen {
224224
bool isKnownType(const std::string& type, std::string& matched);
225225

226226
static bool getTemplateParams(
227-
drgn_type* type, size_t numTemplateParams,
227+
drgn_type* type,
228+
size_t numTemplateParams,
228229
std::vector<std::pair<drgn_qualified_type, std::string>>& v);
229230

230231
bool enumerateTemplateParamIdxs(drgn_type* type,
@@ -233,7 +234,8 @@ class OICodeGen {
233234
bool& ifStub);
234235
bool getContainerTemplateParams(drgn_type* type, bool& ifStub);
235236
void enumerateDescendants(drgn_type* type, drgn_type* baseType);
236-
void getFuncDefinitionStr(std::string& code, drgn_type* type,
237+
void getFuncDefinitionStr(std::string& code,
238+
drgn_type* type,
237239
const std::string& typeName);
238240
std::optional<uint64_t> getDrgnTypeSize(drgn_type* type);
239241

@@ -251,19 +253,24 @@ class OICodeGen {
251253
std::optional<uint64_t> generateMember(
252254
const DrgnClassMemberInfo& m,
253255
std::unordered_map<std::string, int>& memberNames,
254-
uint64_t currOffsetBits, std::string& code, bool isInUnion);
256+
uint64_t currOffsetBits,
257+
std::string& code,
258+
bool isInUnion);
255259
bool generateParent(drgn_type* p,
256260
std::unordered_map<std::string, int>& memberNames,
257-
uint64_t& currOffsetBits, std::string& code,
261+
uint64_t& currOffsetBits,
262+
std::string& code,
258263
size_t offsetToNextMember);
259264
std::optional<uint64_t> getAlignmentRequirements(drgn_type* e);
260265
bool generateStructMembers(drgn_type* e,
261266
std::unordered_map<std::string, int>& memberNames,
262-
std::string& code, uint64_t& out_offset_bits,
267+
std::string& code,
268+
uint64_t& out_offset_bits,
263269
PaddingInfo& paddingInfo,
264270
bool& violatesAlignmentRequirement,
265271
size_t offsetToNextMember);
266-
void getFuncDefClassMembers(std::string& code, drgn_type* type,
272+
void getFuncDefClassMembers(std::string& code,
273+
drgn_type* type,
267274
std::unordered_map<std::string, int>& memberNames,
268275
bool skipPadding = false);
269276
bool isDrgnSizeComplete(drgn_type* type);
@@ -274,7 +281,8 @@ class OICodeGen {
274281
bool ifEnumerateClass(const std::string& typeName);
275282

276283
bool enumerateClassParents(drgn_type* type, const std::string& typeName);
277-
bool enumerateClassMembers(drgn_type* type, const std::string& typeName,
284+
bool enumerateClassMembers(drgn_type* type,
285+
const std::string& typeName,
278286
bool& isStubbed);
279287
bool enumerateClassTemplateParams(drgn_type* type,
280288
const std::string& typeName,
@@ -308,17 +316,21 @@ class OICodeGen {
308316
void getClassMembersIncludingParent(drgn_type* type,
309317
std::vector<DrgnClassMemberInfo>& out);
310318
bool staticAssertMemberOffsets(
311-
const std::string& struct_name, drgn_type* struct_type,
319+
const std::string& struct_name,
320+
drgn_type* struct_type,
312321
std::string& assert_str,
313322
std::unordered_map<std::string, int>& member_names,
314323
uint64_t base_offset = 0);
315-
bool addStaticAssertsForType(drgn_type* type, bool generateAssertsForOffsets,
324+
bool addStaticAssertsForType(drgn_type* type,
325+
bool generateAssertsForOffsets,
316326
std::string& code);
317-
bool buildNameInt(drgn_type* type, std::string& nameWithoutTemplate,
327+
bool buildNameInt(drgn_type* type,
328+
std::string& nameWithoutTemplate,
318329
std::string& outName);
319330
void replaceTemplateOperator(
320331
std::vector<std::pair<drgn_qualified_type, std::string>>& template_params,
321-
std::vector<std::string>& template_params_strings, size_t index);
332+
std::vector<std::string>& template_params_strings,
333+
size_t index);
322334
void replaceTemplateParameters(
323335
drgn_type* type,
324336
std::vector<std::pair<drgn_qualified_type, std::string>>& template_params,

0 commit comments

Comments
 (0)