[PATCH] D77411: [analyzer] StdLibraryFunctionsChecker: Add test for function with default parameter
Gabor Marton via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 6 08:39:04 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rGab1fad8a3a8b: [analyzer] StdLibraryFunctionsChecker: Add test for function with default… (authored by martong).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D77411/new/
https://reviews.llvm.org/D77411
Files:
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
clang/test/Analysis/std-c-library-functions-arg-constraints.cpp
Index: clang/test/Analysis/std-c-library-functions-arg-constraints.cpp
===================================================================
--- /dev/null
+++ clang/test/Analysis/std-c-library-functions-arg-constraints.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_analyze_cc1 %s \
+// RUN: -analyzer-checker=core \
+// RUN: -analyzer-checker=apiModeling.StdCLibraryFunctions \
+// RUN: -analyzer-checker=apiModeling.StdCLibraryFunctionArgs \
+// RUN: -analyzer-checker=debug.StdCLibraryFunctionsTester \
+// RUN: -analyzer-checker=debug.ExprInspection \
+// RUN: -analyzer-config eagerly-assume=false \
+// RUN: -triple i686-unknown-linux \
+// RUN: -verify
+
+void clang_analyzer_eval(int);
+
+int __defaultparam(void *, int y = 3);
+
+void test_arg_constraint_on_fun_with_default_param() {
+ __defaultparam(nullptr); // \
+ // expected-warning{{Function argument constraint is not satisfied}}
+}
Index: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
===================================================================
--- clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -960,6 +960,9 @@
ArgumentCondition(0U, OutOfRange, SingleValue(1)))
.ArgConstraint(
ArgumentCondition(0U, OutOfRange, SingleValue(2)))}},
+ {"__defaultparam", Summaries{Summary(ArgTypes{Irrelevant, IntTy},
+ RetType{IntTy}, EvalCallAsPure)
+ .ArgConstraint(NotNull(ArgNo(0)))}},
};
for (auto &E : TestFunctionSummaryMap) {
auto InsertRes =
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77411.255356.patch
Type: text/x-patch
Size: 1715 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200406/b209b910/attachment-0001.bin>
More information about the cfe-commits
mailing list