Consume checker names from clang static analyzer.
authorAlexander Kornienko <alexfh@google.com>
Wed, 12 Feb 2014 09:52:07 +0000 (09:52 +0000)
committerAlexander Kornienko <alexfh@google.com>
Wed, 12 Feb 2014 09:52:07 +0000 (09:52 +0000)
Summary: This patch depends on patches D2556 and D2557.

Reviewers: klimek

Reviewed By: klimek

CC: cfe-commits, jordan_rose, krememek
Differential Revision: http://llvm-reviews.chandlerc.com/D2620

llvm-svn: 201221

clang-tools-extra/clang-tidy/ClangTidy.cpp
clang-tools-extra/test/clang-tidy/static-analyzer.cpp

index f78953f..aec2d98 100644 (file)
@@ -71,7 +71,8 @@ public:
                                                              E = Diags.end();
          I != E; ++I) {
       const ento::PathDiagnostic *PD = *I;
-      StringRef CheckName(AnalyzerCheckNamePrefix);
+      SmallString<64> CheckName(AnalyzerCheckNamePrefix);
+      CheckName += PD->getCheckName();
       addRanges(Context.diag(CheckName, PD->getLocation().asLocation(),
                              PD->getShortDescription()),
                 PD->path.back()->getRanges());
index 8e14773..66f56c7 100644 (file)
@@ -1,8 +1,17 @@
-// RUN: clang-tidy %s -checks='clang-analyzer-cplusplus' -- | FileCheck %s
+// RUN: clang-tidy %s -checks='clang-analyzer-' -- | FileCheck %s
+extern void *malloc(unsigned long);
+extern void free(void *);
 
 void f() {
   int *p = new int(42);
   delete p;
   delete p;
-  // CHECK: warning: Attempt to free released memory
+  // CHECK: warning: Attempt to free released memory [clang-analyzer-cplusplus.NewDelete]
+}
+
+void g() {
+  void *q = malloc(132);
+  free(q);
+  free(q);
+  // CHECK: warning: Attempt to free released memory [clang-analyzer-unix.Malloc]
 }