-
Notifications
You must be signed in to change notification settings - Fork 13.4k
[webkit.UncountedLambdaCapturesChecker] Fix debug assertion failure. #117090
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
[webkit.UncountedLambdaCapturesChecker] Fix debug assertion failure. #117090
Conversation
Only call getThisType() on an instance method.
@llvm/pr-subscribers-clang Author: Ryosuke Niwa (rniwa) ChangesOnly call getThisType() on an instance method. Full diff: https://github.com/llvm/llvm-project/pull/117090.diff 2 Files Affected:
diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedLambdaCapturesChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedLambdaCapturesChecker.cpp
index 3fb763e72e6809..9312bf0af16dbf 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedLambdaCapturesChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedLambdaCapturesChecker.cpp
@@ -51,7 +51,8 @@ class UncountedLambdaCapturesChecker
bool TraverseCXXMethodDecl(CXXMethodDecl *CXXMD) override {
llvm::SaveAndRestore SavedDecl(ClsType);
- ClsType = CXXMD->getThisType();
+ if (CXXMD && CXXMD->isInstance())
+ ClsType = CXXMD->getThisType();
return DynamicRecursiveASTVisitor::TraverseCXXMethodDecl(CXXMD);
}
diff --git a/clang/test/Analysis/Checkers/WebKit/uncounted-lambda-captures.cpp b/clang/test/Analysis/Checkers/WebKit/uncounted-lambda-captures.cpp
index 9bfcdea04755d2..b63ffed8809fef 100644
--- a/clang/test/Analysis/Checkers/WebKit/uncounted-lambda-captures.cpp
+++ b/clang/test/Analysis/Checkers/WebKit/uncounted-lambda-captures.cpp
@@ -1,5 +1,9 @@
// RUN: %clang_analyze_cc1 -analyzer-checker=webkit.UncountedLambdaCapturesChecker -verify %s
+struct A {
+ static void b();
+};
+
struct RefCountable {
void ref() {}
void deref() {}
|
@llvm/pr-subscribers-clang-static-analyzer-1 Author: Ryosuke Niwa (rniwa) ChangesOnly call getThisType() on an instance method. Full diff: https://github.com/llvm/llvm-project/pull/117090.diff 2 Files Affected:
diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedLambdaCapturesChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedLambdaCapturesChecker.cpp
index 3fb763e72e6809..9312bf0af16dbf 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedLambdaCapturesChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedLambdaCapturesChecker.cpp
@@ -51,7 +51,8 @@ class UncountedLambdaCapturesChecker
bool TraverseCXXMethodDecl(CXXMethodDecl *CXXMD) override {
llvm::SaveAndRestore SavedDecl(ClsType);
- ClsType = CXXMD->getThisType();
+ if (CXXMD && CXXMD->isInstance())
+ ClsType = CXXMD->getThisType();
return DynamicRecursiveASTVisitor::TraverseCXXMethodDecl(CXXMD);
}
diff --git a/clang/test/Analysis/Checkers/WebKit/uncounted-lambda-captures.cpp b/clang/test/Analysis/Checkers/WebKit/uncounted-lambda-captures.cpp
index 9bfcdea04755d2..b63ffed8809fef 100644
--- a/clang/test/Analysis/Checkers/WebKit/uncounted-lambda-captures.cpp
+++ b/clang/test/Analysis/Checkers/WebKit/uncounted-lambda-captures.cpp
@@ -1,5 +1,9 @@
// RUN: %clang_analyze_cc1 -analyzer-checker=webkit.UncountedLambdaCapturesChecker -verify %s
+struct A {
+ static void b();
+};
+
struct RefCountable {
void ref() {}
void deref() {}
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Thanks for the review! |
…lvm#117090) Only call getThisType() on an instance method.
…lvm#117090) Only call getThisType() on an instance method.
Only call getThisType() on an instance method.