From: Ted Kremenek Date: Fri, 20 Jun 2008 23:13:39 +0000 (+0000) Subject: When using the dead-stores checker with the BugReporter class, properly capture the... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bd527efac09504d69018c72017029c20b6d4acef;p=clang When using the dead-stores checker with the BugReporter class, properly capture the diagnostic associated with a specific warning and emit it. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52565 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Analysis/DeadStores.cpp b/lib/Analysis/DeadStores.cpp index 7d912b046e..208e66f3e9 100644 --- a/lib/Analysis/DeadStores.cpp +++ b/lib/Analysis/DeadStores.cpp @@ -164,13 +164,18 @@ namespace { class VISIBILITY_HIDDEN DiagBugReport : public RangedBugReport { std::list Strs; FullSourceLoc L; + const char* description; public: - DiagBugReport(BugType& D, FullSourceLoc l) : - RangedBugReport(D, NULL), L(l) {} + DiagBugReport(const char* desc, BugType& D, FullSourceLoc l) : + RangedBugReport(D, NULL), L(l), description(desc) {} virtual ~DiagBugReport() {} virtual FullSourceLoc getLocation(SourceManager&) { return L; } + virtual const char* getDescription() const { + return description; + } + void addString(const std::string& s) { Strs.push_back(s); } typedef std::list::const_iterator str_iterator; @@ -198,7 +203,7 @@ public: // FIXME: Use a map from diag::kind to BugType, instead of having just // one BugType. - Reports.push_back(DiagBugReport(D, Pos)); + Reports.push_back(DiagBugReport(Diags.getDescription(ID), D, Pos)); DiagBugReport& R = Reports.back(); for ( ; NumRanges ; --NumRanges, ++Ranges)