Skip to content

Commit 0bc2500

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:46236f4c3dbe into origin/amd-gfx:8a9df1520f29
Local branch origin/amd-gfx 8a9df15 Merged main:35622a93bb03 into origin/amd-gfx:b7a60f94656e Remote branch main 46236f4 [lldb] Add missing type conversion for Windows
2 parents 8a9df15 + 46236f4 commit 0bc2500

File tree

27 files changed

+558
-114
lines changed

27 files changed

+558
-114
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,8 @@ Fixed Point Support in Clang
361361
AST Matchers
362362
------------
363363

364+
- Ensure ``isDerivedFrom`` matches the correct base in case more than one alias exists.
365+
364366
clang-format
365367
------------
366368

clang/lib/ASTMatchers/ASTMatchFinder.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1287,6 +1287,27 @@ class MatchASTVisitor : public RecursiveASTVisitor<MatchASTVisitor>,
12871287
auto Aliases = TypeAliases.find(CanonicalType);
12881288
if (Aliases == TypeAliases.end())
12891289
return false;
1290+
1291+
if (const auto *ElaboratedTypeNode =
1292+
llvm::dyn_cast<ElaboratedType>(TypeNode)) {
1293+
if (ElaboratedTypeNode->isSugared() && Aliases->second.size() > 1) {
1294+
const auto &DesugaredTypeName =
1295+
ElaboratedTypeNode->desugar().getAsString();
1296+
1297+
for (const TypedefNameDecl *Alias : Aliases->second) {
1298+
if (Alias->getName() != DesugaredTypeName) {
1299+
continue;
1300+
}
1301+
1302+
BoundNodesTreeBuilder Result(*Builder);
1303+
if (Matcher.matches(*Alias, this, &Result)) {
1304+
*Builder = std::move(Result);
1305+
return true;
1306+
}
1307+
}
1308+
}
1309+
}
1310+
12901311
for (const TypedefNameDecl *Alias : Aliases->second) {
12911312
BoundNodesTreeBuilder Result(*Builder);
12921313
if (Matcher.matches(*Alias, this, &Result)) {

clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,6 +1167,23 @@ TEST_P(ASTMatchersTest, IsDerivedFrom_EmptyName) {
11671167
EXPECT_TRUE(notMatches(Code, cxxRecordDecl(isSameOrDerivedFrom(""))));
11681168
}
11691169

1170+
TEST_P(ASTMatchersTest, IsDerivedFrom_ElaboratedType) {
1171+
if (!GetParam().isCXX()) {
1172+
return;
1173+
}
1174+
1175+
DeclarationMatcher IsDerivenFromBase =
1176+
cxxRecordDecl(isDerivedFrom(decl().bind("typedef")));
1177+
1178+
EXPECT_TRUE(matchAndVerifyResultTrue(
1179+
"struct AnInterface {};"
1180+
"typedef AnInterface UnusedTypedef;"
1181+
"typedef AnInterface Base;"
1182+
"class AClass : public Base {};",
1183+
IsDerivenFromBase,
1184+
std::make_unique<VerifyIdIsBoundTo<TypedefDecl>>("typedef", "Base")));
1185+
}
1186+
11701187
TEST_P(ASTMatchersTest, IsDerivedFrom_ObjC) {
11711188
DeclarationMatcher IsDerivedFromX = objcInterfaceDecl(isDerivedFrom("X"));
11721189
EXPECT_TRUE(

flang/include/flang/Tools/TargetSetup.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,14 @@ namespace Fortran::tools {
4242
targetCharacteristics.set_hasSubnormalFlushingControl(/*kind=*/8);
4343
}
4444

45-
if (targetTriple.getArch() != llvm::Triple::ArchType::x86_64) {
45+
switch (targetTriple.getArch()) {
46+
case llvm::Triple::ArchType::amdgcn:
47+
case llvm::Triple::ArchType::x86_64:
48+
break;
49+
default:
4650
targetCharacteristics.DisableType(
4751
Fortran::common::TypeCategory::Real, /*kind=*/10);
52+
break;
4853
}
4954

5055
// Check for kind=16 support. See flang/runtime/Float128Math/math-entries.h.

flang/test/Lower/OpenMP/real10.f90

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
!REQUIRES: amdgpu-registered-target
2+
3+
!RUN: %flang_fc1 -emit-hlfir -fopenmp -triple amdgcn -fopenmp -fopenmp-is-target-device -o - %s | FileCheck %s
4+
5+
!CHECK: hlfir.declare %0 {uniq_name = "_QFEx"} : (!fir.ref<f80>) -> (!fir.ref<f80>, !fir.ref<f80>)
6+
7+
program p
8+
real(10) :: x
9+
!$omp target
10+
continue
11+
!$omp end target
12+
end
13+

lldb/bindings/interface/SBProgressDocstrings.i

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,48 @@ The Progress class helps make sure that progress is correctly reported
1111
and will always send an initial progress update, updates when
1212
Progress::Increment() is called, and also will make sure that a progress
1313
completed update is reported even if the user doesn't explicitly cause one
14-
to be sent.") lldb::SBProgress;
14+
to be sent.
15+
16+
Progress can either be deterministic, incrementing up to a known total or non-deterministic
17+
with an unbounded total. Deterministic is better if you know the items of work in advance, but non-deterministic
18+
exposes a way to update a user during a long running process that work is taking place.
19+
20+
For all progresses the details provided in the constructor will be sent until an increment detail
21+
is provided. This detail will also continue to be broadcasted on any subsequent update that doesn't
22+
specify a new detail. Some implementations differ on throttling updates and this behavior differs primarily
23+
if the progress is deterministic or non-deterministic. For DAP, non-deterministic update messages have a higher
24+
throttling rate than deterministic ones.
25+
26+
Below are examples in Python for deterministic and non-deterministic progresses.
27+
28+
deterministic_progress1 = lldb.SBProgress('Deterministic Progress', 'Detail', 3, lldb.SBDebugger)
29+
for i in range(3):
30+
deterministic_progress1.Increment(1, f'Update {i}')
31+
# The call to Finalize() is a no-op as we already incremented the right amount of
32+
# times and caused the end event to be sent.
33+
deterministic_progress1.Finalize()
34+
35+
deterministic_progress2 = lldb.SBProgress('Deterministic Progress', 'Detail', 10, lldb.SBDebugger)
36+
for i in range(3):
37+
deterministic_progress2.Increment(1, f'Update {i}')
38+
# Cause the progress end event to be sent even if we didn't increment the right
39+
# number of times. Real world examples would be in a try-finally block to ensure
40+
# progress clean-up.
41+
deterministic_progress2.Finalize()
42+
43+
If you don't call Finalize() when the progress is not done, the progress object will eventually get
44+
garbage collected by the Python runtime, the end event will eventually get sent, but it is best not to
45+
rely on the garbage collection when using lldb.SBProgress.
46+
47+
Non-deterministic progresses behave the same, but omit the total in the constructor.
48+
49+
non_deterministic_progress = lldb.SBProgress('Non deterministic progress, 'Detail', lldb.SBDebugger)
50+
for i in range(10):
51+
non_deterministic_progress.Increment(1)
52+
# Explicitly send a progressEnd, otherwise this will be sent
53+
# when the python runtime cleans up this object.
54+
non_deterministic_progress.Finalize()
55+
") lldb::SBProgress;
1556

1657
%feature("docstring",
1758
"Finalize the SBProgress, which will cause a progress end event to be emitted. This

lldb/test/API/tools/lldb-dap/progress/Progress_emitter.py

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ def create_options(cls):
3737
)
3838

3939
parser.add_option(
40-
"--total", dest="total", help="Total to count up.", type="int"
40+
"--total",
41+
dest="total",
42+
help="Total items in this progress object. When this option is not specified, this will be an indeterminate progress.",
43+
type="int",
44+
default=None,
4145
)
4246

4347
parser.add_option(
@@ -47,6 +51,14 @@ def create_options(cls):
4751
type="int",
4852
)
4953

54+
parser.add_option(
55+
"--no-details",
56+
dest="no_details",
57+
help="Do not display details",
58+
action="store_true",
59+
default=False,
60+
)
61+
5062
return parser
5163

5264
def get_short_help(self):
@@ -68,12 +80,30 @@ def __call__(self, debugger, command, exe_ctx, result):
6880
return
6981

7082
total = cmd_options.total
71-
progress = lldb.SBProgress("Progress tester", "Detail", total, debugger)
83+
if total is None:
84+
progress = lldb.SBProgress(
85+
"Progress tester", "Initial Indeterminate Detail", debugger
86+
)
87+
else:
88+
progress = lldb.SBProgress(
89+
"Progress tester", "Initial Detail", total, debugger
90+
)
91+
92+
# Check to see if total is set to None to indicate an indeterminate progress
93+
# then default to 10 steps.
94+
if total is None:
95+
total = 10
7296

7397
for i in range(1, total):
74-
progress.Increment(1, f"Step {i}")
98+
if cmd_options.no_details:
99+
progress.Increment(1)
100+
else:
101+
progress.Increment(1, f"Step {i}")
75102
time.sleep(cmd_options.seconds)
76103

104+
# Not required for deterministic progress, but required for indeterminate progress.
105+
progress.Finalize()
106+
77107

78108
def __lldb_init_module(debugger, dict):
79109
# Register all classes that have a register_lldb_command method

lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py

Lines changed: 104 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,54 @@
44

55
from lldbsuite.test.decorators import *
66
from lldbsuite.test.lldbtest import *
7+
import json
78
import os
89
import time
910

1011
import lldbdap_testcase
1112

1213

1314
class TestDAP_progress(lldbdap_testcase.DAPTestCaseBase):
15+
def verify_progress_events(
16+
self,
17+
expected_title,
18+
expected_message=None,
19+
expected_not_in_message=None,
20+
only_verify_first_update=False,
21+
):
22+
self.dap_server.wait_for_event("progressEnd", 15)
23+
self.assertTrue(len(self.dap_server.progress_events) > 0)
24+
start_found = False
25+
update_found = False
26+
end_found = False
27+
for event in self.dap_server.progress_events:
28+
event_type = event["event"]
29+
if "progressStart" in event_type:
30+
title = event["body"]["title"]
31+
self.assertIn(expected_title, title)
32+
start_found = True
33+
if "progressUpdate" in event_type:
34+
message = event["body"]["message"]
35+
if only_verify_first_update and update_found:
36+
continue
37+
if expected_message is not None:
38+
self.assertIn(expected_message, message)
39+
if expected_not_in_message is not None:
40+
self.assertNotIn(expected_not_in_message, message)
41+
update_found = True
42+
if "progressEnd" in event_type:
43+
end_found = True
44+
45+
self.assertTrue(start_found)
46+
self.assertTrue(update_found)
47+
self.assertTrue(end_found)
48+
1449
@skipIfWindows
1550
def test_output(self):
1651
program = self.getBuildArtifact("a.out")
1752
self.build_and_launch(program)
1853
progress_emitter = os.path.join(os.getcwd(), "Progress_emitter.py")
19-
print(f"Progress emitter path: {progress_emitter}")
2054
source = "main.cpp"
21-
# Set breakpoint in the thread function so we can step the threads
2255
breakpoint_ids = self.set_source_breakpoints(
2356
source, [line_number(source, "// break here")]
2457
)
@@ -30,20 +63,73 @@ def test_output(self):
3063
"`test-progress --total 3 --seconds 1", context="repl"
3164
)
3265

33-
self.dap_server.wait_for_event("progressEnd", 15)
34-
# Expect at least a start, an update, and end event
35-
# However because the underlying Progress instance is an RAII object and we can't guaruntee
36-
# it's deterministic destruction in the python API, we verify just start and update
37-
# otherwise this test could be flakey.
38-
self.assertTrue(len(self.dap_server.progress_events) > 0)
39-
start_found = False
40-
update_found = False
41-
for event in self.dap_server.progress_events:
42-
event_type = event["event"]
43-
if "progressStart" in event_type:
44-
start_found = True
45-
if "progressUpdate" in event_type:
46-
update_found = True
66+
self.verify_progress_events(
67+
expected_title="Progress tester",
68+
expected_not_in_message="Progress tester",
69+
)
4770

48-
self.assertTrue(start_found)
49-
self.assertTrue(update_found)
71+
@skipIfWindows
72+
def test_output_nodetails(self):
73+
program = self.getBuildArtifact("a.out")
74+
self.build_and_launch(program)
75+
progress_emitter = os.path.join(os.getcwd(), "Progress_emitter.py")
76+
source = "main.cpp"
77+
breakpoint_ids = self.set_source_breakpoints(
78+
source, [line_number(source, "// break here")]
79+
)
80+
self.continue_to_breakpoints(breakpoint_ids)
81+
self.dap_server.request_evaluate(
82+
f"`command script import {progress_emitter}", context="repl"
83+
)
84+
self.dap_server.request_evaluate(
85+
"`test-progress --total 3 --seconds 1 --no-details", context="repl"
86+
)
87+
88+
self.verify_progress_events(
89+
expected_title="Progress tester",
90+
expected_message="Initial Detail",
91+
)
92+
93+
@skipIfWindows
94+
def test_output_indeterminate(self):
95+
program = self.getBuildArtifact("a.out")
96+
self.build_and_launch(program)
97+
progress_emitter = os.path.join(os.getcwd(), "Progress_emitter.py")
98+
source = "main.cpp"
99+
breakpoint_ids = self.set_source_breakpoints(
100+
source, [line_number(source, "// break here")]
101+
)
102+
self.continue_to_breakpoints(breakpoint_ids)
103+
self.dap_server.request_evaluate(
104+
f"`command script import {progress_emitter}", context="repl"
105+
)
106+
self.dap_server.request_evaluate("`test-progress --seconds 1", context="repl")
107+
108+
self.verify_progress_events(
109+
expected_title="Progress tester: Initial Indeterminate Detail",
110+
expected_message="Step 1",
111+
only_verify_first_update=True,
112+
)
113+
114+
@skipIfWindows
115+
def test_output_nodetails_indeterminate(self):
116+
program = self.getBuildArtifact("a.out")
117+
self.build_and_launch(program)
118+
progress_emitter = os.path.join(os.getcwd(), "Progress_emitter.py")
119+
source = "main.cpp"
120+
breakpoint_ids = self.set_source_breakpoints(
121+
source, [line_number(source, "// break here")]
122+
)
123+
self.dap_server.request_evaluate(
124+
f"`command script import {progress_emitter}", context="repl"
125+
)
126+
127+
self.dap_server.request_evaluate(
128+
"`test-progress --seconds 1 --no-details", context="repl"
129+
)
130+
131+
self.verify_progress_events(
132+
expected_title="Progress tester: Initial Indeterminate Detail",
133+
expected_message="Initial Indeterminate Detail",
134+
only_verify_first_update=True,
135+
)

0 commit comments

Comments
 (0)