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>;
31 FIDMap::iterator I = FIDs.find(FID);
41 FIDMap::const_iterator I = FIDs.find(FID);
42 assert(I != FIDs.end());
46 inline raw_ostream &
Indent(raw_ostream &o,
const unsigned indent) {
47 for (
unsigned i = 0; i < indent; ++i)
53 static const char *PlistHeader =
54 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" 55 "<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" " 56 "\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n" 57 "<plist version=\"1.0\">\n";
58 return o << PlistHeader;
61 inline raw_ostream &
EmitInteger(raw_ostream &o, int64_t value) {
68 inline raw_ostream &
EmitString(raw_ostream &o, StringRef s) {
70 for (StringRef::const_iterator I = s.begin(), E = s.end(); I != E; ++I) {
103 Indent(o, indent) <<
"<dict>\n";
104 Indent(o, indent) <<
" <key>line</key>";
106 Indent(o, indent) <<
" <key>col</key>";
108 Indent(o, indent) <<
" <key>file</key>";
110 Indent(o, indent) <<
"</dict>\n";
117 assert(R.
isCharRange() &&
"cannot handle a token range");
118 Indent(o, indent) <<
"<array>\n";
121 Indent(o, indent) <<
"</array>\n";
127 #endif // LLVM_CLANG_BASIC_PLISTSUPPORT_H 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)
Defines the SourceManager interface.
raw_ostream & EmitInteger(raw_ostream &o, int64_t value)
SourceLocation getBegin() const
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
unsigned GetFID(const FIDMap &FIDs, const SourceManager &SM, SourceLocation L)
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.