Skip to content

Commit 0076645

Browse files
authored
Merge branch 'main' into p/libc-hdrgen-template
2 parents 54f276a + dcfc30c commit 0076645

File tree

7 files changed

+51
-132
lines changed

7 files changed

+51
-132
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,11 @@ class TrivialFunctionAnalysisVisitor
503503
return true;
504504
}
505505

506+
bool VisitOffsetOfExpr(const OffsetOfExpr *OE) {
507+
// offsetof(T, D) is considered trivial.
508+
return true;
509+
}
510+
506511
bool VisitCXXMemberCallExpr(const CXXMemberCallExpr *MCE) {
507512
if (!checkArguments(MCE))
508513
return false;

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

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class UncountedLambdaCapturesChecker
4141
const UncountedLambdaCapturesChecker *Checker;
4242
llvm::DenseSet<const DeclRefExpr *> DeclRefExprsToIgnore;
4343
llvm::DenseSet<const LambdaExpr *> LambdasToIgnore;
44+
llvm::DenseSet<const CXXConstructExpr *> ConstructToIgnore;
4445
QualType ClsType;
4546

4647
explicit LocalVisitor(const UncountedLambdaCapturesChecker *Checker)
@@ -106,6 +107,26 @@ class UncountedLambdaCapturesChecker
106107
return safeGetName(NsDecl) == "WTF" && safeGetName(Decl) == "switchOn";
107108
}
108109

110+
bool VisitCXXConstructExpr(CXXConstructExpr *CE) override {
111+
if (ConstructToIgnore.contains(CE))
112+
return true;
113+
if (auto *Callee = CE->getConstructor()) {
114+
unsigned ArgIndex = 0;
115+
for (auto *Param : Callee->parameters()) {
116+
if (ArgIndex >= CE->getNumArgs())
117+
return true;
118+
auto *Arg = CE->getArg(ArgIndex)->IgnoreParenCasts();
119+
if (auto *L = findLambdaInArg(Arg)) {
120+
LambdasToIgnore.insert(L);
121+
if (!Param->hasAttr<NoEscapeAttr>())
122+
Checker->visitLambdaExpr(L, shouldCheckThis());
123+
}
124+
++ArgIndex;
125+
}
126+
}
127+
return true;
128+
}
129+
109130
bool VisitCallExpr(CallExpr *CE) override {
110131
checkCalleeLambda(CE);
111132
if (auto *Callee = CE->getDirectCallee()) {
@@ -143,8 +164,10 @@ class UncountedLambdaCapturesChecker
143164
auto *CtorArg = CE->getArg(0)->IgnoreParenCasts();
144165
if (!CtorArg)
145166
return nullptr;
146-
if (auto *Lambda = dyn_cast<LambdaExpr>(CtorArg))
167+
if (auto *Lambda = dyn_cast<LambdaExpr>(CtorArg)) {
168+
ConstructToIgnore.insert(CE);
147169
return Lambda;
170+
}
148171
auto *DRE = dyn_cast<DeclRefExpr>(CtorArg);
149172
if (!DRE)
150173
return nullptr;
@@ -157,6 +180,7 @@ class UncountedLambdaCapturesChecker
157180
TempExpr = dyn_cast<CXXBindTemporaryExpr>(Init->IgnoreParenCasts());
158181
if (!TempExpr)
159182
return nullptr;
183+
ConstructToIgnore.insert(CE);
160184
return dyn_cast_or_null<LambdaExpr>(TempExpr->getSubExpr());
161185
}
162186

clang/test/Analysis/Checkers/WebKit/uncounted-lambda-captures.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,11 @@ struct RefCountableWithLambdaCapturingThis {
298298
callLambda([&]() -> RefPtr<RefCountable> {
299299
return obj->next();
300300
});
301+
WTF::HashMap<int, RefPtr<RefCountable>> anotherMap([&] {
302+
return obj->next();
303+
});
301304
}
305+
302306
};
303307

304308
struct NonRefCountableWithLambdaCapturingThis {

clang/test/Analysis/Checkers/WebKit/uncounted-obj-arg.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ T&& forward(T& arg);
7777
template<typename T>
7878
T&& move( T&& t );
7979

80+
#define offsetof(t, d) __builtin_offsetof(t, d)
81+
8082
} // namespace std
8183

8284
bool isMainThread();
@@ -373,6 +375,7 @@ class RefCounted {
373375
double y;
374376
};
375377
void trivial68() { point pt = { 1.0 }; }
378+
unsigned trivial69() { return offsetof(RefCounted, children); }
376379

377380
static RefCounted& singleton() {
378381
static RefCounted s_RefCounted;
@@ -560,6 +563,7 @@ class UnrelatedClass {
560563
getFieldTrivial().trivial66()->trivial6(); // no-warning
561564
getFieldTrivial().trivial67()->trivial6(); // no-warning
562565
getFieldTrivial().trivial68(); // no-warning
566+
getFieldTrivial().trivial69(); // no-warning
563567

564568
RefCounted::singleton().trivial18(); // no-warning
565569
RefCounted::singleton().someFunction(); // no-warning
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
// RUN: %clang -target dxil-pc-shadermodel6.0-pixel -S -emit-llvm -o - %s | FileCheck %s
2-
// RUN: %clang -target dxil-pc-shadermodel6.0-vertex -S -emit-llvm -o - %s | FileCheck %s
3-
// RUN: %clang -target dxil-pc-shadermodel6.0-compute -S -emit-llvm -o - %s | FileCheck %s
4-
// RUN: %clang -target dxil-pc-shadermodel6.0-library -S -emit-llvm -o - %s | FileCheck %s
5-
// RUN: %clang -target dxil-pc-shadermodel6.0-hull -S -emit-llvm -o - %s | FileCheck %s
6-
// RUN: %clang -target dxil-pc-shadermodel6.0-domain -S -emit-llvm -o - %s | FileCheck %s
7-
// RUN: %clang -target dxil-pc-shadermodel6.0-geometry -S -emit-llvm -o - %s | FileCheck %s
1+
// RUN: %clang -cc1 -triple dxil-pc-shadermodel6.0-pixel -emit-llvm -o - %s | FileCheck %s
2+
// RUN: %clang -cc1 -triple dxil-pc-shadermodel6.0-vertex -emit-llvm -o - %s | FileCheck %s
3+
// RUN: %clang -cc1 -triple dxil-pc-shadermodel6.0-compute -emit-llvm -o - %s | FileCheck %s
4+
// RUN: %clang -cc1 -triple dxil-pc-shadermodel6.0-library -emit-llvm -o - %s | FileCheck %s
5+
// RUN: %clang -cc1 -triple dxil-pc-shadermodel6.0-hull -emit-llvm -o - %s | FileCheck %s
6+
// RUN: %clang -cc1 -triple dxil-pc-shadermodel6.0-domain -emit-llvm -o - %s | FileCheck %s
7+
// RUN: %clang -cc1 -triple dxil-pc-shadermodel6.0-geometry -emit-llvm -o - %s | FileCheck %s
88

99
// CHECK: target datalayout = "e-m:e-p:32:32-i1:32-i8:8-i16:16-i32:32-i64:64-f16:16-f32:32-f64:64-n8:16:32:64"
1010
// CHECK: target triple = "dxilv1.0-pc-shadermodel6.0-{{[a-z]+}}"

libc/utils/hdrgen/header.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,12 @@
2424
"ptr",
2525
]
2626

27-
COMPILER_HEADER_TYPES = (
28-
{
29-
"bool": "<stdbool.h>",
30-
"va_list": "<stdarg.h>",
31-
}
32-
| {f"int{size}_t": "<stdint.h>" for size in STDINT_SIZES}
33-
| {f"uint{size}_t": "<stdint.h>" for size in STDINT_SIZES}
34-
)
27+
COMPILER_HEADER_TYPES = {
28+
"bool": "<stdbool.h>",
29+
"va_list": "<stdarg.h>",
30+
}
31+
COMPILER_HEADER_TYPES.update({f"int{size}_t": "<stdint.h>" for size in STDINT_SIZES})
32+
COMPILER_HEADER_TYPES.update({f"uint{size}_t": "<stdint.h>" for size in STDINT_SIZES})
3533

3634
NONIDENTIFIER = re.compile("[^a-zA-Z0-9_]+")
3735

llvm/utils/count_running_jobs.py

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

0 commit comments

Comments
 (0)