tomasz-kaminski-sonarsource updated this revision to Diff 346700.
tomasz-kaminski-sonarsource added a comment.
Removed duplicated runs that were only differing by specifying
c++-allocator-inlinging=true, which is the default value.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D102835/new/
https://reviews.llvm.org/D102835
Files:
clang/lib/Analysis/CFG.cpp
clang/test/Analysis/NewDelete-checker-test.cpp
clang/test/Analysis/NewDelete-path-notes.cpp
clang/test/Analysis/NewDeleteLeaks-PR19102.cpp
Index: clang/test/Analysis/NewDeleteLeaks-PR19102.cpp
===================================================================
--- clang/test/Analysis/NewDeleteLeaks-PR19102.cpp
+++ clang/test/Analysis/NewDeleteLeaks-PR19102.cpp
@@ -1,5 +1,4 @@
// RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus.NewDeleteLeaks -verify %s
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus.NewDeleteLeaks -analyzer-config c++-allocator-inlining=true -verify %s
class A0 {};
Index: clang/test/Analysis/NewDelete-path-notes.cpp
===================================================================
--- clang/test/Analysis/NewDelete-path-notes.cpp
+++ clang/test/Analysis/NewDelete-path-notes.cpp
@@ -4,11 +4,6 @@
// RUN: -analyzer-output=text -verify %s
// RUN: %clang_analyze_cc1 \
// RUN: -analyzer-checker=cplusplus.NewDelete,unix.Malloc \
-// RUN: -analyzer-config c++-allocator-inlining=true \
-// RUN: -analyzer-config add-pop-up-notes=false \
-// RUN: -analyzer-output=text -verify %s
-// RUN: %clang_analyze_cc1 \
-// RUN: -analyzer-checker=cplusplus.NewDelete,unix.Malloc \
// RUN: -analyzer-config add-pop-up-notes=false \
// RUN: -analyzer-output=plist %s -o %t.plist
// RUN: %normalize_plist <%t.plist | diff -ub \
Index: clang/test/Analysis/NewDelete-checker-test.cpp
===================================================================
--- clang/test/Analysis/NewDelete-checker-test.cpp
+++ clang/test/Analysis/NewDelete-checker-test.cpp
@@ -9,20 +9,23 @@
// RUN: -analyzer-checker=cplusplus.NewDelete \
// RUN: -analyzer-checker=cplusplus.NewDeleteLeaks
//
-// RUN: %clang_analyze_cc1 -std=c++11 -fblocks %s \
+// RUN: %clang_analyze_cc1 -std=c++11 -fblocks -verify %s \
+// RUN: -verify=expected,leak \
+// RUN: -analyzer-checker=core \
+// RUN: -analyzer-checker=cplusplus.NewDeleteLeaks
+//
+// RUN: %clang_analyze_cc1 -std=c++17 -fblocks %s \
// RUN: -verify=expected,newdelete \
// RUN: -analyzer-checker=core \
-// RUN: -analyzer-checker=cplusplus.NewDelete \
-// RUN: -analyzer-config c++-allocator-inlining=true
+// RUN: -analyzer-checker=cplusplus.NewDelete
//
-// RUN: %clang_analyze_cc1 -std=c++11 -fblocks -verify %s \
+// RUN: %clang_analyze_cc1 -DLEAKS -std=c++17 -fblocks %s \
// RUN: -verify=expected,newdelete,leak \
// RUN: -analyzer-checker=core \
// RUN: -analyzer-checker=cplusplus.NewDelete \
-// RUN: -analyzer-checker=cplusplus.NewDeleteLeaks \
-// RUN: -analyzer-config c++-allocator-inlining=true
+// RUN: -analyzer-checker=cplusplus.NewDeleteLeaks
//
-// RUN: %clang_analyze_cc1 -std=c++11 -fblocks -verify %s \
+// RUN: %clang_analyze_cc1 -std=c++17 -fblocks -verify %s \
// RUN: -verify=expected,leak \
// RUN: -analyzer-checker=core \
// RUN: -analyzer-checker=cplusplus.NewDeleteLeaks
@@ -288,7 +291,7 @@
explicit shared_ptr(T *p) : p(p), control(new control_block) {
control->retain();
}
- shared_ptr(shared_ptr &other) : p(other.p), control(other.control) {
+ shared_ptr(const shared_ptr &other) : p(other.p), control(other.control) {
if (control)
control->retain();
}
@@ -314,11 +317,26 @@
}
};
+ template <typename T, typename... Args>
+ shared_ptr<T> make_shared(Args &&...args) {
+ return shared_ptr<T>(new T(static_cast<Args &&>(args)...));
+ }
+
void testSingle() {
shared_ptr<int> a(new int);
*a = 1;
}
+ void testMake() {
+ shared_ptr<int> a = make_shared<int>();
+ *a = 1;
+ }
+
+ void testMakeInParens() {
+ shared_ptr<int> a = (make_shared<int>()); // no warn
+ *a = 1;
+ }
+
void testDouble() {
shared_ptr<int> a(new int);
shared_ptr<int> b = a;
Index: clang/lib/Analysis/CFG.cpp
===================================================================
--- clang/lib/Analysis/CFG.cpp
+++ clang/lib/Analysis/CFG.cpp
@@ -1456,6 +1456,13 @@
// TODO: Handle other cases. For now, fail to find construction contexts.
break;
}
+ case Stmt::ParenExprClass: {
+ // If expression is placed into parenthesis we should propagate the parent
+ // construction context to subexpressions.
+ auto *PE = cast<ParenExpr>(Child);
+ findConstructionContexts(Layer, PE->getSubExpr());
+ break;
+ }
default:
break;
}
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits