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] Make TrivialFunctionAnalysis recognize std::array::…
…operator[] as trivial (llvm#113377) TFA wasn't recognizing `__libcpp_verbose_abort` as trivial causing `std::array::operator[]` also not being recognized as trivial.
- Loading branch information
Showing
3 changed files
with
47 additions
and
1 deletion.
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
39 changes: 39 additions & 0 deletions
39
clang/test/Analysis/Checkers/WebKit/uncounted-obj-arg-std-array.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,39 @@ | ||
// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.webkit.UncountedCallArgsChecker -verify %s | ||
// expected-no-diagnostics | ||
|
||
#include "mock-types.h" | ||
|
||
void __libcpp_verbose_abort(const char *__format, ...); | ||
|
||
using size_t = __typeof(sizeof(int)); | ||
namespace std{ | ||
template <class T, size_t N> | ||
class array { | ||
T elements[N]; | ||
|
||
public: | ||
T& operator[](unsigned i) { | ||
if (i >= N) { | ||
__libcpp_verbose_abort("%s", "aborting"); | ||
} | ||
return elements[i]; | ||
} | ||
}; | ||
} | ||
|
||
class ArrayClass { | ||
public: | ||
void ref() const; | ||
void deref() const; | ||
typedef std::array<std::array<double, 4>, 4> Matrix; | ||
double e() { return matrix[3][0]; } | ||
Matrix matrix; | ||
}; | ||
|
||
class AnotherClass { | ||
RefPtr<ArrayClass> matrix; | ||
void test() { | ||
double val = { matrix->e()}; | ||
} | ||
}; | ||
|
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