forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WebKit Checkers] Allow a guardian CheckedPtr/CheckedRef (llvm#110222)
This PR makes WebKit checkers allow a guardian variable which is CheckedPtr or CheckedRef as in addition to RefPtr or Ref.
- Loading branch information
Showing
8 changed files
with
177 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.webkit.UncountedCallArgsChecker -verify %s | ||
|
||
#include "mock-types.h" | ||
|
||
RefCountableAndCheckable* makeObj(); | ||
CheckedRef<RefCountableAndCheckable> makeObjChecked(); | ||
void someFunction(RefCountableAndCheckable*); | ||
|
||
namespace call_args_unchecked_uncounted { | ||
|
||
static void foo() { | ||
someFunction(makeObj()); | ||
// expected-warning@-1{{Call argument is uncounted and unsafe [alpha.webkit.UncountedCallArgsChecker]}} | ||
} | ||
|
||
} // namespace call_args_checked | ||
|
||
namespace call_args_checked { | ||
|
||
static void foo() { | ||
CheckedPtr<RefCountableAndCheckable> ptr = makeObj(); | ||
someFunction(ptr.get()); | ||
} | ||
|
||
static void bar() { | ||
someFunction(CheckedPtr { makeObj() }.get()); | ||
} | ||
|
||
static void baz() { | ||
someFunction(makeObjChecked().ptr()); | ||
} | ||
|
||
} // namespace call_args_checked | ||
|
||
namespace call_args_default { | ||
|
||
void someFunction(RefCountableAndCheckable* = makeObj()); | ||
// expected-warning@-1{{Call argument is uncounted and unsafe [alpha.webkit.UncountedCallArgsChecker]}} | ||
void otherFunction(RefCountableAndCheckable* = makeObjChecked().ptr()); | ||
|
||
void foo() { | ||
someFunction(); | ||
otherFunction(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters