[PATCH] D135965: [analyzer] Move unexecuted test block into it's own source file
Domján Dániel via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 20 05:15:09 PDT 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rGea8aebf9eb7f: [analyzer] Move unexecuted test block into it's own source file (authored by isuckatcs).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D135965/new/
https://reviews.llvm.org/D135965
Files:
clang/test/Analysis/lambdas-modern.cpp
clang/test/Analysis/lambdas.cpp
Index: clang/test/Analysis/lambdas.cpp
===================================================================
--- clang/test/Analysis/lambdas.cpp
+++ clang/test/Analysis/lambdas.cpp
@@ -205,29 +205,6 @@
clang_analyzer_eval(i == 7); // expected-warning{{TRUE}}
}
-#if __cplusplus >= 201402L
-// Capture copy elided object.
-
-struct Elided{
- int x = 0;
- Elided(int) {}
-};
-
-void testCopyElidedObjectCaptured(int x) {
- [e = Elided(x)] {
- clang_analyzer_eval(e.x == 0); // expected-warning{{TRUE}}
- }();
-}
-
-static auto MakeUniquePtr() { return std::make_unique<std::vector<int>>(); }
-
-void testCopyElidedUniquePtr() {
- [uniquePtr = MakeUniquePtr()] {}();
- clang_analyzer_warnIfReached(); // expected-warning{{TRUE}}
-}
-
-#endif
-
// Test inline defensive checks
int getNum();
Index: clang/test/Analysis/lambdas-modern.cpp
===================================================================
--- /dev/null
+++ clang/test/Analysis/lambdas-modern.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_analyze_cc1 -std=c++14 -analyzer-checker=core,debug.ExprInspection -analyzer-config inline-lambdas=true -verify %s
+// RUN: %clang_analyze_cc1 -std=c++17 -analyzer-checker=core,debug.ExprInspection -analyzer-config inline-lambdas=true -verify %s
+
+#include "Inputs/system-header-simulator-cxx.h"
+
+void clang_analyzer_warnIfReached();
+void clang_analyzer_eval(int);
+
+// Capture copy elided object.
+struct Elided{
+ int x = 14;
+ Elided(int) {}
+};
+
+void testCopyElidedObjectCaptured(int x) {
+ int r = [e = Elided(x)] {
+ return e.x;
+ }();
+
+ clang_analyzer_eval(r == 14); // expected-warning{{TRUE}}
+}
+
+static auto MakeUniquePtr() { return std::make_unique<std::vector<int>>(); }
+
+void testCopyElidedUniquePtr() {
+ [uniquePtr = MakeUniquePtr()] {}();
+ clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D135965.469177.patch
Type: text/x-patch
Size: 1858 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221020/d6afbc79/attachment.bin>
More information about the cfe-commits
mailing list