//
//===----------------------------------------------------------------------===//
+#ifndef LLVM_CLANG_PLISTSUPPORT_H
+#define LLVM_CLANG_PLISTSUPPORT_H
+
#include "llvm/Support/raw_ostream.h"
#include "clang/Basic/FileManager.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Lex/Lexer.h"
namespace clang {
-
+namespace markup {
typedef llvm::DenseMap<FileID, unsigned> FIDMap;
static const char *PlistHeader =
static void AddFID(FIDMap &FIDs, SmallVectorImpl<FileID> &V,
const SourceManager &SM, SourceLocation L) {
-
FileID FID = SM.getFileID(SM.getExpansionLoc(L));
FIDMap::iterator I = FIDs.find(FID);
if (I != FIDs.end())
const LangOptions &LangOpts, SourceLocation L,
const FIDMap &FM, unsigned indent,
bool extend = false) {
-
FullSourceLoc Loc(SM.getExpansionLoc(L), const_cast<SourceManager &>(SM));
// Add in the length of the token, so that we cover multi-char tokens.
return o;
}
}
+}
+
+#endif
#include "llvm/Support/Casting.h"
using namespace clang;
using namespace ento;
+using namespace markup;
namespace {
class PlistDiagnostics : public PathDiagnosticConsumer {
PP.getLangOpts(), true));
}
-static void EmitLocation(raw_ostream &o, const SourceManager &SM,
- const LangOptions &LangOpts,
- const PathDiagnosticLocation &L, const FIDMap& FM,
- unsigned indent, bool extend = false) {
- EmitLocation(o, SM, LangOpts, L.asLocation(), FM, indent, extend);
-}
-
-static void EmitRange(raw_ostream &o, const SourceManager &SM,
- const LangOptions &LangOpts,
- PathDiagnosticRange R, const FIDMap &FM,
- unsigned indent) {
- Indent(o, indent) << "<array>\n";
- EmitLocation(o, SM, LangOpts, R.getBegin(), FM, indent+1);
- EmitLocation(o, SM, LangOpts, R.getEnd(), FM, indent+1, !R.isPoint);
- Indent(o, indent) << "</array>\n";
-}
-
static void ReportControlFlow(raw_ostream &o,
const PathDiagnosticControlFlowPiece& P,
const FIDMap& FM,
// logic for clients.
Indent(o, indent) << "<key>start</key>\n";
SourceLocation StartEdge = I->getStart().asRange().getBegin();
- EmitRange(o, SM, LangOpts, SourceRange(StartEdge, StartEdge), FM, indent+1);
+ EmitRange(o, SM, LangOpts, CharSourceRange::getTokenRange(StartEdge), FM,
+ indent + 1);
Indent(o, indent) << "<key>end</key>\n";
SourceLocation EndEdge = I->getEnd().asRange().getBegin();
- EmitRange(o, SM, LangOpts, SourceRange(EndEdge, EndEdge), FM, indent+1);
+ EmitRange(o, SM, LangOpts, CharSourceRange::getTokenRange(EndEdge), FM,
+ indent + 1);
--indent;
Indent(o, indent) << "</dict>\n";
++indent;
for (ArrayRef<SourceRange>::iterator I = Ranges.begin(), E = Ranges.end();
I != E; ++I) {
- EmitRange(o, SM, LangOpts, *I, FM, indent+1);
+ EmitRange(o, SM, LangOpts, CharSourceRange::getTokenRange(*I), FM,
+ indent + 1);
}
--indent;
Indent(o, indent) << "</array>\n";
// Output the location of the bug.
o << " <key>location</key>\n";
- EmitLocation(o, *SM, LangOpts, D->getLocation(), FM, 2);
+ EmitLocation(o, *SM, LangOpts, D->getLocation().asLocation(), FM, 2);
// Output the diagnostic to the sub-diagnostic client, if any.
if (!filesMade->empty()) {