Skip to content

Commit 71d2fcf

Browse files
Added upcoming clang-format and other merge changes
1 parent 01d9338 commit 71d2fcf

File tree

8 files changed

+49
-59
lines changed

8 files changed

+49
-59
lines changed

lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,7 @@ bool ConnectionFileDescriptor::IsConnected() const {
119119

120120
ConnectionStatus ConnectionFileDescriptor::Connect(llvm::StringRef path,
121121
Status *error_ptr) {
122-
return Connect(
123-
path, [](llvm::StringRef) {}, error_ptr);
122+
return Connect(path, [](llvm::StringRef) {}, error_ptr);
124123
}
125124

126125
ConnectionStatus
@@ -716,8 +715,7 @@ ConnectionFileDescriptor::ConnectFD(llvm::StringRef s,
716715
ConnectionStatus ConnectionFileDescriptor::ConnectFile(
717716
llvm::StringRef s, socket_id_callback_type socket_id_callback,
718717
Status *error_ptr) {
719-
#if !defined(_AIX)
720-
#if LLDB_ENABLE_POSIX
718+
#if LLDB_ENABLE_POSIX && !defined(_AIX)
721719
std::string addr_str = s.str();
722720
// file:///PATH
723721
int fd = FileSystem::Instance().Open(addr_str.c_str(), O_RDWR);
@@ -748,8 +746,7 @@ ConnectionStatus ConnectionFileDescriptor::ConnectFile(
748746

749747
m_io_sp = std::make_shared<NativeFile>(fd, File::eOpenOptionReadWrite, true);
750748
return eConnectionStatusSuccess;
751-
#endif // LLDB_ENABLE_POSIX
752-
#endif
749+
#endif // LLDB_ENABLE_POSIX && !defined(_AIX)
753750
llvm_unreachable("this function should be only called w/ LLDB_ENABLE_POSIX");
754751
}
755752

lldb/source/Host/posix/DomainSocket.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,9 @@ Status DomainSocket::Connect(llvm::StringRef name) {
8989
m_socket = CreateSocket(kDomain, kType, 0, error);
9090
if (error.Fail())
9191
return error;
92-
if (llvm::sys::RetryAfterSignal(-1, ::connect, GetNativeSocket(),
93-
(struct sockaddr *)&saddr_un, saddr_un_len) < 0)
92+
if (llvm::sys::RetryAfterSignal(-1, ::connect, GetNativeSocket(),
93+
(struct sockaddr *)&saddr_un,
94+
saddr_un_len) < 0)
9495
SetLastError(error);
9596

9697
return error;

lldb/source/Host/posix/FileSystemPosix.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// C includes
1212
#include <dirent.h>
1313
#include <fcntl.h>
14-
#if !defined(_AIX)
14+
#ifndef _AIX
1515
#include <sys/mount.h>
1616
#endif
1717
#include <sys/param.h>

lldb/source/Host/posix/MainLoopPosix.cpp

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ class MainLoopPosix::RunImpl {
9999
~RunImpl() = default;
100100

101101
Status Poll();
102+
int StartPoll(std::optional<MainLoopPosix::TimePoint> point);
102103
void ProcessReadEvents();
103104

104105
private:
@@ -159,6 +160,22 @@ MainLoopPosix::RunImpl::RunImpl(MainLoopPosix &loop) : loop(loop) {
159160
read_fds.reserve(loop.m_read_fds.size());
160161
}
161162

163+
int MainLoopPosix::RunImpl::StartPoll(
164+
std::optional<MainLoopPosix::TimePoint> point) {
165+
#if HAVE_PPOLL
166+
return ppoll(read_fds.data(), read_fds.size(), ToTimeSpec(point),
167+
/*sigmask=*/nullptr);
168+
#else
169+
using namespace std::chrono;
170+
int timeout = -1;
171+
if (point) {
172+
nanoseconds dur = std::max(*point - steady_clock::now(), nanoseconds(0));
173+
timeout = ceil<milliseconds>(dur).count();
174+
}
175+
return poll(read_fds.data(), read_fds.size(), timeout);
176+
#endif
177+
}
178+
162179
Status MainLoopPosix::RunImpl::Poll() {
163180
read_fds.clear();
164181

@@ -169,24 +186,10 @@ Status MainLoopPosix::RunImpl::Poll() {
169186
pfd.revents = 0;
170187
read_fds.push_back(pfd);
171188
}
189+
int ready = StartPoll(loop.GetNextWakeupTime());
172190

173-
#if defined(_AIX)
174-
sigset_t origmask;
175-
int timeout;
176-
177-
timeout = -1;
178-
pthread_sigmask(SIG_SETMASK, nullptr, &origmask);
179-
int ready = poll(read_fds.data(), read_fds.size(), timeout);
180-
pthread_sigmask(SIG_SETMASK, &origmask, nullptr);
181191
if (ready == -1 && errno != EINTR)
182192
return Status(errno, eErrorTypePOSIX);
183-
#else
184-
if (ppoll(read_fds.data(), read_fds.size(),
185-
ToTimeSpec(loop.GetNextWakeupTime()),
186-
/*sigmask=*/nullptr) == -1 &&
187-
errno != EINTR)
188-
return Status(errno, eErrorTypePOSIX);
189-
#endif
190193

191194
return Status();
192195
}
@@ -291,16 +294,6 @@ MainLoopPosix::RegisterSignal(int signo, const Callback &callback,
291294
UNUSED_IF_ASSERT_DISABLED(ret);
292295
assert(ret == 0 && "sigaction failed");
293296

294-
#if HAVE_SYS_EVENT_H
295-
struct kevent ev;
296-
EV_SET(&ev, signo, EVFILT_SIGNAL, EV_ADD, 0, 0, 0);
297-
ret = kevent(m_kqueue, &ev, 1, nullptr, 0, nullptr);
298-
assert(ret == 0);
299-
#endif
300-
301-
// If we're using kqueue, the signal needs to be unblocked in order to
302-
// receive it. If using pselect/ppoll, we need to block it, and later unblock
303-
// it as a part of the system call.
304297
ret = pthread_sigmask(SIG_UNBLOCK, &new_action.sa_mask, &old_set);
305298
assert(ret == 0 && "pthread_sigmask failed");
306299
info.was_blocked = sigismember(&old_set, signo);

lldb/source/Host/posix/ProcessLauncherPosixFork.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ struct ForkLaunchInfo {
197197
#else
198198
if (ptrace(PT_TRACE_ME, 0, nullptr, 0) == -1)
199199
#endif
200-
ExitWithError(error_fd, "ptrace");
200+
ExitWithError(error_fd, "ptrace");
201201
}
202202

203203
// Execute. We should never return...

lldb/source/Plugins/Language/ObjC/Cocoa.cpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
#include "llvm/ADT/APInt.h"
3232
#include "llvm/ADT/bit.h"
3333

34-
3534
using namespace lldb;
3635
using namespace lldb_private;
3736
using namespace lldb_private::formatters;
@@ -267,21 +266,21 @@ bool lldb_private::formatters::NSIndexSetSummaryProvider(
267266
if (class_name == "NSIndexSet" || class_name == "NSMutableIndexSet") {
268267
// Foundation version 2000 added a bitmask if the index set fit in 64 bits
269268
// and a Tagged Pointer version if the bitmask is small enough to fit in
270-
// the tagged pointer payload.
269+
// the tagged pointer payload.
271270
// It also changed the layout (but not the size) of the set descriptor.
272271

273272
// First check whether this is a tagged pointer. The bitmask will be in
274273
// the payload of the tagged pointer.
275274
uint64_t payload;
276-
if (runtime->GetFoundationVersion() >= 2000
277-
&& descriptor->GetTaggedPointerInfo(nullptr, nullptr, &payload)) {
275+
if (runtime->GetFoundationVersion() >= 2000 &&
276+
descriptor->GetTaggedPointerInfo(nullptr, nullptr, &payload)) {
278277
count = llvm::popcount(payload);
279278
break;
280279
}
281280
// The first 32 bits describe the index set in all cases:
282281
Status error;
283282
uint32_t mode = process_sp->ReadUnsignedIntegerFromMemory(
284-
valobj_addr + ptr_size, 4, 0, error);
283+
valobj_addr + ptr_size, 4, 0, error);
285284
if (error.Fail())
286285
return false;
287286
// Now check if the index is held in a bitmask in the object:
@@ -292,7 +291,7 @@ bool lldb_private::formatters::NSIndexSetSummaryProvider(
292291
if ((mode & 2) == 2) {
293292
// The bitfield is a 64 bit uint at the beginning of the data var.
294293
uint64_t bitfield = process_sp->ReadUnsignedIntegerFromMemory(
295-
valobj_addr + 2 * ptr_size, 8, 0, error);
294+
valobj_addr + 2 * ptr_size, 8, 0, error);
296295
if (error.Fail())
297296
return false;
298297
count = llvm::popcount(bitfield);
@@ -309,7 +308,7 @@ bool lldb_private::formatters::NSIndexSetSummaryProvider(
309308
count = 0;
310309
break;
311310
}
312-
311+
313312
if ((mode & 2) == 2)
314313
mode = 1; // this means the set only has one range
315314
else
@@ -1227,8 +1226,7 @@ bool lldb_private::formatters::ObjCSELSummaryProvider(
12271226
time_t lldb_private::formatters::GetOSXEpoch() {
12281227
static time_t epoch = 0;
12291228
if (!epoch) {
1230-
#if !defined(_AIX)
1231-
#ifndef _WIN32
1229+
#if !defined(_WIN32) && !defined(_AIX)
12321230
tzset();
12331231
tm tm_epoch;
12341232
tm_epoch.tm_sec = 0;
@@ -1241,7 +1239,6 @@ time_t lldb_private::formatters::GetOSXEpoch() {
12411239
tm_epoch.tm_gmtoff = 0;
12421240
tm_epoch.tm_zone = nullptr;
12431241
epoch = timegm(&tm_epoch);
1244-
#endif
12451242
#endif
12461243
}
12471244
return epoch;

lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,10 @@ size_t ObjectContainerBSDArchive::Archive::ParseObjects() {
8181

8282
std::unique_ptr<llvm::MemoryBuffer> mem_buffer =
8383
llvm::MemoryBuffer::getMemBuffer(
84-
llvm::StringRef((const char *)data.GetDataStart(),
85-
data.GetByteSize()),
86-
llvm::StringRef(),
87-
/*RequiresNullTerminator=*/false);
84+
llvm::StringRef((const char *)data.GetDataStart(),
85+
data.GetByteSize()),
86+
llvm::StringRef(),
87+
/*RequiresNullTerminator=*/false);
8888

8989
auto exp_ar = llvm::object::Archive::create(mem_buffer->getMemBufferRef());
9090
if (!exp_ar) {
@@ -95,7 +95,7 @@ size_t ObjectContainerBSDArchive::Archive::ParseObjects() {
9595

9696
llvm::Error iter_err = llvm::Error::success();
9797
Object obj;
98-
for (const auto &child: llvm_archive->children(iter_err)) {
98+
for (const auto &child : llvm_archive->children(iter_err)) {
9999
obj.Clear();
100100
auto exp_name = child.getName();
101101
if (exp_name) {
@@ -111,7 +111,9 @@ size_t ObjectContainerBSDArchive::Archive::ParseObjects() {
111111
obj.modification_time =
112112
std::chrono::duration_cast<std::chrono::seconds>(
113113
std::chrono::time_point_cast<std::chrono::seconds>(
114-
exp_mtime.get()).time_since_epoch()).count();
114+
exp_mtime.get())
115+
.time_since_epoch())
116+
.count();
115117
} else {
116118
LLDB_LOG_ERROR(l, exp_mtime.takeError(),
117119
"failed to get archive object time: {0}");
@@ -331,21 +333,21 @@ ObjectContainer *ObjectContainerBSDArchive::CreateInstance(
331333
ArchiveType
332334
ObjectContainerBSDArchive::MagicBytesMatch(const DataExtractor &data) {
333335
uint32_t offset = 0;
334-
const char *armag = (const char *)data.PeekData(offset,
335-
sizeof(ar_hdr) + SARMAG);
336+
const char *armag =
337+
(const char *)data.PeekData(offset, sizeof(ar_hdr) + SARMAG);
336338
if (armag == nullptr)
337339
return ArchiveType::Invalid;
338340
ArchiveType result = ArchiveType::Invalid;
339341
if (strncmp(armag, ArchiveMagic, SARMAG) == 0)
340-
result = ArchiveType::Archive;
342+
result = ArchiveType::Archive;
341343
else if (strncmp(armag, ThinArchiveMagic, SARMAG) == 0)
342-
result = ArchiveType::ThinArchive;
344+
result = ArchiveType::ThinArchive;
343345
else
344-
return ArchiveType::Invalid;
346+
return ArchiveType::Invalid;
345347

346348
armag += offsetof(struct ar_hdr, ar_fmag) + SARMAG;
347349
if (strncmp(armag, ARFMAG, 2) == 0)
348-
return result;
350+
return result;
349351
return ArchiveType::Invalid;
350352
}
351353

@@ -443,7 +445,8 @@ size_t ObjectContainerBSDArchive::GetModuleSpecifications(
443445
return 0;
444446

445447
const size_t initial_count = specs.GetSize();
446-
llvm::sys::TimePoint<> file_mod_time = FileSystem::Instance().GetModificationTime(file);
448+
llvm::sys::TimePoint<> file_mod_time =
449+
FileSystem::Instance().GetModificationTime(file);
447450
Archive::shared_ptr archive_sp(
448451
Archive::FindCachedArchive(file, ArchSpec(), file_mod_time, file_offset));
449452
bool set_archive_arch = false;

lldb/source/Utility/ArchSpec.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#include "lldb/lldb-defines.h"
1515
#include "llvm/ADT/STLExtras.h"
1616
#include "llvm/BinaryFormat/COFF.h"
17-
#include "llvm/BinaryFormat/XCOFF.h"
1817
#include "llvm/BinaryFormat/ELF.h"
1918
#include "llvm/BinaryFormat/MachO.h"
2019
#include "llvm/BinaryFormat/XCOFF.h"

0 commit comments

Comments
 (0)