10 #ifndef LLVM_CLANG_BASIC_PLISTSUPPORT_H
11 #define LLVM_CLANG_BASIC_PLISTSUPPORT_H
15 #include "llvm/Support/raw_ostream.h"
19 typedef llvm::DenseMap<FileID, unsigned>
FIDMap;
24 FIDMap::iterator I = FIDs.find(FID);
34 FIDMap::const_iterator I = FIDs.find(FID);
35 assert(I != FIDs.end());
39 inline raw_ostream &
Indent(raw_ostream &o,
const unsigned indent) {
40 for (
unsigned i = 0; i < indent; ++i)
46 static const char *PlistHeader =
47 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
48 "<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" "
49 "\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n"
50 "<plist version=\"1.0\">\n";
51 return o << PlistHeader;
54 inline raw_ostream &
EmitInteger(raw_ostream &o, int64_t value) {
61 inline raw_ostream &
EmitString(raw_ostream &o, StringRef s) {
63 for (StringRef::const_iterator I = s.begin(), E = s.end(); I != E; ++I) {
96 Indent(o, indent) <<
"<dict>\n";
97 Indent(o, indent) <<
" <key>line</key>";
99 Indent(o, indent) <<
" <key>col</key>";
101 Indent(o, indent) <<
" <key>file</key>";
103 Indent(o, indent) <<
"</dict>\n";
110 assert(R.
isCharRange() &&
"cannot handle a token range");
111 Indent(o, indent) <<
"<array>\n";
114 Indent(o, indent) <<
"</array>\n";
void AddFID(FIDMap &FIDs, SmallVectorImpl< FileID > &V, const SourceManager &SM, SourceLocation L)
void EmitLocation(raw_ostream &o, const SourceManager &SM, SourceLocation L, const FIDMap &FM, unsigned indent)
SourceLocation getBegin() const
Defines the clang::FileManager interface and associated types.
Defines the SourceManager interface.
raw_ostream & EmitInteger(raw_ostream &o, int64_t value)
unsigned getExpansionLineNumber(bool *Invalid=nullptr) const
unsigned getExpansionColumnNumber(bool *Invalid=nullptr) const
FileID getFileID(SourceLocation SpellingLoc) const
Return the FileID for a SourceLocation.
unsigned GetFID(const FIDMap &FIDs, const SourceManager &SM, SourceLocation L)
Represents a character-granular source range.
SourceLocation getEnd() const
Encodes a location in the source. The SourceManager can decode this to get at the full include stack...
llvm::DenseMap< FileID, unsigned > FIDMap
raw_ostream & EmitPlistHeader(raw_ostream &o)
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
raw_ostream & Indent(raw_ostream &o, const unsigned indent)
void EmitRange(raw_ostream &o, const SourceManager &SM, CharSourceRange R, const FIDMap &FM, unsigned indent)
raw_ostream & EmitString(raw_ostream &o, StringRef s)
A SourceLocation and its associated SourceManager.
SourceLocation getExpansionLoc(SourceLocation Loc) const
Given a SourceLocation object Loc, return the expansion location referenced by the ID...
This class handles loading and caching of source files into memory.