10 #ifndef LLVM_CLANG_BASIC_PLISTSUPPORT_H 11 #define LLVM_CLANG_BASIC_PLISTSUPPORT_H 16 #include "llvm/ADT/DenseMap.h" 17 #include "llvm/ADT/SmallVector.h" 18 #include "llvm/ADT/StringRef.h" 19 #include "llvm/Support/raw_ostream.h" 26 using FIDMap = llvm::DenseMap<FileID, unsigned>;
30 FIDMap::iterator I = FIDs.find(FID);
33 unsigned NewValue = V.size();
42 return AddFID(FIDs, V, FID);
46 FIDMap::const_iterator I = FIDs.find(FID);
47 assert(I != FIDs.end());
57 inline raw_ostream &
Indent(raw_ostream &o,
const unsigned indent) {
58 for (
unsigned i = 0; i < indent; ++i)
64 static const char *PlistHeader =
65 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" 66 "<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" " 67 "\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n" 68 "<plist version=\"1.0\">\n";
69 return o << PlistHeader;
72 inline raw_ostream &
EmitInteger(raw_ostream &o, int64_t value) {
79 inline raw_ostream &
EmitString(raw_ostream &o, StringRef s) {
81 for (StringRef::const_iterator I = s.begin(), E = s.end(); I != E; ++I) {
114 Indent(o, indent) <<
"<dict>\n";
115 Indent(o, indent) <<
" <key>line</key>";
117 Indent(o, indent) <<
" <key>col</key>";
119 Indent(o, indent) <<
" <key>file</key>";
121 Indent(o, indent) <<
"</dict>\n";
128 assert(R.
isCharRange() &&
"cannot handle a token range");
129 Indent(o, indent) <<
"<array>\n";
132 Indent(o, indent) <<
"</array>\n";
138 #endif // LLVM_CLANG_BASIC_PLISTSUPPORT_H void EmitLocation(raw_ostream &o, const SourceManager &SM, SourceLocation L, const FIDMap &FM, unsigned indent)
unsigned GetFID(const FIDMap &FIDs, FileID FID)
Defines the SourceManager interface.
raw_ostream & EmitInteger(raw_ostream &o, int64_t value)
SourceLocation getBegin() const
unsigned AddFID(FIDMap &FIDs, SmallVectorImpl< FileID > &V, FileID FID)
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
SourceLocation getExpansionLoc(SourceLocation Loc) const
Given a SourceLocation object Loc, return the expansion location referenced by the ID...
unsigned getExpansionColumnNumber(bool *Invalid=nullptr) const
Represents a character-granular source range.
llvm::DenseMap< FileID, unsigned > FIDMap
Encodes a location in the source.
raw_ostream & EmitPlistHeader(raw_ostream &o)
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
Dataflow Directional Tag Classes.
raw_ostream & Indent(raw_ostream &o, const unsigned indent)
void EmitRange(raw_ostream &o, const SourceManager &SM, CharSourceRange R, const FIDMap &FM, unsigned indent)
unsigned getExpansionLineNumber(bool *Invalid=nullptr) const
FileID getFileID(SourceLocation SpellingLoc) const
Return the FileID for a SourceLocation.
SourceLocation getEnd() const
raw_ostream & EmitString(raw_ostream &o, StringRef s)
Defines the clang::SourceLocation class and associated facilities.
A SourceLocation and its associated SourceManager.
This class handles loading and caching of source files into memory.