[clang] e441363 - Fix a crash introduced by 3d5e9ab by adding a nullptr check. (#90301)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 29 09:27:05 PDT 2024
Author: Ryosuke Niwa
Date: 2024-04-29T09:27:01-07:00
New Revision: e441363f7da2da50449917f17ab4ed412f9e7cb3
URL: https://github.com/llvm/llvm-project/commit/e441363f7da2da50449917f17ab4ed412f9e7cb3
DIFF: https://github.com/llvm/llvm-project/commit/e441363f7da2da50449917f17ab4ed412f9e7cb3.diff
LOG: Fix a crash introduced by 3d5e9ab by adding a nullptr check. (#90301)
Added:
clang/test/Analysis/Checkers/WebKit/call-args-regression-traverse-decl-crash.cpp
Modified:
clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedCallArgsChecker.cpp
Removed:
################################################################################
diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedCallArgsChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedCallArgsChecker.cpp
index 741f336761589f..ae494de58da3da 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedCallArgsChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedCallArgsChecker.cpp
@@ -53,10 +53,11 @@ class UncountedCallArgsChecker
bool shouldVisitTemplateInstantiations() const { return true; }
bool shouldVisitImplicitCode() const { return false; }
- bool TraverseDecl(Decl *D) {
- if (isa<ClassTemplateDecl>(D) && isRefType(safeGetName(D)))
+ bool TraverseClassTemplateDecl(ClassTemplateDecl *Decl) {
+ if (isRefType(safeGetName(Decl)))
return true;
- return RecursiveASTVisitor<LocalVisitor>::TraverseDecl(D);
+ return RecursiveASTVisitor<LocalVisitor>::TraverseClassTemplateDecl(
+ Decl);
}
bool VisitCallExpr(const CallExpr *CE) {
diff --git a/clang/test/Analysis/Checkers/WebKit/call-args-regression-traverse-decl-crash.cpp b/clang/test/Analysis/Checkers/WebKit/call-args-regression-traverse-decl-crash.cpp
new file mode 100644
index 00000000000000..3d8e822025f62b
--- /dev/null
+++ b/clang/test/Analysis/Checkers/WebKit/call-args-regression-traverse-decl-crash.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.webkit.UncountedCallArgsChecker -verify %s
+// expected-no-diagnostics
+
+template <class Class> struct T;
+template <template <class> class Class, class Type>
+struct T<Class<Type>>
+{ };
More information about the cfe-commits
mailing list