]> granicus.if.org Git - clang/commitdiff
PathDiagnostics:
authorTed Kremenek <kremenek@apple.com>
Tue, 27 Jan 2009 01:53:39 +0000 (01:53 +0000)
committerTed Kremenek <kremenek@apple.com>
Tue, 27 Jan 2009 01:53:39 +0000 (01:53 +0000)
- Add the distinction between the 'bug type' and the 'bug description'

HTMLDiagnostics:
- Output the bug type field as HTML comments

scan-build:
- Use the bug type field instead of the bug description for the HTML table.
- Radar filing now automatically picks up the bug description in the title (addresses <rdar://problem/6265970>)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63084 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Analysis/PathDiagnostic.h
lib/Analysis/BugReporter.cpp
lib/Driver/HTMLDiagnostics.cpp
utils/scan-build

index bedc6da40f7fb00d4440e1fc0119899c97f308ef..bc68ac59116f933023132fc76858e063c9bb6fd7 100644 (file)
@@ -78,20 +78,23 @@ class PathDiagnostic {
   unsigned Size;
   std::string Desc;
   std::string Category;
+  std::string BugType;
   std::vector<std::string> OtherDesc;
 
 public:  
   PathDiagnostic() : Size(0) {}
 
-  PathDiagnostic(const char* desc, const char* category)
-    : Size(0), Desc(desc), Category(category) {}
+  PathDiagnostic(const char* bugtype, const char* desc, const char* category)
+    : Size(0), Desc(desc), Category(category), BugType(bugtype) {}
   
-  PathDiagnostic(const std::string& desc, const std::string& category)
-    : Size(0), Desc(desc), Category(category) {}
+  PathDiagnostic(const std::string& bugtype, const std::string& desc, 
+                 const std::string& category)
+    : Size(0), Desc(desc), Category(category), BugType(bugtype) {}
   
   ~PathDiagnostic();
 
   const std::string& getDescription() const { return Desc; }
+  const std::string& getBugType() const { return BugType; }
   const std::string& getCategory() const { return Category; }
   
   typedef std::vector<std::string>::const_iterator meta_iterator;
index b08f5cb793e37d7a115a3f15ee3ee44f06364a66..f59f89a1a82e7f5d8041743609572b11315ef6e3 100644 (file)
@@ -727,6 +727,7 @@ void BugReporter::EmitWarning(BugReport& R) {
     return;
 
   llvm::OwningPtr<PathDiagnostic> D(new PathDiagnostic(R.getName(),
+                                                       R.getDescription(),
                                                        R.getCategory()));
   GeneratePathDiagnostic(*D.get(), R);
   
index 2772cf34226838b8a84c2cdad029673b7c1703a7..6b60588ca56cf5f3fa403966d8e78a72f7776018 100644 (file)
@@ -246,6 +246,14 @@ void HTMLDiagnostics::ReportDiag(const PathDiagnostic& D) {
     R.InsertStrBefore(SMgr.getLocForStartOfFile(FID), os.str());
   }
   
+  const std::string& BugType = D.getBugType();
+  if (!BugType.empty()) {
+    std::string s;
+    llvm::raw_string_ostream os(s);
+    os << "\n<!-- BUGTYPE " << BugType << " -->\n";
+    R.InsertStrBefore(SMgr.getLocForStartOfFile(FID), os.str());
+  }
+  
   const std::string& BugCategory = D.getCategory();
   
   if (!BugCategory.empty()) {
index 44f0cbc64177c85ca1373d00ef5c9da76f102527..39b9ede93916e7c3379ebb17f48b2ee201d358f8 100755 (executable)
@@ -350,7 +350,7 @@ sub ScanFile {
   # Scan the report file for tags.
   open(IN, "$Dir/$FName") or DieDiag("Cannot open '$Dir/$FName'\n");
 
-  my $BugDesc = "";
+  my $BugType = "";
   my $BugFile = "";
   my $BugCategory;
   my $BugPathLength = 1;
@@ -361,8 +361,8 @@ sub ScanFile {
 
     last if ($found == 5);
 
-    if (/<!-- BUGDESC (.*) -->$/) {
-      $BugDesc = $1;
+    if (/<!-- BUGTYPE (.*) -->$/) {
+      $BugType = $1;
       ++$found;
     }
     elsif (/<!-- BUGFILE (.*) -->$/) {
@@ -390,7 +390,7 @@ sub ScanFile {
     $BugCategory = "Other";
   }
     
-  push @$Index,[ $FName, $BugCategory, $BugDesc, $BugFile, $BugLine,
+  push @$Index,[ $FName, $BugCategory, $BugType, $BugFile, $BugLine,
                  $BugPathLength ];
 }