-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[analyzer] Allow default arguments to be evaluated like other argumen…
…ts. (#80956) This PR aligns the evaluation of default arguments with other kinds of arguments by extracting the expressions within them as argument values to be evaluated.
- Loading branch information
Showing
2 changed files
with
28 additions
and
0 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
25 changes: 25 additions & 0 deletions
25
clang/test/Analysis/Checkers/WebKit/ref-countable-default-arg-nullptr.cpp
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,25 @@ | ||
// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.webkit.UncountedCallArgsChecker -verify %s | ||
|
||
#include "mock-types.h" | ||
|
||
class Obj { | ||
public: | ||
static Obj* get(); | ||
static RefPtr<Obj> create(); | ||
void ref() const; | ||
void deref() const; | ||
}; | ||
|
||
void someFunction(Obj*, Obj* = nullptr); | ||
void otherFunction(Obj*, Obj* = Obj::get()); | ||
// expected-warning@-1{{Call argument is uncounted and unsafe [alpha.webkit.UncountedCallArgsChecker]}} | ||
void anotherFunction(Obj*, Obj* = Obj::create().get()); | ||
|
||
void otherFunction() { | ||
someFunction(nullptr); | ||
someFunction(Obj::get()); | ||
// expected-warning@-1{{Call argument is uncounted and unsafe [alpha.webkit.UncountedCallArgsChecker]}} | ||
someFunction(Obj::create().get()); | ||
otherFunction(nullptr); | ||
anotherFunction(nullptr); | ||
} |