Skip to content

Commit f1351a4

Browse files
authored
Merge branch 'main' into ops-sinking
2 parents 0cf29f3 + 7694817 commit f1351a4

File tree

35 files changed

+403
-124
lines changed

35 files changed

+403
-124
lines changed

clang/lib/Format/WhitespaceManager.cpp

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,9 @@ AlignTokenSequence(const FormatStyle &Style, unsigned Start, unsigned End,
288288
ArrayRef<unsigned> Matches,
289289
SmallVector<WhitespaceManager::Change, 16> &Changes) {
290290
int Shift = 0;
291+
// Set when the shift is applied anywhere in the line. Cleared when the line
292+
// ends.
293+
bool LineShifted = false;
291294

292295
// ScopeStack keeps track of the current scope depth. It contains the levels
293296
// of at most 2 scopes. The first one is the one that the matched token is
@@ -339,8 +342,11 @@ AlignTokenSequence(const FormatStyle &Style, unsigned Start, unsigned End,
339342
Changes[i - 1].Tok->is(tok::string_literal);
340343
bool SkipMatchCheck = InsideNestedScope || ContinuedStringLiteral;
341344

342-
if (CurrentChange.NewlinesBefore > 0 && !SkipMatchCheck)
343-
Shift = 0;
345+
if (CurrentChange.NewlinesBefore > 0) {
346+
LineShifted = false;
347+
if (!SkipMatchCheck)
348+
Shift = 0;
349+
}
344350

345351
// If this is the first matching token to be aligned, remember by how many
346352
// spaces it has to be shifted, so the rest of the changes on the line are
@@ -349,7 +355,6 @@ AlignTokenSequence(const FormatStyle &Style, unsigned Start, unsigned End,
349355
Shift = Column - (RightJustify ? CurrentChange.TokenLength : 0) -
350356
CurrentChange.StartOfTokenColumn;
351357
ScopeStack = {CurrentChange.indentAndNestingLevel()};
352-
CurrentChange.Spaces += Shift;
353358
}
354359

355360
if (Shift == 0)
@@ -358,8 +363,10 @@ AlignTokenSequence(const FormatStyle &Style, unsigned Start, unsigned End,
358363
// This is for lines that are split across multiple lines, as mentioned in
359364
// the ScopeStack comment. The stack size being 1 means that the token is
360365
// not in a scope that should not move.
361-
if (ScopeStack.size() == 1u && CurrentChange.NewlinesBefore > 0 &&
362-
(ContinuedStringLiteral || InsideNestedScope)) {
366+
if ((!Matches.empty() && Matches[0] == i) ||
367+
(ScopeStack.size() == 1u && CurrentChange.NewlinesBefore > 0 &&
368+
(ContinuedStringLiteral || InsideNestedScope))) {
369+
LineShifted = true;
363370
CurrentChange.Spaces += Shift;
364371
}
365372

@@ -369,9 +376,11 @@ AlignTokenSequence(const FormatStyle &Style, unsigned Start, unsigned End,
369376
static_cast<int>(Changes[i].Tok->SpacesRequiredBefore) ||
370377
CurrentChange.Tok->is(tok::eof));
371378

372-
CurrentChange.StartOfTokenColumn += Shift;
373-
if (i + 1 != Changes.size())
374-
Changes[i + 1].PreviousEndOfTokenColumn += Shift;
379+
if (LineShifted) {
380+
CurrentChange.StartOfTokenColumn += Shift;
381+
if (i + 1 != Changes.size())
382+
Changes[i + 1].PreviousEndOfTokenColumn += Shift;
383+
}
375384

376385
// If PointerAlignment is PAS_Right, keep *s or &s next to the token,
377386
// except if the token is equal, then a space is needed.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s
2+
3+
// CHECK-NOT: setter
4+
// CHECK-NOT: getter
5+
6+
@interface I1
7+
@property int p1;
8+
@end
9+
10+
@implementation I1
11+
@end
12+
13+
void foo(I1 *ptr) {}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Checks basic debug-info generation for property. Makes sure we
2+
// create a DIObjCProperty for the synthesized property.
3+
4+
// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s
5+
6+
// CHECK: !DIObjCProperty(name: "p1"
7+
// CHECK-SAME: attributes: 2316
8+
// CHECK-SAME: type: ![[P1_TYPE:[0-9]+]]
9+
//
10+
// CHECK: ![[P1_TYPE]] = !DIBasicType(name: "int"
11+
12+
@interface I1 {
13+
int p1;
14+
}
15+
@property int p1;
16+
@end
17+
18+
@implementation I1
19+
@synthesize p1;
20+
@end

clang/test/DebugInfo/ObjC/property.m

Lines changed: 0 additions & 15 deletions
This file was deleted.

clang/test/DebugInfo/ObjC/property4.m

Lines changed: 0 additions & 18 deletions
This file was deleted.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# objective-CXX is not supported on AIX and zOS
2+
unsupported_platforms = [ "system-aix", "system-zos" ]
3+
4+
if any(up in config.available_features for up in unsupported_platforms):
5+
config.unsupported = True

clang/unittests/Format/FormatTest.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19615,6 +19615,25 @@ TEST_F(FormatTest, AlignConsecutiveAssignments) {
1961519615
"};",
1961619616
Alignment);
1961719617

19618+
// Aligning lines should not mess up the comments. However, feel free to
19619+
// change the test if it turns out that comments inside the closure should not
19620+
// be aligned with those outside it.
19621+
verifyFormat("auto aaaaaaaaaaaaaaaaaaaaa = {}; //\n"
19622+
"auto b = [] { //\n"
19623+
" return; //\n"
19624+
"};",
19625+
Alignment);
19626+
verifyFormat("auto aaaaaaaaaaaaaaaaaaaaa = {}; //\n"
19627+
"auto b = [] { //\n"
19628+
" return aaaaaaaaaaaaaaaaaaaaa; //\n"
19629+
"};",
19630+
Alignment);
19631+
verifyFormat("auto aaaaaaaaaaaaaaa = {}; //\n"
19632+
"auto b = [] { //\n"
19633+
" return aaaaaaaaaaaaaaaaaaaaa; //\n"
19634+
"};",
19635+
Alignment);
19636+
1961819637
verifyFormat("auto b = f(aaaaaaaaaaaaaaaaaaaaaaaaa,\n"
1961919638
" ccc ? aaaaa : bbbbb,\n"
1962019639
" dddddddddddddddddddddddddd);",

lldb/include/lldb/Host/MainLoopBase.h

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,18 +57,23 @@ class MainLoopBase {
5757
// Add a pending callback that will be executed once after all the pending
5858
// events are processed. The callback will be executed even if termination
5959
// was requested.
60-
void AddPendingCallback(const Callback &callback) {
61-
AddCallback(callback, std::chrono::steady_clock::time_point());
60+
// Returns false if an interrupt was needed to get the loop to act on the new
61+
// callback, but the interrupt failed, true otherwise. Mostly used when the
62+
// pending callback is a RequestTermination, since if the interrupt fails for
63+
// that callback, waiting for the MainLoop thread to terminate could stall.
64+
bool AddPendingCallback(const Callback &callback) {
65+
return AddCallback(callback, std::chrono::steady_clock::time_point());
6266
}
6367

6468
// Add a callback that will be executed after a certain amount of time has
65-
// passed.
66-
void AddCallback(const Callback &callback, std::chrono::nanoseconds delay) {
67-
AddCallback(callback, std::chrono::steady_clock::now() + delay);
69+
// passed. See AddPendingCallback comment for the return value.
70+
bool AddCallback(const Callback &callback, std::chrono::nanoseconds delay) {
71+
return AddCallback(callback, std::chrono::steady_clock::now() + delay);
6872
}
6973

7074
// Add a callback that will be executed after a given point in time.
71-
void AddCallback(const Callback &callback, TimePoint point);
75+
// See AddPendingCallback comment for the return value.
76+
bool AddCallback(const Callback &callback, TimePoint point);
7277

7378
// Waits for registered events and invoke the proper callbacks. Returns when
7479
// all callbacks deregister themselves or when someone requests termination.
@@ -85,8 +90,9 @@ class MainLoopBase {
8590

8691
virtual void UnregisterReadObject(IOObject::WaitableHandle handle) = 0;
8792

88-
// Interrupt the loop that is currently waiting for events.
89-
virtual void Interrupt() = 0;
93+
/// Interrupt the loop that is currently waiting for events. Return true if
94+
/// the interrupt succeeded, false if it failed.
95+
virtual bool Interrupt() = 0;
9096

9197
void ProcessCallbacks();
9298

lldb/include/lldb/Host/posix/MainLoopPosix.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class MainLoopPosix : public MainLoopBase {
5454
void UnregisterReadObject(IOObject::WaitableHandle handle) override;
5555
void UnregisterSignal(int signo, std::list<Callback>::iterator callback_it);
5656

57-
void Interrupt() override;
57+
bool Interrupt() override;
5858

5959
private:
6060
void ProcessReadObject(IOObject::WaitableHandle handle);

lldb/include/lldb/Host/windows/MainLoopWindows.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class MainLoopWindows : public MainLoopBase {
5050
protected:
5151
void UnregisterReadObject(IOObject::WaitableHandle handle) override;
5252

53-
void Interrupt() override;
53+
bool Interrupt() override;
5454

5555
private:
5656
llvm::Expected<size_t> Poll();

0 commit comments

Comments
 (0)