Skip to content

Commit c4b28c8

Browse files
committed
Revert "[NFC][sanitizer] Clang-format sanitizer_symbolizer_posix_libcdep.cpp (llvm#133011)"
This reverts commit 03817f0.
1 parent e879213 commit c4b28c8

File tree

1 file changed

+44
-49
lines changed

1 file changed

+44
-49
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp

Lines changed: 44 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,9 @@
3838
// because we do not require a C++ ABI library to be linked to a program
3939
// using sanitizers; if it's not present, we'll just use the mangled name.
4040
namespace __cxxabiv1 {
41-
extern "C" SANITIZER_WEAK_ATTRIBUTE char *__cxa_demangle(const char *mangled,
42-
char *buffer,
43-
size_t *length,
44-
int *status);
41+
extern "C" SANITIZER_WEAK_ATTRIBUTE
42+
char *__cxa_demangle(const char *mangled, char *buffer,
43+
size_t *length, int *status);
4544
}
4645

4746
namespace __sanitizer {
@@ -54,7 +53,8 @@ const char *DemangleCXXABI(const char *name) {
5453
// it does not allocate). For now, we just call it anyway, and we leak
5554
// the returned value.
5655
if (&__cxxabiv1::__cxa_demangle)
57-
if (const char *demangled_name = __cxxabiv1::__cxa_demangle(name, 0, 0, 0))
56+
if (const char *demangled_name =
57+
__cxxabiv1::__cxa_demangle(name, 0, 0, 0))
5858
return demangled_name;
5959

6060
return nullptr;
@@ -85,8 +85,7 @@ const char *DemangleSwift(const char *name) {
8585
}
8686

8787
const char *DemangleSwiftAndCXX(const char *name) {
88-
if (!name)
89-
return nullptr;
88+
if (!name) return nullptr;
9089
if (const char *swift_demangled_name = DemangleSwift(name))
9190
return swift_demangled_name;
9291
return DemangleCXXABI(name);
@@ -115,8 +114,7 @@ static bool CreateTwoHighNumberedPipes(int *infd_, int *outfd_) {
115114
} else {
116115
outfd = sock_pair[i];
117116
for (int j = 0; j < i; j++) {
118-
if (sock_pair[j] == infd)
119-
continue;
117+
if (sock_pair[j] == infd) continue;
120118
internal_close(sock_pair[j][0]);
121119
internal_close(sock_pair[j][1]);
122120
}
@@ -157,7 +155,7 @@ bool SymbolizerProcess::StartSymbolizerSubprocess() {
157155
}
158156

159157
if (use_posix_spawn_) {
160-
# if SANITIZER_APPLE
158+
#if SANITIZER_APPLE
161159
fd_t fd = internal_spawn(argv, const_cast<const char **>(GetEnvP()), &pid);
162160
if (fd == kInvalidFd) {
163161
Report("WARNING: failed to spawn external symbolizer (errno: %d)\n",
@@ -167,16 +165,14 @@ bool SymbolizerProcess::StartSymbolizerSubprocess() {
167165

168166
input_fd_ = fd;
169167
output_fd_ = fd;
170-
# else // SANITIZER_APPLE
168+
#else // SANITIZER_APPLE
171169
UNIMPLEMENTED();
172-
# endif // SANITIZER_APPLE
170+
#endif // SANITIZER_APPLE
173171
} else {
174172
fd_t infd[2] = {}, outfd[2] = {};
175173
if (!CreateTwoHighNumberedPipes(infd, outfd)) {
176-
Report(
177-
"WARNING: Can't create a socket pair to start "
178-
"external symbolizer (errno: %d)\n",
179-
errno);
174+
Report("WARNING: Can't create a socket pair to start "
175+
"external symbolizer (errno: %d)\n", errno);
180176
return false;
181177
}
182178

@@ -264,11 +260,10 @@ bool Addr2LineProcess::ReachedEndOfOutput(const char *buffer,
264260
// 1. First one, corresponding to given offset to be symbolized
265261
// (may be equal to output_terminator_, if offset is not valid).
266262
// 2. Second one for output_terminator_, itself to mark the end of output.
267-
if (length <= kTerminatorLen)
268-
return false;
263+
if (length <= kTerminatorLen) return false;
269264
// Addr2Line output should end up with output_terminator_.
270-
return !internal_memcmp(buffer + length - kTerminatorLen, output_terminator_,
271-
kTerminatorLen);
265+
return !internal_memcmp(buffer + length - kTerminatorLen,
266+
output_terminator_, kTerminatorLen);
272267
}
273268

274269
class Addr2LinePool final : public SymbolizerTool {
@@ -288,7 +283,9 @@ class Addr2LinePool final : public SymbolizerTool {
288283
return false;
289284
}
290285

291-
bool SymbolizeData(uptr addr, DataInfo *info) override { return false; }
286+
bool SymbolizeData(uptr addr, DataInfo *info) override {
287+
return false;
288+
}
292289

293290
private:
294291
const char *SendCommand(const char *module_name, uptr module_offset) {
@@ -302,21 +299,22 @@ class Addr2LinePool final : public SymbolizerTool {
302299
}
303300
if (!addr2line) {
304301
addr2line =
305-
new (*allocator_) Addr2LineProcess(addr2line_path_, module_name);
302+
new(*allocator_) Addr2LineProcess(addr2line_path_, module_name);
306303
addr2line_pool_.push_back(addr2line);
307304
}
308305
CHECK_EQ(0, internal_strcmp(module_name, addr2line->module_name()));
309306
char buffer[kBufferSize];
310-
internal_snprintf(buffer, kBufferSize, "0x%zx\n0x%zx\n", module_offset,
311-
dummy_address_);
307+
internal_snprintf(buffer, kBufferSize, "0x%zx\n0x%zx\n",
308+
module_offset, dummy_address_);
312309
return addr2line->SendCommand(buffer);
313310
}
314311

315312
static const uptr kBufferSize = 64;
316313
const char *addr2line_path_;
317314
LowLevelAllocator *allocator_;
318-
InternalMmapVector<Addr2LineProcess *> addr2line_pool_;
319-
static const uptr dummy_address_ = FIRST_32_SECOND_64(UINT32_MAX, UINT64_MAX);
315+
InternalMmapVector<Addr2LineProcess*> addr2line_pool_;
316+
static const uptr dummy_address_ =
317+
FIRST_32_SECOND_64(UINT32_MAX, UINT64_MAX);
320318
};
321319

322320
# if SANITIZER_SUPPORTS_WEAK_HOOKS
@@ -354,9 +352,8 @@ class InternalSymbolizer final : public SymbolizerTool {
354352
}
355353

356354
bool SymbolizePC(uptr addr, SymbolizedStack *stack) override {
357-
bool result = __sanitizer_symbolize_code(stack->info.module,
358-
stack->info.module_offset, buffer_,
359-
sizeof(buffer_));
355+
bool result = __sanitizer_symbolize_code(
356+
stack->info.module, stack->info.module_offset, buffer_, sizeof(buffer_));
360357
if (result)
361358
ParseSymbolizePCOutput(buffer_, stack);
362359
return result;
@@ -426,43 +423,41 @@ static SymbolizerTool *ChooseExternalSymbolizer(LowLevelAllocator *allocator) {
426423
} else if (!internal_strncmp(binary_name, kLLVMSymbolizerPrefix,
427424
internal_strlen(kLLVMSymbolizerPrefix))) {
428425
VReport(2, "Using llvm-symbolizer at user-specified path: %s\n", path);
429-
return new (*allocator) LLVMSymbolizer(path, allocator);
426+
return new(*allocator) LLVMSymbolizer(path, allocator);
430427
} else if (!internal_strcmp(binary_name, "atos")) {
431-
# if SANITIZER_APPLE
428+
#if SANITIZER_APPLE
432429
VReport(2, "Using atos at user-specified path: %s\n", path);
433-
return new (*allocator) AtosSymbolizer(path, allocator);
434-
# else // SANITIZER_APPLE
430+
return new(*allocator) AtosSymbolizer(path, allocator);
431+
#else // SANITIZER_APPLE
435432
Report("ERROR: Using `atos` is only supported on Darwin.\n");
436433
Die();
437-
# endif // SANITIZER_APPLE
434+
#endif // SANITIZER_APPLE
438435
} else if (!internal_strcmp(binary_name, "addr2line")) {
439436
VReport(2, "Using addr2line at user-specified path: %s\n", path);
440-
return new (*allocator) Addr2LinePool(path, allocator);
437+
return new(*allocator) Addr2LinePool(path, allocator);
441438
} else if (path) {
442-
Report(
443-
"ERROR: External symbolizer path is set to '%s' which isn't "
444-
"a known symbolizer. Please set the path to the llvm-symbolizer "
445-
"binary or other known tool.\n",
446-
path);
439+
Report("ERROR: External symbolizer path is set to '%s' which isn't "
440+
"a known symbolizer. Please set the path to the llvm-symbolizer "
441+
"binary or other known tool.\n", path);
447442
Die();
448443
}
449444

450445
// Otherwise symbolizer program is unknown, let's search $PATH
451446
CHECK(path == nullptr);
452-
# if SANITIZER_APPLE
447+
#if SANITIZER_APPLE
453448
if (const char *found_path = FindPathToBinary("atos")) {
454449
VReport(2, "Using atos found at: %s\n", found_path);
455-
return new (*allocator) AtosSymbolizer(found_path, allocator);
450+
return new(*allocator) AtosSymbolizer(found_path, allocator);
456451
}
457-
# endif // SANITIZER_APPLE
452+
#endif // SANITIZER_APPLE
458453
if (const char *found_path = FindPathToBinary("llvm-symbolizer")) {
459454
VReport(2, "Using llvm-symbolizer found at: %s\n", found_path);
460-
return new (*allocator) LLVMSymbolizer(found_path, allocator);
455+
return new(*allocator) LLVMSymbolizer(found_path, allocator);
461456
}
462457
if (common_flags()->allow_addr2line) {
463458
if (const char *found_path = FindPathToBinary("addr2line")) {
464459
VReport(2, "Using addr2line found at: %s\n", found_path);
465-
return new (*allocator) Addr2LinePool(found_path, allocator);
460+
return new(*allocator) Addr2LinePool(found_path, allocator);
466461
}
467462
}
468463
return nullptr;
@@ -497,17 +492,17 @@ static void ChooseSymbolizerTools(IntrusiveList<SymbolizerTool> *list,
497492
list->push_back(tool);
498493
}
499494

500-
# if SANITIZER_APPLE
495+
#if SANITIZER_APPLE
501496
VReport(2, "Using dladdr symbolizer.\n");
502-
list->push_back(new (*allocator) DlAddrSymbolizer());
503-
# endif // SANITIZER_APPLE
497+
list->push_back(new(*allocator) DlAddrSymbolizer());
498+
#endif // SANITIZER_APPLE
504499
}
505500

506501
Symbolizer *Symbolizer::PlatformInit() {
507502
IntrusiveList<SymbolizerTool> list;
508503
list.clear();
509504
ChooseSymbolizerTools(&list, &symbolizer_allocator_);
510-
return new (symbolizer_allocator_) Symbolizer(list);
505+
return new(symbolizer_allocator_) Symbolizer(list);
511506
}
512507

513508
void Symbolizer::LateInitialize() {

0 commit comments

Comments
 (0)