clang: include/clang/Basic/PlistSupport.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9#ifndef LLVM_CLANG_BASIC_PLISTSUPPORT_H
10#define LLVM_CLANG_BASIC_PLISTSUPPORT_H
11
15#include "llvm/ADT/DenseMap.h"
16#include "llvm/ADT/SmallVector.h"
17#include "llvm/ADT/StringRef.h"
18#include "llvm/Support/raw_ostream.h"
19#include
20#include
21
24
25using FIDMap = llvm::DenseMap<FileID, unsigned>;
26
29 auto [I, Inserted] = FIDs.try_emplace(FID, V.size());
30 if (Inserted)
31 V.push_back(FID);
32 return I->second;
33}
34
37 FileID FID = SM.getFileID(SM.getExpansionLoc(L));
38 return AddFID(FIDs, V, FID);
39}
40
42 FIDMap::const_iterator I = FIDs.find(FID);
43 assert(I != FIDs.end());
44 return I->second;
45}
46
49 FileID FID = SM.getFileID(SM.getExpansionLoc(L));
50 return GetFID(FIDs, FID);
51}
52
53inline raw_ostream &Indent(raw_ostream &o, const unsigned indent) {
54 for (unsigned i = 0; i < indent; ++i)
55 o << ' ';
56 return o;
57}
58
60 static const char *PlistHeader =
61 "\n"
62 "<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" "
64 "<plist version=\"1.0\">\n";
65 return o << PlistHeader;
66}
67
68inline raw_ostream &EmitInteger(raw_ostream &o, int64_t value) {
69 o << "";
70 o << value;
71 o << "";
72 return o;
73}
74
75inline raw_ostream &EmitString(raw_ostream &o, StringRef s) {
76 o << "";
78 switch (c) {
79 default:
80 o << c;
81 break;
82 case '&':
83 o << "&";
84 break;
85 case '<':
86 o << "<";
87 break;
88 case '>':
89 o << ">";
90 break;
91 case '\'':
92 o << "'";
93 break;
94 case '\"':
95 o << """;
96 break;
97 }
98 }
99 o << "";
100 return o;
101}
102
106
108
109 Indent(o, indent) << "\n";
110 Indent(o, indent) << " line";
112 Indent(o, indent) << " col";
114 Indent(o, indent) << " file";
116 Indent(o, indent) << "\n";
117}
118
122
123 assert(R.isCharRange() && "cannot handle a token range");
124 Indent(o, indent) << "\n";
126
127
128
129
131 Indent(o, indent) << "\n";
132}
133
134}
135}
136
137#endif
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines the clang::SourceLocation class and associated facilities.
Defines the SourceManager interface.
__device__ __2f16 float __ockl_bool s
__device__ __2f16 float c
Represents a character-granular source range.
SourceLocation getEnd() const
SourceLocation getBegin() const
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
A SourceLocation and its associated SourceManager.
unsigned getExpansionColumnNumber(bool *Invalid=nullptr) const
unsigned getExpansionLineNumber(bool *Invalid=nullptr) const
Encodes a location in the source.
SourceLocation getLocWithOffset(IntTy Offset) const
Return a source location with the specified offset from this SourceLocation.
This class handles loading and caching of source files into memory.
Definition PlistSupport.h:23
void EmitRange(raw_ostream &o, const SourceManager &SM, CharSourceRange R, const FIDMap &FM, unsigned indent)
Definition PlistSupport.h:119
raw_ostream & EmitString(raw_ostream &o, StringRef s)
Definition PlistSupport.h:75
llvm::DenseMap< FileID, unsigned > FIDMap
Definition PlistSupport.h:25
unsigned GetFID(const FIDMap &FIDs, FileID FID)
Definition PlistSupport.h:41
unsigned AddFID(FIDMap &FIDs, SmallVectorImpl< FileID > &V, FileID FID)
Definition PlistSupport.h:27
raw_ostream & EmitInteger(raw_ostream &o, int64_t value)
Definition PlistSupport.h:68
raw_ostream & EmitPlistHeader(raw_ostream &o)
Definition PlistSupport.h:59
raw_ostream & Indent(raw_ostream &o, const unsigned indent)
Definition PlistSupport.h:53
void EmitLocation(raw_ostream &o, const SourceManager &SM, SourceLocation L, const FIDMap &FM, unsigned indent)
Definition PlistSupport.h:103
The JSON file list parser is used to communicate input to InstallAPI.