aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/clang/Analysis/PathDiagnostic.h11
-rw-r--r--lib/Analysis/BugReporter.cpp1
-rw-r--r--lib/Driver/HTMLDiagnostics.cpp8
-rwxr-xr-xutils/scan-build8
4 files changed, 20 insertions, 8 deletions
diff --git a/include/clang/Analysis/PathDiagnostic.h b/include/clang/Analysis/PathDiagnostic.h
index bedc6da40f..bc68ac5911 100644
--- a/include/clang/Analysis/PathDiagnostic.h
+++ b/include/clang/Analysis/PathDiagnostic.h
@@ -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;
diff --git a/lib/Analysis/BugReporter.cpp b/lib/Analysis/BugReporter.cpp
index b08f5cb793..f59f89a1a8 100644
--- a/lib/Analysis/BugReporter.cpp
+++ b/lib/Analysis/BugReporter.cpp
@@ -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);
diff --git a/lib/Driver/HTMLDiagnostics.cpp b/lib/Driver/HTMLDiagnostics.cpp
index 2772cf3422..6b60588ca5 100644
--- a/lib/Driver/HTMLDiagnostics.cpp
+++ b/lib/Driver/HTMLDiagnostics.cpp
@@ -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()) {
diff --git a/utils/scan-build b/utils/scan-build
index 44f0cbc641..39b9ede939 100755
--- a/utils/scan-build
+++ b/utils/scan-build
@@ -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 ];
}