Bug 1475882 - Enable clang-tidy's clang-analyzer-cplusplus.NewDeleteLeaks check. r?andi draft
authorChris Peterson <cpeterson@mozilla.com>
Sat, 14 Jul 2018 23:10:39 -0700
changeset 818601 3389fb54d2e3daee38db38503b37e9d994878bcd
parent 818600 778684b276e6658fb9f3fa125aaec984cca8760a
child 818602 0a56233793c6a2ae0cdfbf40ec89a586a7a278ab
child 819042 348e071ba1af575a3228459e779697c0e71520ca
push id116287
push usercpeterson@mozilla.com
push dateSun, 15 Jul 2018 21:59:08 +0000
reviewersandi
bugs1475882
milestone63.0a1
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
tools/clang-tidy/config.yaml
tools/clang-tidy/test/clang-analyzer-cplusplus.NewDeleteLeaks.cpp
tools/clang-tidy/test/clang-analyzer-cplusplus.NewDeleteLeaks.json
--- 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