Ted Kremenek | 8588896 | 2008-10-21 00:54:44 +0000 | [diff] [blame] | 1 | //===--- CacheTokens.cpp - Caching of lexer tokens for PCH support --------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This provides a possible implementation of PCH support for Clang that is |
| 11 | // based on caching lexed tokens and identifiers. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #include "clang.h" |
| 16 | #include "clang/Basic/FileManager.h" |
| 17 | #include "clang/Basic/SourceManager.h" |
| 18 | #include "clang/Basic/IdentifierTable.h" |
| 19 | #include "clang/Basic/Diagnostic.h" |
| 20 | #include "clang/Lex/Lexer.h" |
| 21 | #include "clang/Lex/Preprocessor.h" |
| 22 | #include "llvm/Support/MemoryBuffer.h" |
| 23 | #include "llvm/Support/raw_ostream.h" |
Ted Kremenek | fc7e2ea | 2008-12-02 19:44:08 +0000 | [diff] [blame] | 24 | #include "llvm/System/Path.h" |
Ted Kremenek | 8588896 | 2008-10-21 00:54:44 +0000 | [diff] [blame] | 25 | |
| 26 | using namespace clang; |
| 27 | |
Ted Kremenek | fc7e2ea | 2008-12-02 19:44:08 +0000 | [diff] [blame] | 28 | typedef uint32_t Offset; |
| 29 | |
Ted Kremenek | fb645b6 | 2008-12-11 23:36:38 +0000 | [diff] [blame] | 30 | typedef llvm::DenseMap<const FileEntry*,std::pair<Offset,Offset> > PCHMap; |
Ted Kremenek | fc7e2ea | 2008-12-02 19:44:08 +0000 | [diff] [blame] | 31 | typedef llvm::DenseMap<const IdentifierInfo*,uint32_t> IDMap; |
Ted Kremenek | 8588896 | 2008-10-21 00:54:44 +0000 | [diff] [blame] | 32 | |
| 33 | static void Emit32(llvm::raw_ostream& Out, uint32_t V) { |
| 34 | Out << (unsigned char)(V); |
| 35 | Out << (unsigned char)(V >> 8); |
| 36 | Out << (unsigned char)(V >> 16); |
| 37 | Out << (unsigned char)(V >> 24); |
| 38 | } |
| 39 | |
| 40 | static void Emit8(llvm::raw_ostream& Out, uint32_t V) { |
| 41 | Out << (unsigned char)(V); |
| 42 | } |
| 43 | |
| 44 | static void EmitBuf(llvm::raw_ostream& Out, const char* I, const char* E) { |
| 45 | for ( ; I != E ; ++I) Out << *I; |
| 46 | } |
| 47 | |
| 48 | static uint32_t ResolveID(IDMap& IM, uint32_t& idx, const IdentifierInfo* II) { |
Ted Kremenek | fc7e2ea | 2008-12-02 19:44:08 +0000 | [diff] [blame] | 49 | |
| 50 | // Null IdentifierInfo's map to the persistent ID 0. |
| 51 | if (!II) |
| 52 | return 0; |
| 53 | |
Ted Kremenek | 8588896 | 2008-10-21 00:54:44 +0000 | [diff] [blame] | 54 | IDMap::iterator I = IM.find(II); |
| 55 | |
| 56 | if (I == IM.end()) { |
Ted Kremenek | fc7e2ea | 2008-12-02 19:44:08 +0000 | [diff] [blame] | 57 | IM[II] = ++idx; // Pre-increment since '0' is reserved for NULL. |
| 58 | return idx; |
Ted Kremenek | 8588896 | 2008-10-21 00:54:44 +0000 | [diff] [blame] | 59 | } |
| 60 | |
Ted Kremenek | fc7e2ea | 2008-12-02 19:44:08 +0000 | [diff] [blame] | 61 | return I->second; // We've already added 1. |
Ted Kremenek | 8588896 | 2008-10-21 00:54:44 +0000 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | static void EmitToken(llvm::raw_ostream& Out, const Token& T, |
Ted Kremenek | fc7e2ea | 2008-12-02 19:44:08 +0000 | [diff] [blame] | 65 | const SourceManager& SMgr, |
Ted Kremenek | 8588896 | 2008-10-21 00:54:44 +0000 | [diff] [blame] | 66 | uint32_t& idcount, IDMap& IM) { |
Ted Kremenek | fc7e2ea | 2008-12-02 19:44:08 +0000 | [diff] [blame] | 67 | |
Ted Kremenek | 8588896 | 2008-10-21 00:54:44 +0000 | [diff] [blame] | 68 | Emit8(Out, T.getKind()); |
| 69 | Emit8(Out, T.getFlags()); |
| 70 | Emit32(Out, ResolveID(IM, idcount, T.getIdentifierInfo())); |
Ted Kremenek | fc7e2ea | 2008-12-02 19:44:08 +0000 | [diff] [blame] | 71 | Emit32(Out, SMgr.getFullFilePos(T.getLocation())); |
Ted Kremenek | 8588896 | 2008-10-21 00:54:44 +0000 | [diff] [blame] | 72 | Emit32(Out, T.getLength()); |
| 73 | } |
| 74 | |
Ted Kremenek | fa59aad | 2008-11-26 23:58:26 +0000 | [diff] [blame] | 75 | struct IDData { |
| 76 | const IdentifierInfo* II; |
| 77 | uint32_t FileOffset; |
| 78 | const IdentifierTable::const_iterator::value_type* Str; |
| 79 | }; |
Ted Kremenek | a3d764c | 2008-11-26 03:36:26 +0000 | [diff] [blame] | 80 | |
Ted Kremenek | fc7e2ea | 2008-12-02 19:44:08 +0000 | [diff] [blame] | 81 | static std::pair<Offset,Offset> |
Ted Kremenek | fa59aad | 2008-11-26 23:58:26 +0000 | [diff] [blame] | 82 | EmitIdentifierTable(llvm::raw_fd_ostream& Out, uint32_t max, |
| 83 | const IdentifierTable& T, const IDMap& IM) { |
| 84 | |
| 85 | // Build an inverse map from persistent IDs -> IdentifierInfo*. |
Ted Kremenek | fc7e2ea | 2008-12-02 19:44:08 +0000 | [diff] [blame] | 86 | typedef std::vector<IDData> InverseIDMap; |
Ted Kremenek | fa59aad | 2008-11-26 23:58:26 +0000 | [diff] [blame] | 87 | InverseIDMap IIDMap; |
Ted Kremenek | fc7e2ea | 2008-12-02 19:44:08 +0000 | [diff] [blame] | 88 | IIDMap.resize(max); |
Ted Kremenek | 8588896 | 2008-10-21 00:54:44 +0000 | [diff] [blame] | 89 | |
Ted Kremenek | fa59aad | 2008-11-26 23:58:26 +0000 | [diff] [blame] | 90 | // Generate mapping from persistent IDs -> IdentifierInfo*. |
Ted Kremenek | fc7e2ea | 2008-12-02 19:44:08 +0000 | [diff] [blame] | 91 | for (IDMap::const_iterator I=IM.begin(), E=IM.end(); I!=E; ++I) { |
| 92 | // Decrement by 1 because we are using a vector for the lookup and |
| 93 | // 0 is reserved for NULL. |
| 94 | assert(I->second > 0); |
| 95 | assert(I->second-1 < IIDMap.size()); |
| 96 | IIDMap[I->second-1].II = I->first; |
| 97 | } |
Ted Kremenek | 8588896 | 2008-10-21 00:54:44 +0000 | [diff] [blame] | 98 | |
Ted Kremenek | fa59aad | 2008-11-26 23:58:26 +0000 | [diff] [blame] | 99 | // Get the string data associated with the IdentifierInfo. |
| 100 | for (IdentifierTable::const_iterator I=T.begin(), E=T.end(); I!=E; ++I) { |
| 101 | IDMap::const_iterator IDI = IM.find(&(I->getValue())); |
| 102 | if (IDI == IM.end()) continue; |
Ted Kremenek | fc7e2ea | 2008-12-02 19:44:08 +0000 | [diff] [blame] | 103 | IIDMap[IDI->second-1].Str = &(*I); |
Ted Kremenek | fa59aad | 2008-11-26 23:58:26 +0000 | [diff] [blame] | 104 | } |
| 105 | |
Ted Kremenek | fc7e2ea | 2008-12-02 19:44:08 +0000 | [diff] [blame] | 106 | Offset DataOff = Out.tell(); |
Ted Kremenek | 6183e48 | 2008-12-03 01:16:39 +0000 | [diff] [blame] | 107 | |
Ted Kremenek | fa59aad | 2008-11-26 23:58:26 +0000 | [diff] [blame] | 108 | for (InverseIDMap::iterator I=IIDMap.begin(), E=IIDMap.end(); I!=E; ++I) { |
Ted Kremenek | fc7e2ea | 2008-12-02 19:44:08 +0000 | [diff] [blame] | 109 | // Record the location for this data. |
| 110 | I->FileOffset = Out.tell(); |
| 111 | // Write out the keyword. |
| 112 | unsigned len = I->Str->getKeyLength(); |
Ted Kremenek | 8588896 | 2008-10-21 00:54:44 +0000 | [diff] [blame] | 113 | Emit32(Out, len); |
Ted Kremenek | fa59aad | 2008-11-26 23:58:26 +0000 | [diff] [blame] | 114 | const char* buf = I->Str->getKeyData(); |
Ted Kremenek | a3d764c | 2008-11-26 03:36:26 +0000 | [diff] [blame] | 115 | EmitBuf(Out, buf, buf+len); |
Ted Kremenek | 8588896 | 2008-10-21 00:54:44 +0000 | [diff] [blame] | 116 | } |
Ted Kremenek | a3d764c | 2008-11-26 03:36:26 +0000 | [diff] [blame] | 117 | |
Ted Kremenek | fa59aad | 2008-11-26 23:58:26 +0000 | [diff] [blame] | 118 | // Now emit the table mapping from persistent IDs to PTH file offsets. |
Ted Kremenek | fc7e2ea | 2008-12-02 19:44:08 +0000 | [diff] [blame] | 119 | Offset IDOff = Out.tell(); |
Ted Kremenek | fa59aad | 2008-11-26 23:58:26 +0000 | [diff] [blame] | 120 | |
Ted Kremenek | 6183e48 | 2008-12-03 01:16:39 +0000 | [diff] [blame] | 121 | // Emit the number of identifiers. |
| 122 | Emit32(Out, max); |
| 123 | |
Ted Kremenek | fa59aad | 2008-11-26 23:58:26 +0000 | [diff] [blame] | 124 | for (InverseIDMap::iterator I=IIDMap.begin(), E=IIDMap.end(); I!=E; ++I) |
Ted Kremenek | fc7e2ea | 2008-12-02 19:44:08 +0000 | [diff] [blame] | 125 | Emit32(Out, I->FileOffset); |
| 126 | |
Ted Kremenek | fa59aad | 2008-11-26 23:58:26 +0000 | [diff] [blame] | 127 | return std::make_pair(DataOff, IDOff); |
Ted Kremenek | 8588896 | 2008-10-21 00:54:44 +0000 | [diff] [blame] | 128 | } |
| 129 | |
Ted Kremenek | fc7e2ea | 2008-12-02 19:44:08 +0000 | [diff] [blame] | 130 | Offset EmitFileTable(llvm::raw_fd_ostream& Out, SourceManager& SM, PCHMap& PM) { |
Ted Kremenek | a3d764c | 2008-11-26 03:36:26 +0000 | [diff] [blame] | 131 | |
Ted Kremenek | fc7e2ea | 2008-12-02 19:44:08 +0000 | [diff] [blame] | 132 | Offset off = (Offset) Out.tell(); |
Ted Kremenek | fa59aad | 2008-11-26 23:58:26 +0000 | [diff] [blame] | 133 | |
| 134 | // Output the size of the table. |
| 135 | Emit32(Out, PM.size()); |
| 136 | |
| 137 | for (PCHMap::iterator I=PM.begin(), E=PM.end(); I!=E; ++I) { |
Ted Kremenek | fa59aad | 2008-11-26 23:58:26 +0000 | [diff] [blame] | 138 | const FileEntry* FE = I->first; |
Ted Kremenek | 8dffd9b | 2008-12-04 22:36:44 +0000 | [diff] [blame] | 139 | const char* Name = FE->getName(); |
| 140 | unsigned size = strlen(Name); |
| 141 | Emit32(Out, size); |
| 142 | EmitBuf(Out, Name, Name+size); |
Ted Kremenek | fb645b6 | 2008-12-11 23:36:38 +0000 | [diff] [blame] | 143 | Emit32(Out, I->second.first); |
| 144 | Emit32(Out, I->second.second); |
Ted Kremenek | fa59aad | 2008-11-26 23:58:26 +0000 | [diff] [blame] | 145 | } |
| 146 | |
Ted Kremenek | a3d764c | 2008-11-26 03:36:26 +0000 | [diff] [blame] | 147 | return off; |
| 148 | } |
| 149 | |
Ted Kremenek | fb645b6 | 2008-12-11 23:36:38 +0000 | [diff] [blame] | 150 | static std::pair<Offset,Offset> |
| 151 | LexTokens(llvm::raw_fd_ostream& Out, Lexer& L, Preprocessor& PP, |
| 152 | uint32_t& idcount, IDMap& IM) { |
Ted Kremenek | a3d764c | 2008-11-26 03:36:26 +0000 | [diff] [blame] | 153 | |
| 154 | // Record the location within the token file. |
Ted Kremenek | fc7e2ea | 2008-12-02 19:44:08 +0000 | [diff] [blame] | 155 | Offset off = (Offset) Out.tell(); |
| 156 | SourceManager& SMgr = PP.getSourceManager(); |
Ted Kremenek | fb645b6 | 2008-12-11 23:36:38 +0000 | [diff] [blame] | 157 | |
| 158 | // Keep track of matching '#if' ... '#endif'. |
| 159 | typedef std::vector<std::pair<Offset, unsigned> > PPCondTable; |
| 160 | PPCondTable PPCond; |
| 161 | std::vector<unsigned> PPStartCond; |
Ted Kremenek | a3d764c | 2008-11-26 03:36:26 +0000 | [diff] [blame] | 162 | |
| 163 | Token Tok; |
| 164 | |
| 165 | do { |
| 166 | L.LexFromRawLexer(Tok); |
| 167 | |
| 168 | if (Tok.is(tok::identifier)) { |
| 169 | Tok.setIdentifierInfo(PP.LookUpIdentifierInfo(Tok)); |
| 170 | } |
| 171 | else if (Tok.is(tok::hash) && Tok.isAtStartOfLine()) { |
| 172 | // Special processing for #include. Store the '#' token and lex |
| 173 | // the next token. |
Ted Kremenek | fb645b6 | 2008-12-11 23:36:38 +0000 | [diff] [blame] | 174 | Offset HashOff = (Offset) Out.tell(); |
Ted Kremenek | fc7e2ea | 2008-12-02 19:44:08 +0000 | [diff] [blame] | 175 | EmitToken(Out, Tok, SMgr, idcount, IM); |
Ted Kremenek | a3d764c | 2008-11-26 03:36:26 +0000 | [diff] [blame] | 176 | L.LexFromRawLexer(Tok); |
| 177 | |
| 178 | // Did we see 'include'/'import'/'include_next'? |
| 179 | if (!Tok.is(tok::identifier)) |
| 180 | continue; |
| 181 | |
| 182 | IdentifierInfo* II = PP.LookUpIdentifierInfo(Tok); |
| 183 | Tok.setIdentifierInfo(II); |
| 184 | tok::PPKeywordKind K = II->getPPKeywordID(); |
| 185 | |
| 186 | if (K == tok::pp_include || K == tok::pp_import || |
| 187 | K == tok::pp_include_next) { |
| 188 | |
| 189 | // Save the 'include' token. |
Ted Kremenek | fc7e2ea | 2008-12-02 19:44:08 +0000 | [diff] [blame] | 190 | EmitToken(Out, Tok, SMgr, idcount, IM); |
Ted Kremenek | a3d764c | 2008-11-26 03:36:26 +0000 | [diff] [blame] | 191 | |
| 192 | // Lex the next token as an include string. |
| 193 | L.setParsingPreprocessorDirective(true); |
| 194 | L.LexIncludeFilename(Tok); |
| 195 | L.setParsingPreprocessorDirective(false); |
| 196 | |
| 197 | if (Tok.is(tok::identifier)) |
| 198 | Tok.setIdentifierInfo(PP.LookUpIdentifierInfo(Tok)); |
| 199 | } |
Ted Kremenek | fb645b6 | 2008-12-11 23:36:38 +0000 | [diff] [blame] | 200 | else if (K == tok::pp_if || K == tok::pp_ifdef || K == tok::pp_ifndef) { |
| 201 | // Ad an entry for '#if' and friends. We initially set the target index |
| 202 | // to 0. This will get backpatched when we hit #endif. |
| 203 | PPStartCond.push_back(PPCond.size()); |
| 204 | PPCond.push_back(std::make_pair((Offset) HashOff, 0U)); |
| 205 | } |
| 206 | else if (K == tok::pp_endif) { |
| 207 | assert(!PPStartCond.empty()); |
| 208 | // Add an entry for '#endif'. We set the target table index to itself. |
| 209 | unsigned index = PPCond.size(); |
| 210 | PPCond.push_back(std::make_pair((Offset) HashOff, index)); |
| 211 | // Backpatch the opening '#if' entry. |
| 212 | assert(PPCond[PPStartCond.back()].second == 0); |
| 213 | PPCond[PPStartCond.back()].second = index; |
| 214 | PPStartCond.pop_back(); |
| 215 | } |
| 216 | else if (K == tok::pp_elif) { |
| 217 | assert(!PPStartCond.empty()); |
| 218 | // Add an entry for '#elif'. This serves as both a closing and |
| 219 | // opening of a conditional block. This means that its entry |
| 220 | // will get backpatched later. |
| 221 | unsigned index = PPCond.size(); |
| 222 | PPCond.push_back(std::make_pair((Offset) HashOff, 0U)); |
| 223 | // Backpatch the previous '#if' entry. |
| 224 | assert(PPCond[PPStartCond.back()].second == 0); |
| 225 | PPCond[PPStartCond.back()].second = index; |
| 226 | PPStartCond.pop_back(); |
| 227 | // Now add '#elif' as a new block opening. |
| 228 | PPStartCond.push_back(index); |
| 229 | } |
Ted Kremenek | a3d764c | 2008-11-26 03:36:26 +0000 | [diff] [blame] | 230 | } |
| 231 | } |
Ted Kremenek | fc7e2ea | 2008-12-02 19:44:08 +0000 | [diff] [blame] | 232 | while (EmitToken(Out, Tok, SMgr, idcount, IM), Tok.isNot(tok::eof)); |
Ted Kremenek | fb645b6 | 2008-12-11 23:36:38 +0000 | [diff] [blame] | 233 | |
| 234 | // Next write out PPCond. |
| 235 | Offset PPCondOff = (Offset) Out.tell(); |
| 236 | // Write out the size of PPCond so that clients can tell if the table is |
| 237 | // empty. |
| 238 | Emit32(Out, PPCond.size()); |
Ted Kremenek | fc7e2ea | 2008-12-02 19:44:08 +0000 | [diff] [blame] | 239 | |
Ted Kremenek | fb645b6 | 2008-12-11 23:36:38 +0000 | [diff] [blame] | 240 | for (PPCondTable::iterator I=PPCond.begin(), E=PPCond.end(); I!=E; ++I) { |
| 241 | Emit32(Out, I->first - off); |
| 242 | Emit32(Out, I->second); |
| 243 | } |
| 244 | |
| 245 | return std::make_pair(off,PPCondOff); |
Ted Kremenek | a3d764c | 2008-11-26 03:36:26 +0000 | [diff] [blame] | 246 | } |
Ted Kremenek | 8588896 | 2008-10-21 00:54:44 +0000 | [diff] [blame] | 247 | |
| 248 | void clang::CacheTokens(Preprocessor& PP, const std::string& OutFile) { |
| 249 | // Lex through the entire file. This will populate SourceManager with |
| 250 | // all of the header information. |
| 251 | Token Tok; |
| 252 | PP.EnterMainSourceFile(); |
| 253 | do { PP.Lex(Tok); } while (Tok.isNot(tok::eof)); |
| 254 | |
| 255 | // Iterate over all the files in SourceManager. Create a lexer |
| 256 | // for each file and cache the tokens. |
| 257 | SourceManager& SM = PP.getSourceManager(); |
| 258 | const LangOptions& LOpts = PP.getLangOptions(); |
| 259 | llvm::raw_ostream& os = llvm::errs(); |
| 260 | |
| 261 | PCHMap PM; |
| 262 | IDMap IM; |
Ted Kremenek | 8588896 | 2008-10-21 00:54:44 +0000 | [diff] [blame] | 263 | uint32_t idcount = 0; |
| 264 | |
| 265 | std::string ErrMsg; |
Daniel Dunbar | 26fb272 | 2008-11-13 05:09:21 +0000 | [diff] [blame] | 266 | llvm::raw_fd_ostream Out(OutFile.c_str(), true, ErrMsg); |
Ted Kremenek | 8588896 | 2008-10-21 00:54:44 +0000 | [diff] [blame] | 267 | |
| 268 | if (!ErrMsg.empty()) { |
Ted Kremenek | fc7e2ea | 2008-12-02 19:44:08 +0000 | [diff] [blame] | 269 | os << "PTH error: " << ErrMsg << "\n"; |
Ted Kremenek | 8588896 | 2008-10-21 00:54:44 +0000 | [diff] [blame] | 270 | return; |
| 271 | } |
| 272 | |
| 273 | for (SourceManager::fileid_iterator I=SM.fileid_begin(), E=SM.fileid_end(); |
| 274 | I!=E; ++I) { |
| 275 | |
| 276 | const SrcMgr::ContentCache* C = I.getFileIDInfo().getContentCache(); |
Ted Kremenek | a3d764c | 2008-11-26 03:36:26 +0000 | [diff] [blame] | 277 | if (!C) continue; |
Ted Kremenek | 8588896 | 2008-10-21 00:54:44 +0000 | [diff] [blame] | 278 | |
Ted Kremenek | a3d764c | 2008-11-26 03:36:26 +0000 | [diff] [blame] | 279 | const FileEntry* FE = C->Entry; // Does this entry correspond to a file? |
| 280 | if (!FE) continue; |
Ted Kremenek | fc7e2ea | 2008-12-02 19:44:08 +0000 | [diff] [blame] | 281 | |
| 282 | // FIXME: Handle files with non-absolute paths. |
| 283 | llvm::sys::Path P(FE->getName()); |
| 284 | if (!P.isAbsolute()) |
| 285 | continue; |
Ted Kremenek | 8588896 | 2008-10-21 00:54:44 +0000 | [diff] [blame] | 286 | |
Ted Kremenek | a3d764c | 2008-11-26 03:36:26 +0000 | [diff] [blame] | 287 | PCHMap::iterator PI = PM.find(FE); // Have we already processed this file? |
| 288 | if (PI != PM.end()) continue; |
| 289 | |
| 290 | const llvm::MemoryBuffer* B = C->Buffer; |
| 291 | if (!B) continue; |
| 292 | |
Ted Kremenek | 8588896 | 2008-10-21 00:54:44 +0000 | [diff] [blame] | 293 | Lexer L(SourceLocation::getFileLoc(I.getFileID(), 0), LOpts, |
| 294 | B->getBufferStart(), B->getBufferEnd(), B); |
Ted Kremenek | fb645b6 | 2008-12-11 23:36:38 +0000 | [diff] [blame] | 295 | |
Ted Kremenek | a3d764c | 2008-11-26 03:36:26 +0000 | [diff] [blame] | 296 | PM[FE] = LexTokens(Out, L, PP, idcount, IM); |
Daniel Dunbar | 31309ab | 2008-11-26 02:18:33 +0000 | [diff] [blame] | 297 | } |
Ted Kremenek | a3d764c | 2008-11-26 03:36:26 +0000 | [diff] [blame] | 298 | |
| 299 | // Write out the identifier table. |
Ted Kremenek | fc7e2ea | 2008-12-02 19:44:08 +0000 | [diff] [blame] | 300 | std::pair<Offset,Offset> IdTableOff = |
Ted Kremenek | fa59aad | 2008-11-26 23:58:26 +0000 | [diff] [blame] | 301 | EmitIdentifierTable(Out, idcount, PP.getIdentifierTable(), IM); |
Ted Kremenek | 8588896 | 2008-10-21 00:54:44 +0000 | [diff] [blame] | 302 | |
Ted Kremenek | a3d764c | 2008-11-26 03:36:26 +0000 | [diff] [blame] | 303 | // Write out the file table. |
Ted Kremenek | fc7e2ea | 2008-12-02 19:44:08 +0000 | [diff] [blame] | 304 | Offset FileTableOff = EmitFileTable(Out, SM, PM); |
Ted Kremenek | a3d764c | 2008-11-26 03:36:26 +0000 | [diff] [blame] | 305 | |
| 306 | // Finally, write out the offset table at the end. |
Ted Kremenek | fc7e2ea | 2008-12-02 19:44:08 +0000 | [diff] [blame] | 307 | Emit32(Out, IdTableOff.first); |
| 308 | Emit32(Out, IdTableOff.second); |
| 309 | Emit32(Out, FileTableOff); |
Ted Kremenek | 8588896 | 2008-10-21 00:54:44 +0000 | [diff] [blame] | 310 | } |