-
Notifications
You must be signed in to change notification settings - Fork 13.4k
[WebKit Checkers] Make TrivialFunctionAnalysis recognize std::array::operator[] as trivial #113377
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+47
−1
Conversation
This file contains hidden or 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
@llvm/pr-subscribers-clang-static-analyzer-1 @llvm/pr-subscribers-clang Author: Rashmi Mudduluru (t-rasmud) ChangesTFA wasn't recognizing Full diff: https://github.com/llvm/llvm-project/pull/113377.diff 2 Files Affected:
diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
index e043806eadd6ac..71440e6d08a1c9 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
@@ -414,7 +414,8 @@ class TrivialFunctionAnalysisVisitor
Name == "isMainThreadOrGCThread" || Name == "isMainRunLoop" ||
Name == "isWebThread" || Name == "isUIThread" ||
Name == "mayBeGCThread" || Name == "compilerFenceForCrash" ||
- Name == "bitwise_cast" || Name.find("__builtin") == 0)
+ Name == "bitwise_cast" || Name.find("__builtin") == 0 ||
+ Name == "__libcpp_verbose_abort")
return true;
return IsFunctionTrivial(Callee);
diff --git a/clang/test/Analysis/Checkers/WebKit/uncounted-obj-arg-std-array.cpp b/clang/test/Analysis/Checkers/WebKit/uncounted-obj-arg-std-array.cpp
new file mode 100644
index 00000000000000..43c76c0b0793a8
--- /dev/null
+++ b/clang/test/Analysis/Checkers/WebKit/uncounted-obj-arg-std-array.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.webkit.UncountedCallArgsChecker -verify %s
+// expected-no-diagnostics
+
+#include "mock-types.h"
+
+using size_t = __typeof(sizeof(int));
+namespace std{
+template <class T, size_t N>
+class array {
+ T elements[N];
+
+ public:
+ T& operator[](unsigned i) { return elements[i]; }
+ constexpr const T* data() const noexcept {
+ return elements;
+ }
+
+};
+}
+
+class ArrayClass {
+public:
+ typedef std::array<std::array<double, 4>, 4> Matrix;
+ double e() { return matrix[3][0]; }
+ Matrix matrix;
+};
+
+class AnotherClass {
+ Ref<ArrayClass> matrix;
+ void test() {
+ double val[] = { matrix->e(), matrix->e() };
+ }
+};
|
rniwa
reviewed
Oct 22, 2024
clang/test/Analysis/Checkers/WebKit/uncounted-obj-arg-std-array.cpp
Outdated
Show resolved
Hide resolved
rniwa
reviewed
Oct 24, 2024
rniwa
reviewed
Oct 24, 2024
rniwa
approved these changes
Oct 24, 2024
Loading status checks…
…operator[] as trivial TFA wasn't recognizing `__libcpp_verbose_abort` as trivial causing `std::array::operator[]` also not being recongnized as trivial.
209612d
to
0374a38
Compare
Closed
NoumanAmir657
pushed a commit
to NoumanAmir657/llvm-project
that referenced
this pull request
Nov 4, 2024
…operator[] as trivial (llvm#113377) TFA wasn't recognizing `__libcpp_verbose_abort` as trivial causing `std::array::operator[]` also not being recognized as trivial.
rniwa
pushed a commit
to rniwa/llvm-project
that referenced
this pull request
Feb 3, 2025
…operator[] as trivial (llvm#113377) TFA wasn't recognizing `__libcpp_verbose_abort` as trivial causing `std::array::operator[]` also not being recognized as trivial.
devincoughlin
pushed a commit
to swiftlang/llvm-project
that referenced
this pull request
Feb 25, 2025
…operator[] as trivial (llvm#113377) TFA wasn't recognizing `__libcpp_verbose_abort` as trivial causing `std::array::operator[]` also not being recognized as trivial.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
TFA wasn't recognizing
__libcpp_verbose_abort
as trivial causingstd::array::operator[]
also not being recongnized as trivial.