Skip to content

Commit 737eb03

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:602e47c5f9fd into amd-gfx:f337c8eadcf3
Local branch amd-gfx f337c8e Merged main:f8f934e22c4a into amd-gfx:bd63dc7b6e97 Remote branch main 602e47c [lldb] Format Python files in scripts and utils (llvm#66053)
2 parents f337c8e + 602e47c commit 737eb03

File tree

63 files changed

+6453
-1150
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+6453
-1150
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import github
2+
import os
3+
import sys
4+
import time
5+
6+
7+
def needs_to_wait(repo):
8+
workflow_name = os.environ.get("GITHUB_WORKFLOW")
9+
run_number = os.environ.get("GITHUB_RUN_NUMBER")
10+
print("Workflow Name:", workflow_name, "Run Number:", run_number)
11+
for status in ["in_progress", "queued"]:
12+
for workflow in repo.get_workflow_runs(status=status):
13+
print("Looking at ", workflow.name, "#", workflow.run_number)
14+
if workflow.name != workflow_name:
15+
continue
16+
if workflow.run_number < int(run_number):
17+
print("Workflow {} still {} ".format(workflow.run_number, status))
18+
return True
19+
return False
20+
21+
22+
repo_name = os.environ.get("GITHUB_REPOSITORY")
23+
token = os.environ.get("GITHUB_TOKEN")
24+
gh = github.Github(token)
25+
repo = gh.get_repo(repo_name)
26+
while needs_to_wait(repo):
27+
time.sleep(30)

.github/workflows/pr-subscriber.yml

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,9 @@ on:
77
- completed
88

99
permissions:
10+
actions: read
1011
contents: read
1112

12-
concurrency:
13-
# Ideally, we would use the PR number in the concurrency group, but we don't
14-
# have access to it here. We need to ensure only one job is running for
15-
# each PR at a time, because there is a potential race condition when
16-
# updating the issue comment.
17-
group: "PR Subscriber"
18-
cancel-in-progress: false
19-
2013
jobs:
2114
auto-subscribe:
2215
runs-on: ubuntu-latest
@@ -25,6 +18,23 @@ jobs:
2518
github.event.workflow_run.event == 'pull_request' &&
2619
github.event.workflow_run.conclusion == 'success'
2720
steps:
21+
- name: Setup Automation Script
22+
run: |
23+
curl -O -L https://raw.githubusercontent.com/"$GITHUB_REPOSITORY"/main/llvm/utils/git/github-automation.py
24+
curl -O -L https://raw.githubusercontent.com/"$GITHUB_REPOSITORY"/main/llvm/utils/git/requirements.txt
25+
curl -O -L https://raw.githubusercontent.com/"$GITHUB_REPOSITORY"/main/.github/workflows/pr-subscriber-wait.py
26+
chmod a+x github-automation.py
27+
pip install -r requirements.txt
28+
29+
- name: 'Wait for other actions'
30+
# We can't use the concurrency tag for these jobs, because it will
31+
# cancel pending jobs if another job is running.
32+
env:
33+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34+
run: |
35+
python3 pr-subscriber-wait.py
36+
37+
2838
# From: https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
2939
# Updated version here: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#using-data-from-the-triggering-workflow
3040
- name: 'Download artifact'
@@ -50,13 +60,6 @@ jobs:
5060
5161
- run: unzip pr.zip
5262

53-
- name: Setup Automation Script
54-
run: |
55-
curl -O -L https://raw.githubusercontent.com/"$GITHUB_REPOSITORY"/main/llvm/utils/git/github-automation.py
56-
curl -O -L https://raw.githubusercontent.com/"$GITHUB_REPOSITORY"/main/llvm/utils/git/requirements.txt
57-
chmod a+x github-automation.py
58-
pip install -r requirements.txt
59-
6063
- name: Update watchers
6164
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
6265
run: |

clang/lib/AST/ExprConstant.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6062,8 +6062,9 @@ const AccessKinds StartLifetimeOfUnionMemberHandler::AccessKind;
60626062
/// operator whose left-hand side might involve a union member access. If it
60636063
/// does, implicitly start the lifetime of any accessed union elements per
60646064
/// C++20 [class.union]5.
6065-
static bool HandleUnionActiveMemberChange(EvalInfo &Info, const Expr *LHSExpr,
6066-
const LValue &LHS) {
6065+
static bool MaybeHandleUnionActiveMemberChange(EvalInfo &Info,
6066+
const Expr *LHSExpr,
6067+
const LValue &LHS) {
60676068
if (LHS.InvalidBase || LHS.Designator.Invalid)
60686069
return false;
60696070

@@ -6118,8 +6119,14 @@ static bool HandleUnionActiveMemberChange(EvalInfo &Info, const Expr *LHSExpr,
61186119
break;
61196120
// Walk path backwards as we walk up from the base to the derived class.
61206121
for (const CXXBaseSpecifier *Elt : llvm::reverse(ICE->path())) {
6122+
if (Elt->isVirtual()) {
6123+
// A class with virtual base classes never has a trivial default
6124+
// constructor, so S(E) is empty in this case.
6125+
E = nullptr;
6126+
break;
6127+
}
6128+
61216129
--PathLength;
6122-
(void)Elt;
61236130
assert(declaresSameEntity(Elt->getType()->getAsCXXRecordDecl(),
61246131
LHS.Designator.Entries[PathLength]
61256132
.getAsBaseOrMember().getPointer()));
@@ -7806,7 +7813,7 @@ class ExprEvaluatorBase
78067813
// per C++20 [class.union]5.
78077814
if (Info.getLangOpts().CPlusPlus20 && OCE &&
78087815
OCE->getOperator() == OO_Equal && MD->isTrivial() &&
7809-
!HandleUnionActiveMemberChange(Info, Args[0], ThisVal))
7816+
!MaybeHandleUnionActiveMemberChange(Info, Args[0], ThisVal))
78107817
return false;
78117818

78127819
Args = Args.slice(1);
@@ -8679,7 +8686,7 @@ bool LValueExprEvaluator::VisitBinAssign(const BinaryOperator *E) {
86798686
return false;
86808687

86818688
if (Info.getLangOpts().CPlusPlus20 &&
8682-
!HandleUnionActiveMemberChange(Info, E->getLHS(), Result))
8689+
!MaybeHandleUnionActiveMemberChange(Info, E->getLHS(), Result))
86838690
return false;
86848691

86858692
return handleAssignment(this->Info, E, Result, E->getLHS()->getType(),

clang/lib/AST/Interp/ByteCodeExprGen.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -634,8 +634,14 @@ bool ByteCodeExprGen<Emitter>::VisitSubstNonTypeTemplateParmExpr(
634634

635635
template <class Emitter>
636636
bool ByteCodeExprGen<Emitter>::VisitConstantExpr(const ConstantExpr *E) {
637-
// TODO: Check if the ConstantExpr already has a value set and if so,
638-
// use that instead of evaluating it again.
637+
// Try to emit the APValue directly, without visiting the subexpr.
638+
// This will only fail if we can't emit the APValue, so won't emit any
639+
// diagnostics or any double values.
640+
std::optional<PrimType> T = classify(E->getType());
641+
if (T && E->hasAPValueResult() &&
642+
this->visitAPValue(E->getAPValueResult(), *T, E))
643+
return true;
644+
639645
return this->delegate(E->getSubExpr());
640646
}
641647

clang/lib/Format/TokenAnnotator.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2598,9 +2598,12 @@ class AnnotatingParser {
25982598
if (InTemplateArgument && NextToken->Tok.isAnyIdentifier())
25992599
return TT_BinaryOperator;
26002600

2601-
// "&&(" is quite unlikely to be two successive unary "&".
2602-
if (Tok.is(tok::ampamp) && NextToken->is(tok::l_paren))
2601+
// "&&" followed by "(", "*", or "&" is quite unlikely to be two successive
2602+
// unary "&".
2603+
if (Tok.is(tok::ampamp) &&
2604+
NextToken->isOneOf(tok::l_paren, tok::star, tok::amp)) {
26032605
return TT_BinaryOperator;
2606+
}
26042607

26052608
// This catches some cases where evaluation order is used as control flow:
26062609
// aaa && aaa->f();

clang/test/Preprocessor/riscv-target-features.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@
643643
// RUN: %clang -target riscv64-unknown-linux-gnu \
644644
// RUN: -march=rv64izicntr -x c -E -dM %s \
645645
// RUN: -o - | FileCheck --check-prefix=CHECK-ZICNTR-EXT %s
646-
// CHECK-ZICNTR-EXT: __riscv_zicntr 1000000{{$}}
646+
// CHECK-ZICNTR-EXT: __riscv_zicntr 2000000{{$}}
647647

648648
// RUN: %clang -target riscv32-unknown-linux-gnu \
649649
// RUN: -march=rv32izicsr2p0 -x c -E -dM %s \
@@ -677,6 +677,14 @@
677677
// RUN: -o - | FileCheck --check-prefix=CHECK-ZIHINTPAUSE-EXT %s
678678
// CHECK-ZIHINTPAUSE-EXT: __riscv_zihintpause 2000000{{$}}
679679

680+
// RUN: %clang -target riscv32-unknown-linux-gnu \
681+
// RUN: -march=rv32izihpm -x c -E -dM %s \
682+
// RUN: -o - | FileCheck --check-prefix=CHECK-ZIHPM-EXT %s
683+
// RUN: %clang -target riscv64-unknown-linux-gnu \
684+
// RUN: -march=rv64izihpm -x c -E -dM %s \
685+
// RUN: -o - | FileCheck --check-prefix=CHECK-ZIHPM-EXT %s
686+
// CHECK-ZIHPM-EXT: __riscv_zihpm 2000000{{$}}
687+
680688
// RUN: %clang -target riscv32-unknown-linux-gnu \
681689
// RUN: -march=rv32izk1p0 -x c -E -dM %s \
682690
// RUN: -o - | FileCheck --check-prefix=CHECK-ZK-EXT %s
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// RUN: %clang_cc1 -std=c++2a -verify -triple=x86_64-linux-gnu %s
2+
// expected-no-diagnostics
3+
4+
// Fixes assertion triggered by https://github.com/llvm/llvm-project/issues/65982
5+
6+
struct A { int y; };
7+
struct B : virtual public A {};
8+
struct X : public B {};
9+
10+
void member_with_virtual_inheritance() {
11+
X x;
12+
x.B::y = 1;
13+
}

clang/unittests/Format/TokenAnnotatorTest.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,12 @@ TEST_F(TokenAnnotatorTest, UnderstandsUsesOfStarAndAmp) {
280280
EXPECT_TOKEN(Tokens[12], tok::ampamp, TT_BinaryOperator);
281281
EXPECT_TOKEN(Tokens[27], tok::ampamp, TT_BinaryOperator);
282282

283+
Tokens = annotate("foo = *i < *j && *j > *k;");
284+
EXPECT_EQ(Tokens.size(), 15u) << Tokens;
285+
EXPECT_TOKEN(Tokens[4], tok::less, TT_BinaryOperator);
286+
EXPECT_TOKEN(Tokens[7], tok::ampamp, TT_BinaryOperator);
287+
EXPECT_TOKEN(Tokens[10], tok::greater, TT_BinaryOperator);
288+
283289
FormatStyle Style = getLLVMStyle();
284290
Style.TypeNames.push_back("MYI");
285291
Tokens = annotate("if (MYI *p{nullptr})", Style);

lldb/scripts/analyze-project-deps.py

Lines changed: 42 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,21 @@
1010
from use_lldb_suite import lldb_root
1111

1212
parser = argparse.ArgumentParser(
13-
description='Analyze LLDB project #include dependencies.')
14-
parser.add_argument('--show-counts', default=False, action='store_true',
15-
help='When true, show the number of dependencies from each subproject')
16-
parser.add_argument('--discover-cycles', default=False, action='store_true',
17-
help='When true, find and display all project dependency cycles. Note,'
18-
'this option is very slow')
13+
description="Analyze LLDB project #include dependencies."
14+
)
15+
parser.add_argument(
16+
"--show-counts",
17+
default=False,
18+
action="store_true",
19+
help="When true, show the number of dependencies from each subproject",
20+
)
21+
parser.add_argument(
22+
"--discover-cycles",
23+
default=False,
24+
action="store_true",
25+
help="When true, find and display all project dependency cycles. Note,"
26+
"this option is very slow",
27+
)
1928

2029
args = parser.parse_args()
2130

@@ -24,12 +33,14 @@
2433

2534
src_map = {}
2635

27-
include_regex = re.compile('#include \"((lldb|Plugins|clang)(.*/)+).*\"')
36+
include_regex = re.compile('#include "((lldb|Plugins|clang)(.*/)+).*"')
37+
2838

2939
def is_sublist(small, big):
3040
it = iter(big)
3141
return all(c in it for c in small)
3242

43+
3344
def normalize_host(str):
3445
if str.startswith("lldb/Host"):
3546
return "lldb/Host"
@@ -39,6 +50,7 @@ def normalize_host(str):
3950
return str.replace("lldb/../../source", "lldb")
4051
return str
4152

53+
4254
def scan_deps(this_dir, file):
4355
global src_map
4456
deps = {}
@@ -62,7 +74,8 @@ def scan_deps(this_dir, file):
6274
if this_dir not in src_map and len(deps) > 0:
6375
src_map[this_dir] = deps
6476

65-
for (base, dirs, files) in os.walk(inc_dir):
77+
78+
for base, dirs, files in os.walk(inc_dir):
6679
dir = os.path.basename(base)
6780
relative = os.path.relpath(base, inc_dir)
6881
inc_files = [x for x in files if os.path.splitext(x)[1] in [".h"]]
@@ -71,7 +84,7 @@ def scan_deps(this_dir, file):
7184
inc_path = os.path.join(base, inc)
7285
scan_deps(relative, inc_path)
7386

74-
for (base, dirs, files) in os.walk(src_dir):
87+
for base, dirs, files in os.walk(src_dir):
7588
dir = os.path.basename(base)
7689
relative = os.path.relpath(base, src_dir)
7790
src_files = [x for x in files if os.path.splitext(x)[1] in [".cpp", ".h", ".mm"]]
@@ -82,6 +95,7 @@ def scan_deps(this_dir, file):
8295
scan_deps(norm_base_path, src_path)
8396
pass
8497

98+
8599
def is_existing_cycle(path, cycles):
86100
# If we have a cycle like # A -> B -> C (with an implicit -> A at the end)
87101
# then we don't just want to check for an occurrence of A -> B -> C in the
@@ -90,12 +104,13 @@ def is_existing_cycle(path, cycles):
90104
# at the end), then A -> B -> C is also a cycle. This is an important
91105
# optimization which reduces the search space by multiple orders of
92106
# magnitude.
93-
for i in range(0,len(path)):
107+
for i in range(0, len(path)):
94108
if any(is_sublist(x, path) for x in cycles):
95109
return True
96110
path = [path[-1]] + path[0:-1]
97111
return False
98112

113+
99114
def expand(path_queue, path_lengths, cycles, src_map):
100115
# We do a breadth first search, to make sure we visit all paths in order
101116
# of ascending length. This is an important optimization to make sure that
@@ -127,54 +142,57 @@ def expand(path_queue, path_lengths, cycles, src_map):
127142
path_queue.append(cur_path + [item])
128143
pass
129144

145+
130146
cycles = []
131147

132148
path_queue = [[x] for x in iter(src_map)]
133149
path_lens = [1] * len(path_queue)
134150

135151
items = list(src_map.items())
136-
items.sort(key = lambda A : A[0])
152+
items.sort(key=lambda A: A[0])
137153

138-
for (path, deps) in items:
154+
for path, deps in items:
139155
print(path + ":")
140156
sorted_deps = list(deps.items())
141157
if args.show_counts:
142-
sorted_deps.sort(key = lambda A: (A[1], A[0]))
158+
sorted_deps.sort(key=lambda A: (A[1], A[0]))
143159
for dep in sorted_deps:
144160
print("\t{} [{}]".format(dep[0], dep[1]))
145161
else:
146-
sorted_deps.sort(key = lambda A: A[0])
162+
sorted_deps.sort(key=lambda A: A[0])
147163
for dep in sorted_deps:
148164
print("\t{}".format(dep[0]))
149165

166+
150167
def iter_cycles(cycles):
151168
global src_map
152169
for cycle in cycles:
153170
cycle.append(cycle[0])
154171
zipper = list(zip(cycle[0:-1], cycle[1:]))
155-
result = [(x, src_map[x][y], y) for (x,y) in zipper]
172+
result = [(x, src_map[x][y], y) for (x, y) in zipper]
156173
total = 0
157174
smallest = result[0][1]
158-
for (first, value, last) in result:
175+
for first, value, last in result:
159176
total += value
160177
smallest = min(smallest, value)
161178
yield (total, smallest, result)
162179

180+
163181
if args.discover_cycles:
164182
print("Analyzing cycles...")
165183

166184
expand(path_queue, path_lens, cycles, src_map)
167185

168-
average = sum([len(x)+1 for x in cycles]) / len(cycles)
186+
average = sum([len(x) + 1 for x in cycles]) / len(cycles)
169187

170188
print("Found {} cycles. Average cycle length = {}.".format(len(cycles), average))
171189
counted = list(iter_cycles(cycles))
172190
if args.show_counts:
173-
counted.sort(key = lambda A: A[0])
174-
for (total, smallest, cycle) in counted:
191+
counted.sort(key=lambda A: A[0])
192+
for total, smallest, cycle in counted:
175193
sys.stdout.write("{} deps to break: ".format(total))
176194
sys.stdout.write(cycle[0][0])
177-
for (first, count, last) in cycle:
195+
for first, count, last in cycle:
178196
sys.stdout.write(" [{}->] {}".format(count, last))
179197
sys.stdout.write("\n")
180198
else:
@@ -186,8 +204,8 @@ def iter_cycles(cycles):
186204
islands = []
187205
outgoing_counts = defaultdict(int)
188206
incoming_counts = defaultdict(int)
189-
for (total, smallest, cycle) in counted:
190-
for (first, count, last) in cycle:
207+
for total, smallest, cycle in counted:
208+
for first, count, last in cycle:
191209
outgoing_counts[first] += count
192210
incoming_counts[last] += count
193211
for cycle in cycles:
@@ -201,8 +219,8 @@ def iter_cycles(cycles):
201219
sorted = []
202220
for node in island:
203221
sorted.append((node, incoming_counts[node], outgoing_counts[node]))
204-
sorted.sort(key = lambda x: x[1]+x[2])
205-
for (node, inc, outg) in sorted:
222+
sorted.sort(key=lambda x: x[1] + x[2])
223+
for node, inc, outg in sorted:
206224
print(" {} [{} in, {} out]".format(node, inc, outg))
207225
sys.stdout.flush()
208226
pass

0 commit comments

Comments
 (0)