[PATCH] Add a clang-tidy flag to support temporary destructor-aware analysis (workaround for bug 15599).

Alex McCarthy alexmc at google.com
Wed Apr 30 07:00:29 PDT 2014


Submitting now.

================
Comment at: clang-tidy/ClangTidy.h:116
@@ -114,2 +115,3 @@
   std::unique_ptr<ClangTidyCheckFactories> CheckFactories;
+  const ClangTidyOptions &Options;
 };
----------------
Alexander Kornienko wrote:
> I'd not make any assumptions about the life-time of Options. Please just copy it here, not store a reference.
Done.

================
Comment at: test/clang-tidy/temporaries.cpp:1
@@ +1,2 @@
+// RUN: clang-tidy -checks=clang-analyzer-core.NullDereference -analyze-temporary-dtors %s -- > %t.log
+// FileCheck complains if the input file is empty, so add a dummy line.
----------------
Alexander Kornienko wrote:
> Add -disable-checks='', so that we don't rely on its default value.
Done.

================
Comment at: test/clang-tidy/temporaries.cpp:2
@@ +1,3 @@
+// RUN: clang-tidy -checks=clang-analyzer-core.NullDereference -analyze-temporary-dtors %s -- > %t.log
+// FileCheck complains if the input file is empty, so add a dummy line.
+// RUN: echo foo >> %t.log
----------------
Alexander Kornienko wrote:
> Could you instead add test code which actually generates a core.NullDereference warning, so that we can be sure it's not just completely disabled.
> 
>   // CHECK-NOT: warning
>   void testNullPointerDereferencePositive() {
>     int *value = 0;
>     // CHECK: :[[@LINE+1]]:3: warning: .....
>     *value = 1;
>   }
> 
>   // CHECK-NOT: warning
>   <the rest of your test case>
Done.

http://reviews.llvm.org/D3556






More information about the cfe-commits mailing list