Bug 1475882 - Enable clang-tidy's clang-analyzer-cplusplus.NewDeleteLeaks check. r?andi
Check for memory leaks. Traces memory managed by new/ delete. There are currently no clang-analyzer-cplusplus.NewDeleteLeaks warnings in mozilla-central!
https://clang-analyzer.llvm.org/available_checks.html
MozReview-Commit-ID: 3tmwR26UB8K
--- a/tools/clang-tidy/config.yaml
+++ b/tools/clang-tidy/config.yaml
@@ -8,16 +8,18 @@ platforms:
- linux64
- win64
- win32
clang_checkers:
- name: -*
publish: !!bool no
- name: clang-analyzer-cplusplus.NewDelete
publish: !!bool yes
+ - name: clang-analyzer-cplusplus.NewDeleteLeaks
+ publish: !!bool yes
- name: clang-analyzer-deadcode.DeadStores
publish: !!bool yes
- name: clang-analyzer-security.FloatLoopCounter
publish: !!bool yes
- name: clang-analyzer-security.insecureAPI.getpw
publish: !!bool yes
# We don't add clang-analyzer-security.insecureAPI.gets here; it's deprecated.
- name: clang-analyzer-security.insecureAPI.mkstemp
new file mode 100644
--- /dev/null
+++ b/tools/clang-tidy/test/clang-analyzer-cplusplus.NewDeleteLeaks.cpp
@@ -0,0 +1,6 @@
+// https://clang-analyzer.llvm.org/available_checks.html
+
+void test()
+{
+ int *p = new int;
+} // warning
new file mode 100644
--- /dev/null
+++ b/tools/clang-tidy/test/clang-analyzer-cplusplus.NewDeleteLeaks.json
@@ -0,0 +1,1 @@
+"[[\"warning\", \"Potential leak of memory pointed to by 'p'\", \"clang-analyzer-cplusplus.NewDeleteLeaks\"]]"
\ No newline at end of file