[PATCH] D66565: [analyzer] pr43036: Fix support for operator `sizeof...'.
Artem Dergachev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 21 16:20:53 PDT 2019
NoQ created this revision.
NoQ added reviewers: dcoughlin, xazax.hun, a_sidorin, rnkovacs, Szelethus, baloghadamsoftware, Charusso.
Herald added subscribers: cfe-commits, dkrupp, donat.nagy, mikhail.ramalho, a.sidorin, szepet.
Herald added a project: clang.
A tiny fix for https://bugs.llvm.org/show_bug.cgi?id=43036 . We should probably double-check other fancy compile-time expressions.
Repository:
rC Clang
https://reviews.llvm.org/D66565
Files:
clang/lib/StaticAnalyzer/Core/Environment.cpp
clang/test/Analysis/sizeofpack.cpp
Index: clang/test/Analysis/sizeofpack.cpp
===================================================================
--- /dev/null
+++ clang/test/Analysis/sizeofpack.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection \
+// RUN: -verify %s
+
+typedef __typeof(sizeof(int)) size_t;
+
+void clang_analyzer_eval(bool);
+
+template <int... N> size_t foo() {
+ return sizeof...(N);
+}
+
+void bar() {
+ clang_analyzer_eval(foo<>() == 0); // expected-warning{{TRUE}}
+ clang_analyzer_eval(foo<1, 2, 3>() == 3); // expected-warning{{TRUE}}
+}
Index: clang/lib/StaticAnalyzer/Core/Environment.cpp
===================================================================
--- clang/lib/StaticAnalyzer/Core/Environment.cpp
+++ clang/lib/StaticAnalyzer/Core/Environment.cpp
@@ -108,6 +108,7 @@
case Stmt::ObjCStringLiteralClass:
case Stmt::StringLiteralClass:
case Stmt::TypeTraitExprClass:
+ case Stmt::SizeOfPackExprClass:
// Known constants; defer to SValBuilder.
return svalBuilder.getConstantVal(cast<Expr>(S)).getValue();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66565.216517.patch
Type: text/x-patch
Size: 1089 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190821/3191789d/attachment-0001.bin>
More information about the cfe-commits
mailing list