2008-11-04 06:33:57 +08:00
|
|
|
//===--- PlistDiagnostics.cpp - Plist Diagnostics for Paths -----*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file defines the PlistDiagnostics object.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2009-03-02 14:16:29 +08:00
|
|
|
#include "clang/Frontend/PathDiagnosticClients.h"
|
2008-11-04 06:33:57 +08:00
|
|
|
#include "clang/Analysis/PathDiagnostic.h"
|
|
|
|
#include "clang/Basic/SourceManager.h"
|
|
|
|
#include "clang/Basic/FileManager.h"
|
2009-04-15 07:22:57 +08:00
|
|
|
#include "clang/Lex/Preprocessor.h"
|
2008-11-04 06:33:57 +08:00
|
|
|
#include "llvm/Support/Compiler.h"
|
|
|
|
#include "llvm/Support/raw_ostream.h"
|
2009-03-13 02:41:53 +08:00
|
|
|
#include "llvm/Support/Casting.h"
|
2008-11-04 06:33:57 +08:00
|
|
|
#include "llvm/System/Path.h"
|
|
|
|
#include "llvm/ADT/DenseMap.h"
|
|
|
|
#include "llvm/ADT/SmallVector.h"
|
|
|
|
using namespace clang;
|
2009-03-13 02:41:53 +08:00
|
|
|
using llvm::cast;
|
2009-01-17 14:22:33 +08:00
|
|
|
|
|
|
|
typedef llvm::DenseMap<FileID, unsigned> FIDMap;
|
2008-11-04 06:33:57 +08:00
|
|
|
|
2008-11-04 07:18:07 +08:00
|
|
|
namespace clang {
|
|
|
|
class Preprocessor;
|
|
|
|
class PreprocessorFactory;
|
|
|
|
}
|
|
|
|
|
2008-11-04 06:33:57 +08:00
|
|
|
namespace {
|
|
|
|
class VISIBILITY_HIDDEN PlistDiagnostics : public PathDiagnosticClient {
|
2009-01-21 08:42:24 +08:00
|
|
|
std::vector<const PathDiagnostic*> BatchedDiags;
|
|
|
|
const std::string OutputFile;
|
2009-04-15 07:22:57 +08:00
|
|
|
const LangOptions &LangOpts;
|
2008-11-04 06:33:57 +08:00
|
|
|
public:
|
2009-04-15 07:22:57 +08:00
|
|
|
PlistDiagnostics(const std::string& prefix, const LangOptions &LangOpts);
|
2009-01-21 08:42:24 +08:00
|
|
|
~PlistDiagnostics();
|
2009-03-27 13:06:10 +08:00
|
|
|
void HandlePathDiagnostic(const PathDiagnostic* D);
|
|
|
|
|
2009-04-02 08:44:18 +08:00
|
|
|
PathGenerationScheme getGenerationScheme() const { return Extensive; }
|
2009-03-27 13:06:10 +08:00
|
|
|
bool supportsLogicalOpControlFlow() const { return true; }
|
2009-04-01 04:22:36 +08:00
|
|
|
bool supportsAllBlockEdges() const { return true; }
|
2008-11-04 06:33:57 +08:00
|
|
|
};
|
|
|
|
} // end anonymous namespace
|
|
|
|
|
2009-04-15 07:22:57 +08:00
|
|
|
PlistDiagnostics::PlistDiagnostics(const std::string& output,
|
|
|
|
const LangOptions &LO)
|
|
|
|
: OutputFile(output), LangOpts(LO) {}
|
2008-11-04 06:33:57 +08:00
|
|
|
|
2008-11-04 07:18:07 +08:00
|
|
|
PathDiagnosticClient*
|
|
|
|
clang::CreatePlistDiagnosticClient(const std::string& s,
|
2009-04-15 07:22:57 +08:00
|
|
|
Preprocessor *PP, PreprocessorFactory*) {
|
|
|
|
return new PlistDiagnostics(s, PP->getLangOptions());
|
2008-11-04 06:33:57 +08:00
|
|
|
}
|
|
|
|
|
2009-01-19 15:46:45 +08:00
|
|
|
static void AddFID(FIDMap &FIDs, llvm::SmallVectorImpl<FileID> &V,
|
2009-04-01 14:13:56 +08:00
|
|
|
const SourceManager* SM, SourceLocation L) {
|
2008-11-04 06:33:57 +08:00
|
|
|
|
2009-01-24 04:06:20 +08:00
|
|
|
FileID FID = SM->getFileID(SM->getInstantiationLoc(L));
|
2009-01-17 14:22:33 +08:00
|
|
|
FIDMap::iterator I = FIDs.find(FID);
|
2008-11-04 06:33:57 +08:00
|
|
|
if (I != FIDs.end()) return;
|
2009-01-17 14:22:33 +08:00
|
|
|
FIDs[FID] = V.size();
|
|
|
|
V.push_back(FID);
|
2008-11-04 06:33:57 +08:00
|
|
|
}
|
|
|
|
|
2009-04-15 07:22:57 +08:00
|
|
|
static unsigned GetFID(const FIDMap& FIDs, const SourceManager &SM,
|
2009-04-01 14:13:56 +08:00
|
|
|
SourceLocation L) {
|
2009-04-15 07:22:57 +08:00
|
|
|
FileID FID = SM.getFileID(SM.getInstantiationLoc(L));
|
2009-01-17 14:22:33 +08:00
|
|
|
FIDMap::const_iterator I = FIDs.find(FID);
|
|
|
|
assert(I != FIDs.end());
|
2008-11-04 06:33:57 +08:00
|
|
|
return I->second;
|
|
|
|
}
|
|
|
|
|
|
|
|
static llvm::raw_ostream& Indent(llvm::raw_ostream& o, const unsigned indent) {
|
2009-03-13 02:41:53 +08:00
|
|
|
for (unsigned i = 0; i < indent; ++i) o << ' ';
|
2008-11-04 06:33:57 +08:00
|
|
|
return o;
|
|
|
|
}
|
|
|
|
|
2009-04-15 07:22:57 +08:00
|
|
|
static void EmitLocation(llvm::raw_ostream& o, const SourceManager &SM,
|
|
|
|
const LangOptions &LangOpts,
|
|
|
|
SourceLocation L, const FIDMap &FM,
|
|
|
|
unsigned indent, bool extend = false) {
|
2008-11-04 06:33:57 +08:00
|
|
|
|
2009-04-15 07:22:57 +08:00
|
|
|
FullSourceLoc Loc(SM.getInstantiationLoc(L), const_cast<SourceManager&>(SM));
|
2009-04-05 10:08:28 +08:00
|
|
|
|
|
|
|
// Add in the length of the token, so that we cover multi-char tokens.
|
2009-04-15 07:22:57 +08:00
|
|
|
unsigned offset =
|
|
|
|
extend ? Lexer::MeasureTokenLength(Loc, SM, LangOpts) - 1 : 0;
|
2009-04-05 10:08:28 +08:00
|
|
|
|
2008-11-04 06:33:57 +08:00
|
|
|
Indent(o, indent) << "<dict>\n";
|
|
|
|
Indent(o, indent) << " <key>line</key><integer>"
|
2009-04-05 10:08:28 +08:00
|
|
|
<< Loc.getInstantiationLineNumber() << "</integer>\n";
|
2008-11-04 06:33:57 +08:00
|
|
|
Indent(o, indent) << " <key>col</key><integer>"
|
2009-04-05 10:08:28 +08:00
|
|
|
<< Loc.getInstantiationColumnNumber() + offset << "</integer>\n";
|
2008-11-04 06:33:57 +08:00
|
|
|
Indent(o, indent) << " <key>file</key><integer>"
|
2009-04-05 10:08:28 +08:00
|
|
|
<< GetFID(FM, SM, Loc) << "</integer>\n";
|
2008-11-04 06:33:57 +08:00
|
|
|
Indent(o, indent) << "</dict>\n";
|
|
|
|
}
|
|
|
|
|
2009-04-15 07:22:57 +08:00
|
|
|
static void EmitLocation(llvm::raw_ostream& o, const SourceManager &SM,
|
|
|
|
const LangOptions &LangOpts,
|
2009-04-01 14:13:56 +08:00
|
|
|
const PathDiagnosticLocation &L, const FIDMap& FM,
|
2009-04-15 07:22:57 +08:00
|
|
|
unsigned indent, bool extend = false) {
|
|
|
|
EmitLocation(o, SM, LangOpts, L.asLocation(), FM, indent, extend);
|
2009-04-01 14:13:56 +08:00
|
|
|
}
|
|
|
|
|
2009-04-15 07:22:57 +08:00
|
|
|
static void EmitRange(llvm::raw_ostream& o, const SourceManager &SM,
|
|
|
|
const LangOptions &LangOpts,
|
|
|
|
SourceRange R, const FIDMap &FM,
|
|
|
|
unsigned indent) {
|
2008-11-04 06:33:57 +08:00
|
|
|
Indent(o, indent) << "<array>\n";
|
2009-04-15 07:22:57 +08:00
|
|
|
EmitLocation(o, SM, LangOpts, R.getBegin(), FM, indent+1);
|
|
|
|
EmitLocation(o, SM, LangOpts, R.getEnd(), FM, indent+1, true);
|
2008-11-04 06:33:57 +08:00
|
|
|
Indent(o, indent) << "</array>\n";
|
|
|
|
}
|
|
|
|
|
2009-03-28 14:40:54 +08:00
|
|
|
static llvm::raw_ostream& EmitString(llvm::raw_ostream& o,
|
|
|
|
const std::string& s) {
|
|
|
|
o << "<string>";
|
|
|
|
for (std::string::const_iterator I=s.begin(), E=s.end(); I!=E; ++I) {
|
|
|
|
char c = *I;
|
|
|
|
switch (c) {
|
|
|
|
default: o << c; break;
|
|
|
|
case '&': o << "&"; break;
|
|
|
|
case '<': o << "<"; break;
|
|
|
|
case '>': o << ">"; break;
|
|
|
|
case '\'': o << "'"; break;
|
|
|
|
case '\"': o << """; break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
o << "</string>";
|
|
|
|
return o;
|
|
|
|
}
|
|
|
|
|
2009-03-13 02:41:53 +08:00
|
|
|
static void ReportControlFlow(llvm::raw_ostream& o,
|
|
|
|
const PathDiagnosticControlFlowPiece& P,
|
2009-04-15 07:22:57 +08:00
|
|
|
const FIDMap& FM,
|
|
|
|
const SourceManager &SM,
|
|
|
|
const LangOptions &LangOpts,
|
2009-03-13 02:41:53 +08:00
|
|
|
unsigned indent) {
|
|
|
|
|
|
|
|
Indent(o, indent) << "<dict>\n";
|
|
|
|
++indent;
|
|
|
|
|
|
|
|
Indent(o, indent) << "<key>kind</key><string>control</string>\n";
|
2009-04-22 05:03:00 +08:00
|
|
|
|
2009-03-27 23:53:20 +08:00
|
|
|
// Emit edges.
|
|
|
|
Indent(o, indent) << "<key>edges</key>\n";
|
|
|
|
++indent;
|
|
|
|
Indent(o, indent) << "<array>\n";
|
|
|
|
++indent;
|
|
|
|
for (PathDiagnosticControlFlowPiece::const_iterator I=P.begin(), E=P.end();
|
|
|
|
I!=E; ++I) {
|
|
|
|
Indent(o, indent) << "<dict>\n";
|
|
|
|
++indent;
|
|
|
|
Indent(o, indent) << "<key>start</key>\n";
|
2009-04-15 07:22:57 +08:00
|
|
|
EmitRange(o, SM, LangOpts, I->getStart().asRange(), FM, indent+1);
|
2009-03-27 23:53:20 +08:00
|
|
|
Indent(o, indent) << "<key>end</key>\n";
|
2009-04-15 07:22:57 +08:00
|
|
|
EmitRange(o, SM, LangOpts, I->getEnd().asRange(), FM, indent+1);
|
2009-03-27 23:53:20 +08:00
|
|
|
--indent;
|
|
|
|
Indent(o, indent) << "</dict>\n";
|
|
|
|
}
|
|
|
|
--indent;
|
|
|
|
Indent(o, indent) << "</array>\n";
|
|
|
|
--indent;
|
|
|
|
|
2009-03-13 02:41:53 +08:00
|
|
|
// Output any helper text.
|
|
|
|
const std::string& s = P.getString();
|
|
|
|
if (!s.empty()) {
|
2009-03-28 14:40:54 +08:00
|
|
|
Indent(o, indent) << "<key>alternate</key>";
|
|
|
|
EmitString(o, s) << '\n';
|
2009-03-13 02:41:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
--indent;
|
|
|
|
Indent(o, indent) << "</dict>\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ReportEvent(llvm::raw_ostream& o, const PathDiagnosticPiece& P,
|
2009-04-15 07:22:57 +08:00
|
|
|
const FIDMap& FM,
|
|
|
|
const SourceManager &SM,
|
|
|
|
const LangOptions &LangOpts,
|
2009-04-01 14:13:56 +08:00
|
|
|
unsigned indent) {
|
2008-11-04 06:33:57 +08:00
|
|
|
|
|
|
|
Indent(o, indent) << "<dict>\n";
|
|
|
|
++indent;
|
2009-03-13 02:41:53 +08:00
|
|
|
|
|
|
|
Indent(o, indent) << "<key>kind</key><string>event</string>\n";
|
2008-11-04 06:33:57 +08:00
|
|
|
|
|
|
|
// Output the location.
|
2009-04-01 14:13:56 +08:00
|
|
|
FullSourceLoc L = P.getLocation().asLocation();
|
2009-03-13 02:41:53 +08:00
|
|
|
|
2008-11-04 06:33:57 +08:00
|
|
|
Indent(o, indent) << "<key>location</key>\n";
|
2009-04-15 07:22:57 +08:00
|
|
|
EmitLocation(o, SM, LangOpts, L, FM, indent);
|
2009-03-13 02:41:53 +08:00
|
|
|
|
2008-11-04 06:33:57 +08:00
|
|
|
// Output the ranges (if any).
|
|
|
|
PathDiagnosticPiece::range_iterator RI = P.ranges_begin(),
|
2009-03-13 02:41:53 +08:00
|
|
|
RE = P.ranges_end();
|
2008-11-04 06:33:57 +08:00
|
|
|
|
|
|
|
if (RI != RE) {
|
|
|
|
Indent(o, indent) << "<key>ranges</key>\n";
|
|
|
|
Indent(o, indent) << "<array>\n";
|
2009-02-03 05:45:32 +08:00
|
|
|
++indent;
|
2009-04-15 07:22:57 +08:00
|
|
|
for (; RI != RE; ++RI)
|
|
|
|
EmitRange(o, SM, LangOpts, *RI, FM, indent+1);
|
2009-02-03 05:45:32 +08:00
|
|
|
--indent;
|
2008-11-04 06:33:57 +08:00
|
|
|
Indent(o, indent) << "</array>\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
// Output the text.
|
2009-03-13 02:41:53 +08:00
|
|
|
assert(!P.getString().empty());
|
2009-03-19 08:42:56 +08:00
|
|
|
Indent(o, indent) << "<key>extended_message</key>\n";
|
2009-03-28 14:40:54 +08:00
|
|
|
Indent(o, indent);
|
|
|
|
EmitString(o, P.getString()) << '\n';
|
2009-03-19 08:42:56 +08:00
|
|
|
|
|
|
|
// Output the short text.
|
|
|
|
// FIXME: Really use a short string.
|
2008-11-04 06:33:57 +08:00
|
|
|
Indent(o, indent) << "<key>message</key>\n";
|
2009-03-28 14:40:54 +08:00
|
|
|
EmitString(o, P.getString()) << '\n';
|
2009-03-13 02:41:53 +08:00
|
|
|
|
|
|
|
// Finish up.
|
|
|
|
--indent;
|
|
|
|
Indent(o, indent); o << "</dict>\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ReportMacro(llvm::raw_ostream& o,
|
|
|
|
const PathDiagnosticMacroPiece& P,
|
2009-04-15 07:22:57 +08:00
|
|
|
const FIDMap& FM, const SourceManager &SM,
|
|
|
|
const LangOptions &LangOpts,
|
2009-03-13 02:41:53 +08:00
|
|
|
unsigned indent) {
|
2008-11-04 06:33:57 +08:00
|
|
|
|
2009-03-13 02:41:53 +08:00
|
|
|
for (PathDiagnosticMacroPiece::const_iterator I=P.begin(), E=P.end();
|
|
|
|
I!=E; ++I) {
|
|
|
|
|
|
|
|
switch ((*I)->getKind()) {
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
case PathDiagnosticPiece::Event:
|
2009-04-15 07:22:57 +08:00
|
|
|
ReportEvent(o, cast<PathDiagnosticEventPiece>(**I), FM, SM, LangOpts,
|
|
|
|
indent);
|
2009-03-13 02:41:53 +08:00
|
|
|
break;
|
|
|
|
case PathDiagnosticPiece::Macro:
|
2009-04-15 07:22:57 +08:00
|
|
|
ReportMacro(o, cast<PathDiagnosticMacroPiece>(**I), FM, SM, LangOpts,
|
|
|
|
indent);
|
2009-03-13 02:41:53 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ReportDiag(llvm::raw_ostream& o, const PathDiagnosticPiece& P,
|
2009-04-15 07:22:57 +08:00
|
|
|
const FIDMap& FM, const SourceManager &SM,
|
|
|
|
const LangOptions &LangOpts) {
|
2009-03-13 02:41:53 +08:00
|
|
|
|
|
|
|
unsigned indent = 4;
|
2009-03-10 10:49:29 +08:00
|
|
|
|
|
|
|
switch (P.getKind()) {
|
2009-03-13 02:41:53 +08:00
|
|
|
case PathDiagnosticPiece::ControlFlow:
|
|
|
|
ReportControlFlow(o, cast<PathDiagnosticControlFlowPiece>(P), FM, SM,
|
2009-04-15 07:22:57 +08:00
|
|
|
LangOpts, indent);
|
2009-03-13 02:41:53 +08:00
|
|
|
break;
|
|
|
|
case PathDiagnosticPiece::Event:
|
2009-04-15 07:22:57 +08:00
|
|
|
ReportEvent(o, cast<PathDiagnosticEventPiece>(P), FM, SM, LangOpts,
|
|
|
|
indent);
|
2009-03-13 02:41:53 +08:00
|
|
|
break;
|
|
|
|
case PathDiagnosticPiece::Macro:
|
2009-04-15 07:22:57 +08:00
|
|
|
ReportMacro(o, cast<PathDiagnosticMacroPiece>(P), FM, SM, LangOpts,
|
|
|
|
indent);
|
2009-03-13 02:41:53 +08:00
|
|
|
break;
|
2009-03-10 10:49:29 +08:00
|
|
|
}
|
2008-11-04 06:33:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void PlistDiagnostics::HandlePathDiagnostic(const PathDiagnostic* D) {
|
2009-01-21 08:42:24 +08:00
|
|
|
if (!D)
|
|
|
|
return;
|
2008-11-04 06:33:57 +08:00
|
|
|
|
2009-01-21 08:42:24 +08:00
|
|
|
if (D->empty()) {
|
|
|
|
delete D;
|
2008-11-04 06:33:57 +08:00
|
|
|
return;
|
2009-01-21 08:42:24 +08:00
|
|
|
}
|
|
|
|
|
2009-04-02 13:13:24 +08:00
|
|
|
// We need to flatten the locations (convert Stmt* to locations) because
|
|
|
|
// the referenced statements may be freed by the time the diagnostics
|
|
|
|
// are emitted.
|
|
|
|
const_cast<PathDiagnostic*>(D)->flattenLocations();
|
2009-01-21 08:42:24 +08:00
|
|
|
BatchedDiags.push_back(D);
|
|
|
|
}
|
2008-11-04 06:33:57 +08:00
|
|
|
|
2009-01-21 08:42:24 +08:00
|
|
|
PlistDiagnostics::~PlistDiagnostics() {
|
2008-11-04 06:33:57 +08:00
|
|
|
|
|
|
|
// Build up a set of FIDs that we use by scanning the locations and
|
|
|
|
// ranges of the diagnostics.
|
|
|
|
FIDMap FM;
|
2009-01-17 14:22:33 +08:00
|
|
|
llvm::SmallVector<FileID, 10> Fids;
|
2009-04-01 14:13:56 +08:00
|
|
|
const SourceManager* SM = 0;
|
2009-01-24 04:06:20 +08:00
|
|
|
|
|
|
|
if (!BatchedDiags.empty())
|
|
|
|
SM = &(*BatchedDiags.begin())->begin()->getLocation().getManager();
|
2008-11-04 06:33:57 +08:00
|
|
|
|
2009-01-21 08:42:24 +08:00
|
|
|
for (std::vector<const PathDiagnostic*>::iterator DI = BatchedDiags.begin(),
|
|
|
|
DE = BatchedDiags.end(); DI != DE; ++DI) {
|
|
|
|
|
|
|
|
const PathDiagnostic *D = *DI;
|
|
|
|
|
|
|
|
for (PathDiagnostic::const_iterator I=D->begin(), E=D->end(); I!=E; ++I) {
|
2009-04-01 14:13:56 +08:00
|
|
|
AddFID(FM, Fids, SM, I->getLocation().asLocation());
|
2009-01-21 08:42:24 +08:00
|
|
|
|
|
|
|
for (PathDiagnosticPiece::range_iterator RI=I->ranges_begin(),
|
|
|
|
RE=I->ranges_end(); RI!=RE; ++RI) {
|
|
|
|
AddFID(FM, Fids, SM, RI->getBegin());
|
|
|
|
AddFID(FM, Fids, SM, RI->getEnd());
|
|
|
|
}
|
2008-11-04 06:33:57 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-21 08:42:24 +08:00
|
|
|
// Open the file.
|
2008-11-04 06:33:57 +08:00
|
|
|
std::string ErrMsg;
|
2009-01-21 08:42:24 +08:00
|
|
|
llvm::raw_fd_ostream o(OutputFile.c_str(), false, ErrMsg);
|
2008-11-04 06:33:57 +08:00
|
|
|
if (!ErrMsg.empty()) {
|
2009-01-21 08:42:24 +08:00
|
|
|
llvm::errs() << "warning: could not creat file: " << OutputFile << '\n';
|
2008-11-04 06:33:57 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Write the plist header.
|
|
|
|
o << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
2009-01-21 08:42:24 +08:00
|
|
|
"<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" "
|
|
|
|
"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n"
|
|
|
|
"<plist version=\"1.0\">\n";
|
2008-11-04 06:33:57 +08:00
|
|
|
|
|
|
|
// Write the root object: a <dict> containing...
|
|
|
|
// - "files", an <array> mapping from FIDs to file names
|
|
|
|
// - "diagnostics", an <array> containing the path diagnostics
|
|
|
|
o << "<dict>\n"
|
|
|
|
" <key>files</key>\n"
|
|
|
|
" <array>\n";
|
|
|
|
|
2009-01-17 14:22:33 +08:00
|
|
|
for (llvm::SmallVectorImpl<FileID>::iterator I=Fids.begin(), E=Fids.end();
|
2009-03-28 14:40:54 +08:00
|
|
|
I!=E; ++I) {
|
|
|
|
o << " ";
|
|
|
|
EmitString(o, SM->getFileEntryForID(*I)->getName()) << '\n';
|
|
|
|
}
|
2008-11-04 06:33:57 +08:00
|
|
|
|
|
|
|
o << " </array>\n"
|
|
|
|
" <key>diagnostics</key>\n"
|
|
|
|
" <array>\n";
|
|
|
|
|
2009-01-21 08:42:24 +08:00
|
|
|
for (std::vector<const PathDiagnostic*>::iterator DI=BatchedDiags.begin(),
|
|
|
|
DE = BatchedDiags.end(); DI!=DE; ++DI) {
|
|
|
|
|
|
|
|
o << " <dict>\n"
|
|
|
|
" <key>path</key>\n";
|
|
|
|
|
|
|
|
const PathDiagnostic *D = *DI;
|
|
|
|
// Create an owning smart pointer for 'D' just so that we auto-free it
|
|
|
|
// when we exit this method.
|
|
|
|
llvm::OwningPtr<PathDiagnostic> OwnedD(const_cast<PathDiagnostic*>(D));
|
2008-11-04 06:33:57 +08:00
|
|
|
|
2009-01-21 08:42:24 +08:00
|
|
|
o << " <array>\n";
|
|
|
|
|
|
|
|
for (PathDiagnostic::const_iterator I=D->begin(), E=D->end(); I != E; ++I)
|
2009-04-15 07:22:57 +08:00
|
|
|
ReportDiag(o, *I, FM, *SM, LangOpts);
|
2009-01-21 08:42:24 +08:00
|
|
|
|
|
|
|
o << " </array>\n";
|
2008-11-04 06:33:57 +08:00
|
|
|
|
2009-01-21 08:42:24 +08:00
|
|
|
// Output the bug type and bug category.
|
2009-03-28 14:40:54 +08:00
|
|
|
o << " <key>description</key>";
|
|
|
|
EmitString(o, D->getDescription()) << '\n';
|
|
|
|
o << " <key>category</key>";
|
|
|
|
EmitString(o, D->getCategory()) << '\n';
|
|
|
|
o << " <key>type</key>";
|
|
|
|
EmitString(o, D->getBugType()) << '\n';
|
2009-03-27 23:31:11 +08:00
|
|
|
|
|
|
|
// Output the location of the bug.
|
|
|
|
o << " <key>location</key>\n";
|
2009-04-15 07:22:57 +08:00
|
|
|
EmitLocation(o, *SM, LangOpts, D->getLocation(), FM, 2);
|
2009-03-27 23:31:11 +08:00
|
|
|
|
2009-03-28 14:40:54 +08:00
|
|
|
// Close up the entry.
|
2009-03-27 23:31:11 +08:00
|
|
|
o << " </dict>\n";
|
2009-01-21 08:42:24 +08:00
|
|
|
}
|
2008-11-04 06:33:57 +08:00
|
|
|
|
2009-01-21 08:42:24 +08:00
|
|
|
o << " </array>\n";
|
|
|
|
|
2008-11-04 06:33:57 +08:00
|
|
|
// Finish.
|
2008-11-04 07:18:07 +08:00
|
|
|
o << "</dict>\n</plist>";
|
2008-11-04 06:33:57 +08:00
|
|
|
}
|