File tree 2 files changed +31
-6
lines changed
lib/StaticAnalyzer/Checkers/WebKit
test/Analysis/Checkers/WebKit
2 files changed +31
-6
lines changed Original file line number Diff line number Diff line change @@ -285,15 +285,31 @@ class RawPtrRefLambdaCapturesChecker
285
285
do {
286
286
if (auto *BTE = dyn_cast<CXXBindTemporaryExpr>(Arg))
287
287
Arg = BTE->getSubExpr ()->IgnoreParenCasts ();
288
- if (auto *CE = dyn_cast_or_null <CXXConstructExpr>(Arg)) {
288
+ if (auto *CE = dyn_cast <CXXConstructExpr>(Arg)) {
289
289
auto *Ctor = CE->getConstructor ();
290
290
if (!Ctor)
291
291
return false ;
292
292
auto clsName = safeGetName (Ctor->getParent ());
293
- if (!isRefType (clsName) || !CE->getNumArgs ())
294
- return false ;
295
- Arg = CE->getArg (0 )->IgnoreParenCasts ();
296
- continue ;
293
+ if (isRefType (clsName) && CE->getNumArgs ()) {
294
+ Arg = CE->getArg (0 )->IgnoreParenCasts ();
295
+ continue ;
296
+ }
297
+ if (auto *Type = ClsType.getTypePtrOrNull ()) {
298
+ if (auto *CXXR = Type->getPointeeCXXRecordDecl ()) {
299
+ if (CXXR == Ctor->getParent () && Ctor->isMoveConstructor () &&
300
+ CE->getNumArgs () == 1 ) {
301
+ Arg = CE->getArg (0 )->IgnoreParenCasts ();
302
+ continue ;
303
+ }
304
+ }
305
+ }
306
+ return false ;
307
+ }
308
+ if (auto *CE = dyn_cast<CallExpr>(Arg)) {
309
+ if (CE->isCallToStdMove () && CE->getNumArgs () == 1 ) {
310
+ Arg = CE->getArg (0 )->IgnoreParenCasts ();
311
+ continue ;
312
+ }
297
313
}
298
314
if (auto *OpCE = dyn_cast<CXXOperatorCallExpr>(Arg)) {
299
315
auto OpCode = OpCE->getOperator ();
Original file line number Diff line number Diff line change 2
2
3
3
#include " mock-types.h"
4
4
5
+ namespace std {
6
+
7
+ template <typename T>
8
+ T&& move(T& t) {
9
+ return static_cast <T&&>(t);
10
+ }
11
+
12
+ }
13
+
5
14
namespace WTF {
6
15
7
16
namespace Detail {
@@ -321,7 +330,7 @@ struct RefCountableWithLambdaCapturingThis {
321
330
322
331
void method_nested_lambda2 () {
323
332
callAsync ([this , protectedThis = RefPtr { this }] {
324
- callAsync ([this , protectedThis = static_cast < const Ref<RefCountableWithLambdaCapturingThis>&&> (*protectedThis)] {
333
+ callAsync ([this , protectedThis = std::move (*protectedThis)] {
325
334
nonTrivial ();
326
335
});
327
336
});
You can’t perform that action at this time.
0 commit comments