Ted Kremenek | 5d86625 | 2008-11-03 22:33:57 +0000 | [diff] [blame] | 1 | //===--- PlistDiagnostics.cpp - Plist Diagnostics for Paths -----*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file defines the PlistDiagnostics object. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
Daniel Dunbar | e1bd4e6 | 2009-03-02 06:16:29 +0000 | [diff] [blame] | 14 | #include "clang/Frontend/PathDiagnosticClients.h" |
Ted Kremenek | 5d86625 | 2008-11-03 22:33:57 +0000 | [diff] [blame] | 15 | #include "clang/Analysis/PathDiagnostic.h" |
| 16 | #include "clang/Basic/SourceManager.h" |
| 17 | #include "clang/Basic/FileManager.h" |
| 18 | #include "llvm/Support/Compiler.h" |
| 19 | #include "llvm/Support/raw_ostream.h" |
Ted Kremenek | 082cb8d | 2009-03-12 18:41:53 +0000 | [diff] [blame] | 20 | #include "llvm/Support/Casting.h" |
Ted Kremenek | 5d86625 | 2008-11-03 22:33:57 +0000 | [diff] [blame] | 21 | #include "llvm/System/Path.h" |
| 22 | #include "llvm/ADT/DenseMap.h" |
| 23 | #include "llvm/ADT/SmallVector.h" |
Ted Kremenek | 5d86625 | 2008-11-03 22:33:57 +0000 | [diff] [blame] | 24 | using namespace clang; |
Ted Kremenek | 082cb8d | 2009-03-12 18:41:53 +0000 | [diff] [blame] | 25 | using llvm::cast; |
Chris Lattner | 2b2453a | 2009-01-17 06:22:33 +0000 | [diff] [blame] | 26 | |
| 27 | typedef llvm::DenseMap<FileID, unsigned> FIDMap; |
Ted Kremenek | 5d86625 | 2008-11-03 22:33:57 +0000 | [diff] [blame] | 28 | |
Ted Kremenek | 4fc82c8 | 2008-11-03 23:18:07 +0000 | [diff] [blame] | 29 | namespace clang { |
| 30 | class Preprocessor; |
| 31 | class PreprocessorFactory; |
| 32 | } |
| 33 | |
Ted Kremenek | 5d86625 | 2008-11-03 22:33:57 +0000 | [diff] [blame] | 34 | namespace { |
| 35 | class VISIBILITY_HIDDEN PlistDiagnostics : public PathDiagnosticClient { |
Ted Kremenek | ddf32da | 2009-01-21 00:42:24 +0000 | [diff] [blame] | 36 | std::vector<const PathDiagnostic*> BatchedDiags; |
| 37 | const std::string OutputFile; |
Ted Kremenek | 5d86625 | 2008-11-03 22:33:57 +0000 | [diff] [blame] | 38 | public: |
| 39 | PlistDiagnostics(const std::string& prefix); |
Ted Kremenek | ddf32da | 2009-01-21 00:42:24 +0000 | [diff] [blame] | 40 | ~PlistDiagnostics(); |
Ted Kremenek | babdd7b | 2009-03-27 05:06:10 +0000 | [diff] [blame] | 41 | void HandlePathDiagnostic(const PathDiagnostic* D); |
| 42 | |
| 43 | bool supportsLogicalOpControlFlow() const { return true; } |
Ted Kremenek | 5d86625 | 2008-11-03 22:33:57 +0000 | [diff] [blame] | 44 | }; |
| 45 | } // end anonymous namespace |
| 46 | |
Ted Kremenek | ddf32da | 2009-01-21 00:42:24 +0000 | [diff] [blame] | 47 | PlistDiagnostics::PlistDiagnostics(const std::string& output) |
| 48 | : OutputFile(output) {} |
Ted Kremenek | 5d86625 | 2008-11-03 22:33:57 +0000 | [diff] [blame] | 49 | |
Ted Kremenek | 4fc82c8 | 2008-11-03 23:18:07 +0000 | [diff] [blame] | 50 | PathDiagnosticClient* |
| 51 | clang::CreatePlistDiagnosticClient(const std::string& s, |
| 52 | Preprocessor*, PreprocessorFactory*) { |
Ted Kremenek | 5d86625 | 2008-11-03 22:33:57 +0000 | [diff] [blame] | 53 | return new PlistDiagnostics(s); |
| 54 | } |
| 55 | |
Chris Lattner | a11d617 | 2009-01-19 07:46:45 +0000 | [diff] [blame] | 56 | static void AddFID(FIDMap &FIDs, llvm::SmallVectorImpl<FileID> &V, |
Ted Kremenek | c472d79 | 2009-01-23 20:06:20 +0000 | [diff] [blame] | 57 | SourceManager* SM, SourceLocation L) { |
Ted Kremenek | 5d86625 | 2008-11-03 22:33:57 +0000 | [diff] [blame] | 58 | |
Ted Kremenek | c472d79 | 2009-01-23 20:06:20 +0000 | [diff] [blame] | 59 | FileID FID = SM->getFileID(SM->getInstantiationLoc(L)); |
Chris Lattner | 2b2453a | 2009-01-17 06:22:33 +0000 | [diff] [blame] | 60 | FIDMap::iterator I = FIDs.find(FID); |
Ted Kremenek | 5d86625 | 2008-11-03 22:33:57 +0000 | [diff] [blame] | 61 | if (I != FIDs.end()) return; |
Chris Lattner | 2b2453a | 2009-01-17 06:22:33 +0000 | [diff] [blame] | 62 | FIDs[FID] = V.size(); |
| 63 | V.push_back(FID); |
Ted Kremenek | 5d86625 | 2008-11-03 22:33:57 +0000 | [diff] [blame] | 64 | } |
| 65 | |
Ted Kremenek | c472d79 | 2009-01-23 20:06:20 +0000 | [diff] [blame] | 66 | static unsigned GetFID(const FIDMap& FIDs, SourceManager* SM, SourceLocation L){ |
| 67 | FileID FID = SM->getFileID(SM->getInstantiationLoc(L)); |
Chris Lattner | 2b2453a | 2009-01-17 06:22:33 +0000 | [diff] [blame] | 68 | FIDMap::const_iterator I = FIDs.find(FID); |
| 69 | assert(I != FIDs.end()); |
Ted Kremenek | 5d86625 | 2008-11-03 22:33:57 +0000 | [diff] [blame] | 70 | return I->second; |
| 71 | } |
| 72 | |
| 73 | static llvm::raw_ostream& Indent(llvm::raw_ostream& o, const unsigned indent) { |
Ted Kremenek | 082cb8d | 2009-03-12 18:41:53 +0000 | [diff] [blame] | 74 | for (unsigned i = 0; i < indent; ++i) o << ' '; |
Ted Kremenek | 5d86625 | 2008-11-03 22:33:57 +0000 | [diff] [blame] | 75 | return o; |
| 76 | } |
| 77 | |
Ted Kremenek | c472d79 | 2009-01-23 20:06:20 +0000 | [diff] [blame] | 78 | static void EmitLocation(llvm::raw_ostream& o, SourceManager* SM, |
Ted Kremenek | 5d86625 | 2008-11-03 22:33:57 +0000 | [diff] [blame] | 79 | SourceLocation L, const FIDMap& FM, |
| 80 | const unsigned indent) { |
| 81 | |
| 82 | Indent(o, indent) << "<dict>\n"; |
| 83 | Indent(o, indent) << " <key>line</key><integer>" |
Ted Kremenek | c472d79 | 2009-01-23 20:06:20 +0000 | [diff] [blame] | 84 | << SM->getInstantiationLineNumber(L) << "</integer>\n"; |
Ted Kremenek | 5d86625 | 2008-11-03 22:33:57 +0000 | [diff] [blame] | 85 | Indent(o, indent) << " <key>col</key><integer>" |
Ted Kremenek | c472d79 | 2009-01-23 20:06:20 +0000 | [diff] [blame] | 86 | << SM->getInstantiationColumnNumber(L) << "</integer>\n"; |
Ted Kremenek | 5d86625 | 2008-11-03 22:33:57 +0000 | [diff] [blame] | 87 | Indent(o, indent) << " <key>file</key><integer>" |
| 88 | << GetFID(FM, SM, L) << "</integer>\n"; |
| 89 | Indent(o, indent) << "</dict>\n"; |
| 90 | } |
| 91 | |
Ted Kremenek | c472d79 | 2009-01-23 20:06:20 +0000 | [diff] [blame] | 92 | static void EmitRange(llvm::raw_ostream& o, SourceManager* SM, SourceRange R, |
Ted Kremenek | 5d86625 | 2008-11-03 22:33:57 +0000 | [diff] [blame] | 93 | const FIDMap& FM, const unsigned indent) { |
| 94 | |
| 95 | Indent(o, indent) << "<array>\n"; |
| 96 | EmitLocation(o, SM, R.getBegin(), FM, indent+1); |
| 97 | EmitLocation(o, SM, R.getEnd(), FM, indent+1); |
| 98 | Indent(o, indent) << "</array>\n"; |
| 99 | } |
| 100 | |
Ted Kremenek | 082cb8d | 2009-03-12 18:41:53 +0000 | [diff] [blame] | 101 | static void ReportControlFlow(llvm::raw_ostream& o, |
| 102 | const PathDiagnosticControlFlowPiece& P, |
| 103 | const FIDMap& FM, SourceManager *SM, |
| 104 | unsigned indent) { |
Ted Kremenek | 5d86625 | 2008-11-03 22:33:57 +0000 | [diff] [blame] | 105 | |
Ted Kremenek | 5d86625 | 2008-11-03 22:33:57 +0000 | [diff] [blame] | 106 | Indent(o, indent) << "<dict>\n"; |
| 107 | ++indent; |
| 108 | |
Ted Kremenek | 082cb8d | 2009-03-12 18:41:53 +0000 | [diff] [blame] | 109 | Indent(o, indent) << "<key>kind</key><string>control</string>\n"; |
| 110 | |
Ted Kremenek | f48fbc6 | 2009-03-27 15:53:20 +0000 | [diff] [blame^] | 111 | // FIXME: Eventually remove (DEPRECATED) |
Ted Kremenek | 082cb8d | 2009-03-12 18:41:53 +0000 | [diff] [blame] | 112 | // Output the start and end locations. |
| 113 | Indent(o, indent) << "<key>start</key>\n"; |
| 114 | EmitLocation(o, SM, P.getStartLocation(), FM, indent); |
| 115 | Indent(o, indent) << "<key>end</key>\n"; |
| 116 | EmitLocation(o, SM, P.getEndLocation(), FM, indent); |
| 117 | |
Ted Kremenek | f48fbc6 | 2009-03-27 15:53:20 +0000 | [diff] [blame^] | 118 | // Emit edges. |
| 119 | Indent(o, indent) << "<key>edges</key>\n"; |
| 120 | ++indent; |
| 121 | Indent(o, indent) << "<array>\n"; |
| 122 | ++indent; |
| 123 | for (PathDiagnosticControlFlowPiece::const_iterator I=P.begin(), E=P.end(); |
| 124 | I!=E; ++I) { |
| 125 | Indent(o, indent) << "<dict>\n"; |
| 126 | ++indent; |
| 127 | Indent(o, indent) << "<key>start</key>\n"; |
| 128 | EmitRange(o, SM, I->getStart().asRange(), FM, indent+1); |
| 129 | Indent(o, indent) << "<key>end</key>\n"; |
| 130 | EmitRange(o, SM, I->getEnd().asRange(), FM, indent+1); |
| 131 | --indent; |
| 132 | Indent(o, indent) << "</dict>\n"; |
| 133 | } |
| 134 | --indent; |
| 135 | Indent(o, indent) << "</array>\n"; |
| 136 | --indent; |
| 137 | |
Ted Kremenek | 082cb8d | 2009-03-12 18:41:53 +0000 | [diff] [blame] | 138 | // Output any helper text. |
| 139 | const std::string& s = P.getString(); |
| 140 | if (!s.empty()) { |
| 141 | Indent(o, indent) << "<key>alternate</key><string>" << s << "</string>\n"; |
| 142 | } |
| 143 | |
| 144 | --indent; |
| 145 | Indent(o, indent) << "</dict>\n"; |
| 146 | } |
| 147 | |
| 148 | static void ReportEvent(llvm::raw_ostream& o, const PathDiagnosticPiece& P, |
| 149 | const FIDMap& FM, SourceManager* SM, unsigned indent) { |
| 150 | |
| 151 | Indent(o, indent) << "<dict>\n"; |
| 152 | ++indent; |
| 153 | |
| 154 | Indent(o, indent) << "<key>kind</key><string>event</string>\n"; |
| 155 | |
Ted Kremenek | 5d86625 | 2008-11-03 22:33:57 +0000 | [diff] [blame] | 156 | // Output the location. |
| 157 | FullSourceLoc L = P.getLocation(); |
Ted Kremenek | 082cb8d | 2009-03-12 18:41:53 +0000 | [diff] [blame] | 158 | |
Ted Kremenek | 5d86625 | 2008-11-03 22:33:57 +0000 | [diff] [blame] | 159 | Indent(o, indent) << "<key>location</key>\n"; |
Chris Lattner | 59ddeab | 2009-01-16 23:06:35 +0000 | [diff] [blame] | 160 | EmitLocation(o, SM, L, FM, indent); |
Ted Kremenek | 082cb8d | 2009-03-12 18:41:53 +0000 | [diff] [blame] | 161 | |
Ted Kremenek | 5d86625 | 2008-11-03 22:33:57 +0000 | [diff] [blame] | 162 | // Output the ranges (if any). |
| 163 | PathDiagnosticPiece::range_iterator RI = P.ranges_begin(), |
Ted Kremenek | 082cb8d | 2009-03-12 18:41:53 +0000 | [diff] [blame] | 164 | RE = P.ranges_end(); |
Ted Kremenek | 5d86625 | 2008-11-03 22:33:57 +0000 | [diff] [blame] | 165 | |
| 166 | if (RI != RE) { |
| 167 | Indent(o, indent) << "<key>ranges</key>\n"; |
| 168 | Indent(o, indent) << "<array>\n"; |
Ted Kremenek | d671c5a | 2009-02-02 21:45:32 +0000 | [diff] [blame] | 169 | ++indent; |
Ted Kremenek | 5d86625 | 2008-11-03 22:33:57 +0000 | [diff] [blame] | 170 | for ( ; RI != RE; ++RI ) EmitRange(o, SM, *RI, FM, indent+1); |
Ted Kremenek | d671c5a | 2009-02-02 21:45:32 +0000 | [diff] [blame] | 171 | --indent; |
Ted Kremenek | 5d86625 | 2008-11-03 22:33:57 +0000 | [diff] [blame] | 172 | Indent(o, indent) << "</array>\n"; |
| 173 | } |
| 174 | |
| 175 | // Output the text. |
Ted Kremenek | 082cb8d | 2009-03-12 18:41:53 +0000 | [diff] [blame] | 176 | assert(!P.getString().empty()); |
Ted Kremenek | 61dc71a | 2009-03-19 00:42:56 +0000 | [diff] [blame] | 177 | Indent(o, indent) << "<key>extended_message</key>\n"; |
| 178 | Indent(o, indent) << "<string>" << P.getString() << "</string>\n"; |
| 179 | |
| 180 | // Output the short text. |
| 181 | // FIXME: Really use a short string. |
Ted Kremenek | 5d86625 | 2008-11-03 22:33:57 +0000 | [diff] [blame] | 182 | Indent(o, indent) << "<key>message</key>\n"; |
Ted Kremenek | 4fc82c8 | 2008-11-03 23:18:07 +0000 | [diff] [blame] | 183 | Indent(o, indent) << "<string>" << P.getString() << "</string>\n"; |
Ted Kremenek | 082cb8d | 2009-03-12 18:41:53 +0000 | [diff] [blame] | 184 | |
Ted Kremenek | 5d86625 | 2008-11-03 22:33:57 +0000 | [diff] [blame] | 185 | // Finish up. |
| 186 | --indent; |
| 187 | Indent(o, indent); o << "</dict>\n"; |
| 188 | } |
| 189 | |
Ted Kremenek | 082cb8d | 2009-03-12 18:41:53 +0000 | [diff] [blame] | 190 | static void ReportMacro(llvm::raw_ostream& o, |
| 191 | const PathDiagnosticMacroPiece& P, |
| 192 | const FIDMap& FM, SourceManager *SM, |
| 193 | unsigned indent) { |
| 194 | |
| 195 | for (PathDiagnosticMacroPiece::const_iterator I=P.begin(), E=P.end(); |
| 196 | I!=E; ++I) { |
| 197 | |
| 198 | switch ((*I)->getKind()) { |
| 199 | default: |
| 200 | break; |
| 201 | case PathDiagnosticPiece::Event: |
| 202 | ReportEvent(o, cast<PathDiagnosticEventPiece>(**I), FM, SM, indent); |
| 203 | break; |
| 204 | case PathDiagnosticPiece::Macro: |
| 205 | ReportMacro(o, cast<PathDiagnosticMacroPiece>(**I), FM, SM, indent); |
| 206 | break; |
| 207 | } |
| 208 | } |
| 209 | } |
| 210 | |
| 211 | static void ReportDiag(llvm::raw_ostream& o, const PathDiagnosticPiece& P, |
| 212 | const FIDMap& FM, SourceManager* SM) { |
| 213 | |
| 214 | unsigned indent = 4; |
| 215 | |
| 216 | switch (P.getKind()) { |
| 217 | case PathDiagnosticPiece::ControlFlow: |
| 218 | ReportControlFlow(o, cast<PathDiagnosticControlFlowPiece>(P), FM, SM, |
| 219 | indent); |
| 220 | break; |
| 221 | case PathDiagnosticPiece::Event: |
| 222 | ReportEvent(o, cast<PathDiagnosticEventPiece>(P), FM, SM, indent); |
| 223 | break; |
| 224 | case PathDiagnosticPiece::Macro: |
| 225 | ReportMacro(o, cast<PathDiagnosticMacroPiece>(P), FM, SM, indent); |
| 226 | break; |
| 227 | } |
| 228 | } |
| 229 | |
Ted Kremenek | 5d86625 | 2008-11-03 22:33:57 +0000 | [diff] [blame] | 230 | void PlistDiagnostics::HandlePathDiagnostic(const PathDiagnostic* D) { |
Ted Kremenek | ddf32da | 2009-01-21 00:42:24 +0000 | [diff] [blame] | 231 | if (!D) |
| 232 | return; |
Ted Kremenek | 5d86625 | 2008-11-03 22:33:57 +0000 | [diff] [blame] | 233 | |
Ted Kremenek | ddf32da | 2009-01-21 00:42:24 +0000 | [diff] [blame] | 234 | if (D->empty()) { |
| 235 | delete D; |
| 236 | return; |
Ted Kremenek | 5d86625 | 2008-11-03 22:33:57 +0000 | [diff] [blame] | 237 | } |
| 238 | |
Ted Kremenek | ddf32da | 2009-01-21 00:42:24 +0000 | [diff] [blame] | 239 | BatchedDiags.push_back(D); |
| 240 | } |
Ted Kremenek | 5d86625 | 2008-11-03 22:33:57 +0000 | [diff] [blame] | 241 | |
Ted Kremenek | ddf32da | 2009-01-21 00:42:24 +0000 | [diff] [blame] | 242 | PlistDiagnostics::~PlistDiagnostics() { |
Ted Kremenek | 5d86625 | 2008-11-03 22:33:57 +0000 | [diff] [blame] | 243 | |
| 244 | // Build up a set of FIDs that we use by scanning the locations and |
| 245 | // ranges of the diagnostics. |
| 246 | FIDMap FM; |
Chris Lattner | 2b2453a | 2009-01-17 06:22:33 +0000 | [diff] [blame] | 247 | llvm::SmallVector<FileID, 10> Fids; |
Ted Kremenek | c472d79 | 2009-01-23 20:06:20 +0000 | [diff] [blame] | 248 | SourceManager* SM = 0; |
| 249 | |
| 250 | if (!BatchedDiags.empty()) |
| 251 | SM = &(*BatchedDiags.begin())->begin()->getLocation().getManager(); |
Ted Kremenek | 5d86625 | 2008-11-03 22:33:57 +0000 | [diff] [blame] | 252 | |
Ted Kremenek | ddf32da | 2009-01-21 00:42:24 +0000 | [diff] [blame] | 253 | for (std::vector<const PathDiagnostic*>::iterator DI = BatchedDiags.begin(), |
| 254 | DE = BatchedDiags.end(); DI != DE; ++DI) { |
| 255 | |
| 256 | const PathDiagnostic *D = *DI; |
| 257 | |
| 258 | for (PathDiagnostic::const_iterator I=D->begin(), E=D->end(); I!=E; ++I) { |
| 259 | AddFID(FM, Fids, SM, I->getLocation()); |
| 260 | |
| 261 | for (PathDiagnosticPiece::range_iterator RI=I->ranges_begin(), |
| 262 | RE=I->ranges_end(); RI!=RE; ++RI) { |
| 263 | AddFID(FM, Fids, SM, RI->getBegin()); |
| 264 | AddFID(FM, Fids, SM, RI->getEnd()); |
| 265 | } |
Ted Kremenek | 5d86625 | 2008-11-03 22:33:57 +0000 | [diff] [blame] | 266 | } |
| 267 | } |
| 268 | |
Ted Kremenek | ddf32da | 2009-01-21 00:42:24 +0000 | [diff] [blame] | 269 | // Open the file. |
Ted Kremenek | 5d86625 | 2008-11-03 22:33:57 +0000 | [diff] [blame] | 270 | std::string ErrMsg; |
Ted Kremenek | ddf32da | 2009-01-21 00:42:24 +0000 | [diff] [blame] | 271 | llvm::raw_fd_ostream o(OutputFile.c_str(), false, ErrMsg); |
Ted Kremenek | 5d86625 | 2008-11-03 22:33:57 +0000 | [diff] [blame] | 272 | if (!ErrMsg.empty()) { |
Ted Kremenek | ddf32da | 2009-01-21 00:42:24 +0000 | [diff] [blame] | 273 | llvm::errs() << "warning: could not creat file: " << OutputFile << '\n'; |
Ted Kremenek | 5d86625 | 2008-11-03 22:33:57 +0000 | [diff] [blame] | 274 | return; |
| 275 | } |
| 276 | |
| 277 | // Write the plist header. |
| 278 | o << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" |
Ted Kremenek | ddf32da | 2009-01-21 00:42:24 +0000 | [diff] [blame] | 279 | "<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" " |
| 280 | "http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n" |
| 281 | "<plist version=\"1.0\">\n"; |
Ted Kremenek | 5d86625 | 2008-11-03 22:33:57 +0000 | [diff] [blame] | 282 | |
| 283 | // Write the root object: a <dict> containing... |
| 284 | // - "files", an <array> mapping from FIDs to file names |
| 285 | // - "diagnostics", an <array> containing the path diagnostics |
| 286 | o << "<dict>\n" |
| 287 | " <key>files</key>\n" |
| 288 | " <array>\n"; |
| 289 | |
Chris Lattner | 2b2453a | 2009-01-17 06:22:33 +0000 | [diff] [blame] | 290 | for (llvm::SmallVectorImpl<FileID>::iterator I=Fids.begin(), E=Fids.end(); |
Ted Kremenek | 5d86625 | 2008-11-03 22:33:57 +0000 | [diff] [blame] | 291 | I!=E; ++I) |
Ted Kremenek | c472d79 | 2009-01-23 20:06:20 +0000 | [diff] [blame] | 292 | o << " <string>" << SM->getFileEntryForID(*I)->getName() << "</string>\n"; |
Ted Kremenek | 5d86625 | 2008-11-03 22:33:57 +0000 | [diff] [blame] | 293 | |
| 294 | o << " </array>\n" |
| 295 | " <key>diagnostics</key>\n" |
| 296 | " <array>\n"; |
| 297 | |
Ted Kremenek | ddf32da | 2009-01-21 00:42:24 +0000 | [diff] [blame] | 298 | for (std::vector<const PathDiagnostic*>::iterator DI=BatchedDiags.begin(), |
| 299 | DE = BatchedDiags.end(); DI!=DE; ++DI) { |
| 300 | |
| 301 | o << " <dict>\n" |
| 302 | " <key>path</key>\n"; |
| 303 | |
| 304 | const PathDiagnostic *D = *DI; |
| 305 | // Create an owning smart pointer for 'D' just so that we auto-free it |
| 306 | // when we exit this method. |
| 307 | llvm::OwningPtr<PathDiagnostic> OwnedD(const_cast<PathDiagnostic*>(D)); |
| 308 | |
| 309 | o << " <array>\n"; |
| 310 | |
| 311 | for (PathDiagnostic::const_iterator I=D->begin(), E=D->end(); I != E; ++I) |
| 312 | ReportDiag(o, *I, FM, SM); |
| 313 | |
| 314 | o << " </array>\n"; |
| 315 | |
| 316 | // Output the bug type and bug category. |
Ted Kremenek | 082cb8d | 2009-03-12 18:41:53 +0000 | [diff] [blame] | 317 | o << " <key>description</key><string>" << D->getDescription() |
Ted Kremenek | ddf32da | 2009-01-21 00:42:24 +0000 | [diff] [blame] | 318 | << "</string>\n" |
Ted Kremenek | 082cb8d | 2009-03-12 18:41:53 +0000 | [diff] [blame] | 319 | << " <key>category</key><string>" << D->getCategory() |
Ted Kremenek | ddf32da | 2009-01-21 00:42:24 +0000 | [diff] [blame] | 320 | << "</string>\n" |
Ted Kremenek | 082cb8d | 2009-03-12 18:41:53 +0000 | [diff] [blame] | 321 | << " <key>type</key><string>" << D->getBugType() |
Ted Kremenek | ca1bada | 2009-03-27 15:31:11 +0000 | [diff] [blame] | 322 | << "</string>\n"; |
| 323 | |
| 324 | // Output the location of the bug. |
| 325 | o << " <key>location</key>\n"; |
| 326 | EmitLocation(o, SM, D->getLocation(), FM, 2); |
| 327 | |
| 328 | o << " </dict>\n"; |
Ted Kremenek | 082cb8d | 2009-03-12 18:41:53 +0000 | [diff] [blame] | 329 | |
Ted Kremenek | ddf32da | 2009-01-21 00:42:24 +0000 | [diff] [blame] | 330 | } |
Ted Kremenek | 5d86625 | 2008-11-03 22:33:57 +0000 | [diff] [blame] | 331 | |
| 332 | o << " </array>\n"; |
Ted Kremenek | ddf32da | 2009-01-21 00:42:24 +0000 | [diff] [blame] | 333 | |
Ted Kremenek | 5d86625 | 2008-11-03 22:33:57 +0000 | [diff] [blame] | 334 | // Finish. |
Ted Kremenek | 4fc82c8 | 2008-11-03 23:18:07 +0000 | [diff] [blame] | 335 | o << "</dict>\n</plist>"; |
Ted Kremenek | 5d86625 | 2008-11-03 22:33:57 +0000 | [diff] [blame] | 336 | } |