Skip to content

Commit 44a9a0b

Browse files
committed
[𝘀𝗽𝗿] changes introduced through rebase
Created using spr 1.3.6 [skip ci]
2 parents 0f34bbf + d5aa5e3 commit 44a9a0b

File tree

201 files changed

+5208
-1320
lines changed

Some content is hidden

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

201 files changed

+5208
-1320
lines changed

.github/workflows/libcxx-build-and-test.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ on:
2929
permissions:
3030
contents: read # Default everything to read-only
3131

32+
concurrency:
33+
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
34+
cancel-in-progress: true
35+
3236
jobs:
3337
stage1:
3438
if: github.repository_owner == 'llvm'

.github/workflows/libcxx-run-benchmarks.yml

Lines changed: 64 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
name: Benchmark libc++
1111

1212
permissions:
13-
contents: read # Default everything to read-only
13+
contents: read
1414

1515
on:
1616
issue_comment:
@@ -21,46 +21,90 @@ on:
2121
env:
2222
CC: clang-22
2323
CXX: clang++-22
24-
COMMENT_BODY: ${{ github.event.comment.body }}
25-
26-
concurrency:
27-
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
28-
cancel-in-progress: true
2924

3025
jobs:
3126
run-benchmarks:
27+
permissions:
28+
pull-requests: write
29+
3230
if: >-
3331
github.event.issue.pull_request &&
3432
contains(github.event.comment.body, '/libcxx-bot benchmark')
3533
3634
runs-on: llvm-premerge-libcxx-next-runners # TODO: This should run on a dedicated set of machines
3735
steps:
38-
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
39-
with:
40-
fetch-depth: 0
41-
fetch-tags: true # This job requires access to all the Git branches so it can diff against (usually) main
42-
4336
- uses: actions/setup-python@v6
4437
with:
4538
python-version: '3.10'
4639

47-
- name: Install dependencies
40+
- name: Extract information from the PR
41+
id: vars
4842
run: |
4943
python3 -m venv .venv
5044
source .venv/bin/activate
51-
python -m pip install -r libcxx/utils/requirements.txt
45+
python -m pip install pygithub
46+
47+
cat <<EOF | python >> ${GITHUB_OUTPUT}
48+
import github
49+
repo = github.Github("${{ github.token }}").get_repo("${{ github.repository }}")
50+
pr = repo.get_pull(${{ github.event.issue.number }})
51+
print(f"pr_base={pr.base.sha}")
52+
print(f"pr_head={pr.head.sha}")
53+
EOF
54+
BENCHMARKS=$(echo "${{ github.event.comment.body }}" | sed -nE 's/\/libcxx-bot benchmark (.+)/\1/p')
55+
echo "benchmarks=${BENCHMARKS}" >> ${GITHUB_OUTPUT}
56+
57+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
58+
with:
59+
ref: ${{ steps.vars.outputs.pr_head }}
60+
fetch-depth: 0
61+
fetch-tags: true # This job requires access to all the Git branches so it can diff against (usually) main
62+
path: repo # Avoid nuking the workspace, where we have the Python virtualenv
5263

5364
- name: Run baseline
5465
run: |
55-
BENCHMARKS=$(echo "${COMMENT_BODY}" | sed -n 's/\/libcxx-bot benchmark (.+)/\1/p')
56-
baseline_commit=$(git merge-base refs/remotes/origin/${GITHUB_BASE_REF} ${GITHUB_SHA})
57-
./libcxx/utils/test-at-commit --commit ${baseline_commit} -B build/baseline -- -sv -j1 --param optimization=speed ${BENCHMARKS}
66+
source .venv/bin/activate && cd repo
67+
python -m pip install -r libcxx/utils/requirements.txt
68+
baseline_commit=$(git merge-base ${{ steps.vars.outputs.pr_base }} ${{ steps.vars.outputs.pr_head }})
69+
./libcxx/utils/test-at-commit --commit ${baseline_commit} -B build/baseline -- -sv -j1 --param optimization=speed ${{ steps.vars.outputs.benchmarks }}
70+
./libcxx/utils/consolidate-benchmarks build/baseline | tee baseline.lnt
5871
5972
- name: Run candidate
6073
run: |
61-
BENCHMARKS=$(echo "${COMMENT_BODY}" | sed -n 's/\/libcxx-bot benchmark (.+)/\1/p')
62-
./libcxx/utils/test-at-commit --commit ${GITHUB_SHA} -B build/candidate -- -sv -j1 --param optimization=speed ${BENCHMARKS}
74+
source .venv/bin/activate && cd repo
75+
./libcxx/utils/test-at-commit --commit ${{ steps.vars.outputs.pr_head }} -B build/candidate -- -sv -j1 --param optimization=speed ${{ steps.vars.outputs.benchmarks }}
76+
./libcxx/utils/consolidate-benchmarks build/candidate | tee candidate.lnt
6377
6478
- name: Compare baseline and candidate runs
65-
run: ./libcxx/utils/compare-benchmarks <(./libcxx/utils/consolidate-benchmarks build/baseline) \
66-
<(./libcxx/utils/consolidate-benchmarks build/candidate)
79+
run: |
80+
source .venv/bin/activate && cd repo
81+
./libcxx/utils/compare-benchmarks baseline.lnt candidate.lnt | tee results.txt
82+
83+
- name: Update comment with results
84+
run: |
85+
source .venv/bin/activate && cd repo
86+
cat <<EOF | python
87+
import github
88+
repo = github.Github("${{ github.token }}").get_repo("${{ github.repository }}")
89+
pr = repo.get_pull(${{ github.event.issue.number }})
90+
comment = pr.get_issue_comment(${{ github.event.comment.id }})
91+
with open('results.txt', 'r') as f:
92+
benchmark_results = f.read()
93+
94+
new_comment_text = f"""
95+
{comment.body}
96+
97+
<details>
98+
<summary>
99+
Benchmark results:
100+
</summary>
101+
102+
\`\`\`
103+
{benchmark_results}
104+
\`\`\`
105+
106+
</details>
107+
"""
108+
109+
comment.edit(new_comment_text)
110+
EOF

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,8 @@ Improvements to Clang's diagnostics
283283
pointers under ``-Wthread-safety-beta`` (still experimental), which reduces
284284
both false positives but also false negatives through more precise analysis.
285285

286+
- Clang now looks through parenthesis for ``-Wundefined-reinterpret-cast`` diagnostic.
287+
286288
Improvements to Clang's time-trace
287289
----------------------------------
288290

clang/lib/Sema/SemaExpr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14784,7 +14784,7 @@ static QualType CheckIndirectionOperand(Sema &S, Expr *Op, ExprValueKind &VK,
1478414784
QualType OpTy = Op->getType();
1478514785
QualType Result;
1478614786

14787-
if (isa<CXXReinterpretCastExpr>(Op)) {
14787+
if (isa<CXXReinterpretCastExpr>(Op->IgnoreParens())) {
1478814788
QualType OpOrigType = Op->IgnoreParenCasts()->getType();
1478914789
S.CheckCompatibleReinterpretCast(OpOrigType, OpTy, /*IsDereference*/true,
1479014790
Op->getSourceRange());

clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,13 @@ bool tryToFindPtrOrigin(
9191
continue;
9292
}
9393
if (auto *call = dyn_cast<CallExpr>(E)) {
94+
if (auto *Callee = call->getCalleeDecl()) {
95+
if (Callee->hasAttr<CFReturnsRetainedAttr>() ||
96+
Callee->hasAttr<NSReturnsRetainedAttr>()) {
97+
return callback(E, true);
98+
}
99+
}
100+
94101
if (auto *memberCall = dyn_cast<CXXMemberCallExpr>(call)) {
95102
if (auto *decl = memberCall->getMethodDecl()) {
96103
std::optional<bool> IsGetterOfRefCt = isGetterOfSafePtr(decl);
@@ -154,6 +161,24 @@ bool tryToFindPtrOrigin(
154161
Name == "NSClassFromString")
155162
return callback(E, true);
156163
}
164+
165+
// Sometimes, canonical type erroneously turns Ref<T> into T.
166+
// Workaround this problem by checking again if the original type was
167+
// a SubstTemplateTypeParmType of a safe smart pointer type (e.g. Ref).
168+
if (auto *CalleeDecl = call->getCalleeDecl()) {
169+
if (auto *FD = dyn_cast<FunctionDecl>(CalleeDecl)) {
170+
auto RetType = FD->getReturnType();
171+
if (auto *Subst = dyn_cast<SubstTemplateTypeParmType>(RetType)) {
172+
if (auto *SubstType = Subst->desugar().getTypePtr()) {
173+
if (auto *RD = dyn_cast<RecordType>(SubstType)) {
174+
if (auto *CXX = dyn_cast<CXXRecordDecl>(RD->getOriginalDecl()))
175+
if (isSafePtr(CXX))
176+
return callback(E, true);
177+
}
178+
}
179+
}
180+
}
181+
}
157182
}
158183
if (auto *ObjCMsgExpr = dyn_cast<ObjCMessageExpr>(E)) {
159184
if (auto *Method = ObjCMsgExpr->getMethodDecl()) {

clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,10 @@ class TrivialFunctionAnalysisVisitor
666666
return IsFunctionTrivial(Callee);
667667
}
668668

669+
bool VisitGCCAsmStmt(const GCCAsmStmt *AS) {
670+
return AS->getAsmString() == "brk #0xc471";
671+
}
672+
669673
bool
670674
VisitSubstNonTypeTemplateParmExpr(const SubstNonTypeTemplateParmExpr *E) {
671675
// Non-type template paramter is compile time constant and trivial.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.webkit.UncountedCallArgsChecker -verify %s
2+
// expected-no-diagnostics
3+
4+
#include "mock-types.h"
5+
6+
struct Obj {
7+
void ref() const;
8+
void deref() const;
9+
10+
void someFunction();
11+
};
12+
13+
template<typename T> class Wrapper {
14+
public:
15+
T obj();
16+
};
17+
18+
static void foo(Wrapper<Ref<Obj>>&& wrapper)
19+
{
20+
wrapper.obj()->someFunction();
21+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// RUN: %clang_analyze_cc1 -triple arm-darwin -analyzer-checker=alpha.webkit.UncountedCallArgsChecker -verify %s
2+
// expected-no-diagnostics
3+
4+
void crash()
5+
{
6+
__asm__ volatile ("brk #0xc471");
7+
__builtin_unreachable();
8+
}
9+
10+
class SomeObj {
11+
public:
12+
void ref();
13+
void deref();
14+
15+
void someWork() { crash(); }
16+
};
17+
18+
SomeObj* provide();
19+
20+
void doSomeWork() {
21+
provide()->someWork();
22+
}

clang/test/Analysis/Checkers/WebKit/unretained-call-args.mm

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,32 @@ void use_const_local() {
438438

439439
} // namespace const_global
440440

441+
namespace ns_retained_return_value {
442+
443+
NSString *provideNS() NS_RETURNS_RETAINED;
444+
CFDictionaryRef provideCF() CF_RETURNS_RETAINED;
445+
void consumeNS(NSString *);
446+
void consumeCF(CFDictionaryRef);
447+
448+
void foo() {
449+
consumeNS(provideNS());
450+
consumeCF(provideCF());
451+
}
452+
453+
struct Base {
454+
NSString *provideStr() NS_RETURNS_RETAINED;
455+
};
456+
457+
struct Derived : Base {
458+
void consumeStr(NSString *);
459+
460+
void foo() {
461+
consumeStr(provideStr());
462+
}
463+
};
464+
465+
} // namespace ns_retained_return_value
466+
441467
@interface TestObject : NSObject
442468
- (void)doWork:(NSString *)msg, ...;
443469
- (void)doWorkOnSelf;

clang/test/Analysis/Checkers/WebKit/unretained-local-vars.mm

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,21 @@ void use_const_local() {
408408

409409
} // namespace const_global
410410

411+
namespace ns_retained_return_value {
412+
413+
NSString *provideNS() NS_RETURNS_RETAINED;
414+
CFDictionaryRef provideCF() CF_RETURNS_RETAINED;
415+
void consumeNS(NSString *);
416+
void consumeCF(CFDictionaryRef);
417+
418+
unsigned foo() {
419+
auto *string = provideNS();
420+
auto *dictionary = provideCF();
421+
return string.length + CFDictionaryGetCount(dictionary);
422+
}
423+
424+
} // namespace ns_retained_return_value
425+
411426
bool doMoreWorkOpaque(OtherObj*);
412427
SomeObj* provide();
413428

0 commit comments

Comments
 (0)