Argyrios Kyrtzidis | b0f4b9a | 2011-03-09 17:21:42 +0000 | [diff] [blame] | 1 | //===- ChainedIncludesSource.cpp - Chained PCHs in Memory -------*- C++ -*-===// |
| 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 file defines the ChainedIncludesSource class, which converts headers |
| 11 | // to chained PCHs in memory, mainly used for testing. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
Chandler Carruth | 55fc873 | 2012-12-04 09:13:33 +0000 | [diff] [blame] | 15 | #include "clang/Basic/TargetInfo.h" |
Argyrios Kyrtzidis | b0f4b9a | 2011-03-09 17:21:42 +0000 | [diff] [blame] | 16 | #include "clang/Frontend/ASTUnit.h" |
Chandler Carruth | 55fc873 | 2012-12-04 09:13:33 +0000 | [diff] [blame] | 17 | #include "clang/Frontend/CompilerInstance.h" |
| 18 | #include "clang/Frontend/TextDiagnosticPrinter.h" |
| 19 | #include "clang/Lex/Preprocessor.h" |
| 20 | #include "clang/Parse/ParseAST.h" |
Chandler Carruth | 71088d1 | 2011-12-09 01:55:54 +0000 | [diff] [blame] | 21 | #include "clang/Serialization/ASTReader.h" |
| 22 | #include "clang/Serialization/ASTWriter.h" |
Argyrios Kyrtzidis | b0f4b9a | 2011-03-09 17:21:42 +0000 | [diff] [blame] | 23 | #include "llvm/Support/MemoryBuffer.h" |
| 24 | |
| 25 | using namespace clang; |
| 26 | |
Stephen Hines | c568f1e | 2014-07-21 00:47:37 -0700 | [diff] [blame] | 27 | namespace { |
| 28 | class ChainedIncludesSource : public ExternalSemaSource { |
| 29 | public: |
| 30 | virtual ~ChainedIncludesSource(); |
| 31 | |
| 32 | ExternalSemaSource &getFinalReader() const { return *FinalReader; } |
| 33 | |
| 34 | std::vector<CompilerInstance *> CIs; |
| 35 | IntrusiveRefCntPtr<ExternalSemaSource> FinalReader; |
| 36 | |
| 37 | protected: |
| 38 | //===----------------------------------------------------------------------===// |
| 39 | // ExternalASTSource interface. |
| 40 | //===----------------------------------------------------------------------===// |
| 41 | |
| 42 | Decl *GetExternalDecl(uint32_t ID) override; |
| 43 | Selector GetExternalSelector(uint32_t ID) override; |
| 44 | uint32_t GetNumExternalSelectors() override; |
| 45 | Stmt *GetExternalDeclStmt(uint64_t Offset) override; |
| 46 | CXXBaseSpecifier *GetExternalCXXBaseSpecifiers(uint64_t Offset) override; |
| 47 | bool FindExternalVisibleDeclsByName(const DeclContext *DC, |
| 48 | DeclarationName Name) override; |
| 49 | ExternalLoadResult |
| 50 | FindExternalLexicalDecls(const DeclContext *DC, |
| 51 | bool (*isKindWeWant)(Decl::Kind), |
| 52 | SmallVectorImpl<Decl *> &Result) override; |
| 53 | void CompleteType(TagDecl *Tag) override; |
| 54 | void CompleteType(ObjCInterfaceDecl *Class) override; |
| 55 | void StartedDeserializing() override; |
| 56 | void FinishedDeserializing() override; |
| 57 | void StartTranslationUnit(ASTConsumer *Consumer) override; |
| 58 | void PrintStats() override; |
| 59 | |
| 60 | /// Return the amount of memory used by memory buffers, breaking down |
| 61 | /// by heap-backed versus mmap'ed memory. |
| 62 | void getMemoryBufferSizes(MemoryBufferSizes &sizes) const override; |
| 63 | |
| 64 | //===----------------------------------------------------------------------===// |
| 65 | // ExternalSemaSource interface. |
| 66 | //===----------------------------------------------------------------------===// |
| 67 | |
| 68 | void InitializeSema(Sema &S) override; |
| 69 | void ForgetSema() override; |
| 70 | void ReadMethodPool(Selector Sel) override; |
| 71 | bool LookupUnqualified(LookupResult &R, Scope *S) override; |
| 72 | }; |
| 73 | } |
| 74 | |
Stephen Hines | 6bcf27b | 2014-05-29 04:14:42 -0700 | [diff] [blame] | 75 | static ASTReader * |
| 76 | createASTReader(CompilerInstance &CI, StringRef pchFile, |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame^] | 77 | SmallVectorImpl<std::unique_ptr<llvm::MemoryBuffer>> &MemBufs, |
Stephen Hines | 6bcf27b | 2014-05-29 04:14:42 -0700 | [diff] [blame] | 78 | SmallVectorImpl<std::string> &bufNames, |
| 79 | ASTDeserializationListener *deserialListener = nullptr) { |
Argyrios Kyrtzidis | b0f4b9a | 2011-03-09 17:21:42 +0000 | [diff] [blame] | 80 | Preprocessor &PP = CI.getPreprocessor(); |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 81 | std::unique_ptr<ASTReader> Reader; |
Douglas Gregor | f8a1e51 | 2011-09-02 00:26:20 +0000 | [diff] [blame] | 82 | Reader.reset(new ASTReader(PP, CI.getASTContext(), /*isysroot=*/"", |
Argyrios Kyrtzidis | b0f4b9a | 2011-03-09 17:21:42 +0000 | [diff] [blame] | 83 | /*DisableValidation=*/true)); |
Jonathan D. Turner | c24a1ee | 2011-08-02 17:40:32 +0000 | [diff] [blame] | 84 | for (unsigned ti = 0; ti < bufNames.size(); ++ti) { |
| 85 | StringRef sr(bufNames[ti]); |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame^] | 86 | Reader->addInMemoryBuffer(sr, std::move(MemBufs[ti])); |
Jonathan D. Turner | c24a1ee | 2011-08-02 17:40:32 +0000 | [diff] [blame] | 87 | } |
Argyrios Kyrtzidis | b0f4b9a | 2011-03-09 17:21:42 +0000 | [diff] [blame] | 88 | Reader->setDeserializationListener(deserialListener); |
Argyrios Kyrtzidis | 958bcaf | 2012-11-15 18:57:22 +0000 | [diff] [blame] | 89 | switch (Reader->ReadAST(pchFile, serialization::MK_PCH, SourceLocation(), |
Douglas Gregor | 38295be | 2012-10-22 23:51:00 +0000 | [diff] [blame] | 90 | ASTReader::ARR_None)) { |
Argyrios Kyrtzidis | b0f4b9a | 2011-03-09 17:21:42 +0000 | [diff] [blame] | 91 | case ASTReader::Success: |
| 92 | // Set the predefines buffer as suggested by the PCH reader. |
| 93 | PP.setPredefines(Reader->getSuggestedPredefines()); |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 94 | return Reader.release(); |
Argyrios Kyrtzidis | b0f4b9a | 2011-03-09 17:21:42 +0000 | [diff] [blame] | 95 | |
| 96 | case ASTReader::Failure: |
Douglas Gregor | 677e15f | 2013-03-19 00:28:20 +0000 | [diff] [blame] | 97 | case ASTReader::Missing: |
Douglas Gregor | 4825fd7 | 2012-10-22 22:50:17 +0000 | [diff] [blame] | 98 | case ASTReader::OutOfDate: |
| 99 | case ASTReader::VersionMismatch: |
| 100 | case ASTReader::ConfigurationMismatch: |
| 101 | case ASTReader::HadErrors: |
Argyrios Kyrtzidis | b0f4b9a | 2011-03-09 17:21:42 +0000 | [diff] [blame] | 102 | break; |
| 103 | } |
Stephen Hines | 6bcf27b | 2014-05-29 04:14:42 -0700 | [diff] [blame] | 104 | return nullptr; |
Argyrios Kyrtzidis | b0f4b9a | 2011-03-09 17:21:42 +0000 | [diff] [blame] | 105 | } |
| 106 | |
| 107 | ChainedIncludesSource::~ChainedIncludesSource() { |
| 108 | for (unsigned i = 0, e = CIs.size(); i != e; ++i) |
| 109 | delete CIs[i]; |
| 110 | } |
| 111 | |
Stephen Hines | c568f1e | 2014-07-21 00:47:37 -0700 | [diff] [blame] | 112 | IntrusiveRefCntPtr<ExternalSemaSource> clang::createChainedIncludesSource( |
| 113 | CompilerInstance &CI, IntrusiveRefCntPtr<ExternalSemaSource> &Reader) { |
Argyrios Kyrtzidis | b0f4b9a | 2011-03-09 17:21:42 +0000 | [diff] [blame] | 114 | |
| 115 | std::vector<std::string> &includes = CI.getPreprocessorOpts().ChainedIncludes; |
| 116 | assert(!includes.empty() && "No '-chain-include' in options!"); |
| 117 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 118 | IntrusiveRefCntPtr<ChainedIncludesSource> source(new ChainedIncludesSource()); |
Argyrios Kyrtzidis | 8616f9a | 2012-11-09 19:40:39 +0000 | [diff] [blame] | 119 | InputKind IK = CI.getFrontendOpts().Inputs[0].getKind(); |
Argyrios Kyrtzidis | b0f4b9a | 2011-03-09 17:21:42 +0000 | [diff] [blame] | 120 | |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame^] | 121 | SmallVector<std::unique_ptr<llvm::MemoryBuffer>, 4> SerialBufs; |
Jonathan D. Turner | c24a1ee | 2011-08-02 17:40:32 +0000 | [diff] [blame] | 122 | SmallVector<std::string, 4> serialBufNames; |
Argyrios Kyrtzidis | b0f4b9a | 2011-03-09 17:21:42 +0000 | [diff] [blame] | 123 | |
| 124 | for (unsigned i = 0, e = includes.size(); i != e; ++i) { |
| 125 | bool firstInclude = (i == 0); |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 126 | std::unique_ptr<CompilerInvocation> CInvok; |
Argyrios Kyrtzidis | b0f4b9a | 2011-03-09 17:21:42 +0000 | [diff] [blame] | 127 | CInvok.reset(new CompilerInvocation(CI.getInvocation())); |
| 128 | |
| 129 | CInvok->getPreprocessorOpts().ChainedIncludes.clear(); |
| 130 | CInvok->getPreprocessorOpts().ImplicitPCHInclude.clear(); |
| 131 | CInvok->getPreprocessorOpts().ImplicitPTHInclude.clear(); |
| 132 | CInvok->getPreprocessorOpts().DisablePCHValidation = true; |
| 133 | CInvok->getPreprocessorOpts().Includes.clear(); |
| 134 | CInvok->getPreprocessorOpts().MacroIncludes.clear(); |
| 135 | CInvok->getPreprocessorOpts().Macros.clear(); |
| 136 | |
| 137 | CInvok->getFrontendOpts().Inputs.clear(); |
Argyrios Kyrtzidis | 8e1fbbc | 2012-11-09 19:40:33 +0000 | [diff] [blame] | 138 | FrontendInputFile InputFile(includes[i], IK); |
| 139 | CInvok->getFrontendOpts().Inputs.push_back(InputFile); |
Argyrios Kyrtzidis | b0f4b9a | 2011-03-09 17:21:42 +0000 | [diff] [blame] | 140 | |
| 141 | TextDiagnosticPrinter *DiagClient = |
Douglas Gregor | 02c23eb | 2012-10-23 22:26:28 +0000 | [diff] [blame] | 142 | new TextDiagnosticPrinter(llvm::errs(), new DiagnosticOptions()); |
Dylan Noblesmith | c93dc78 | 2012-02-20 14:00:23 +0000 | [diff] [blame] | 143 | IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs()); |
| 144 | IntrusiveRefCntPtr<DiagnosticsEngine> Diags( |
Douglas Gregor | 02c23eb | 2012-10-23 22:26:28 +0000 | [diff] [blame] | 145 | new DiagnosticsEngine(DiagID, &CI.getDiagnosticOpts(), DiagClient)); |
Argyrios Kyrtzidis | b0f4b9a | 2011-03-09 17:21:42 +0000 | [diff] [blame] | 146 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 147 | std::unique_ptr<CompilerInstance> Clang(new CompilerInstance()); |
| 148 | Clang->setInvocation(CInvok.release()); |
Stephen Hines | c568f1e | 2014-07-21 00:47:37 -0700 | [diff] [blame] | 149 | Clang->setDiagnostics(Diags.get()); |
| 150 | Clang->setTarget(TargetInfo::CreateTargetInfo( |
| 151 | Clang->getDiagnostics(), Clang->getInvocation().TargetOpts)); |
Argyrios Kyrtzidis | b0f4b9a | 2011-03-09 17:21:42 +0000 | [diff] [blame] | 152 | Clang->createFileManager(); |
| 153 | Clang->createSourceManager(Clang->getFileManager()); |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 154 | Clang->createPreprocessor(TU_Prefix); |
Sebastian Redl | 0ab547c | 2011-03-31 19:29:18 +0000 | [diff] [blame] | 155 | Clang->getDiagnosticClient().BeginSourceFile(Clang->getLangOpts(), |
| 156 | &Clang->getPreprocessor()); |
Argyrios Kyrtzidis | b0f4b9a | 2011-03-09 17:21:42 +0000 | [diff] [blame] | 157 | Clang->createASTContext(); |
| 158 | |
Chris Lattner | 5f9e272 | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 159 | SmallVector<char, 256> serialAST; |
Argyrios Kyrtzidis | b0f4b9a | 2011-03-09 17:21:42 +0000 | [diff] [blame] | 160 | llvm::raw_svector_ostream OS(serialAST); |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame^] | 161 | auto consumer = |
| 162 | llvm::make_unique<PCHGenerator>(Clang->getPreprocessor(), "-", nullptr, |
| 163 | /*isysroot=*/"", &OS); |
Argyrios Kyrtzidis | b0f4b9a | 2011-03-09 17:21:42 +0000 | [diff] [blame] | 164 | Clang->getASTContext().setASTMutationListener( |
| 165 | consumer->GetASTMutationListener()); |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame^] | 166 | Clang->setASTConsumer(std::move(consumer)); |
Stephen Hines | 6bcf27b | 2014-05-29 04:14:42 -0700 | [diff] [blame] | 167 | Clang->createSema(TU_Prefix, nullptr); |
Argyrios Kyrtzidis | b0f4b9a | 2011-03-09 17:21:42 +0000 | [diff] [blame] | 168 | |
| 169 | if (firstInclude) { |
| 170 | Preprocessor &PP = Clang->getPreprocessor(); |
| 171 | PP.getBuiltinInfo().InitializeBuiltins(PP.getIdentifierTable(), |
David Blaikie | 4e4d084 | 2012-03-11 07:00:24 +0000 | [diff] [blame] | 172 | PP.getLangOpts()); |
Argyrios Kyrtzidis | b0f4b9a | 2011-03-09 17:21:42 +0000 | [diff] [blame] | 173 | } else { |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame^] | 174 | assert(!SerialBufs.empty()); |
| 175 | SmallVector<std::unique_ptr<llvm::MemoryBuffer>, 4> Bufs; |
Stephen Hines | c568f1e | 2014-07-21 00:47:37 -0700 | [diff] [blame] | 176 | // TODO: Pass through the existing MemoryBuffer instances instead of |
| 177 | // allocating new ones. |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame^] | 178 | for (auto &SB : SerialBufs) |
| 179 | Bufs.push_back(llvm::MemoryBuffer::getMemBuffer(SB->getBuffer())); |
Argyrios Kyrtzidis | b0f4b9a | 2011-03-09 17:21:42 +0000 | [diff] [blame] | 180 | std::string pchName = includes[i-1]; |
| 181 | llvm::raw_string_ostream os(pchName); |
| 182 | os << ".pch" << i-1; |
Stephen Hines | c568f1e | 2014-07-21 00:47:37 -0700 | [diff] [blame] | 183 | serialBufNames.push_back(os.str()); |
Jonathan D. Turner | c24a1ee | 2011-08-02 17:40:32 +0000 | [diff] [blame] | 184 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 185 | IntrusiveRefCntPtr<ASTReader> Reader; |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame^] | 186 | Reader = createASTReader( |
| 187 | *Clang, pchName, Bufs, serialBufNames, |
| 188 | Clang->getASTConsumer().GetASTDeserializationListener()); |
Argyrios Kyrtzidis | b0f4b9a | 2011-03-09 17:21:42 +0000 | [diff] [blame] | 189 | if (!Reader) |
Stephen Hines | 6bcf27b | 2014-05-29 04:14:42 -0700 | [diff] [blame] | 190 | return nullptr; |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 191 | Clang->setModuleManager(Reader); |
Argyrios Kyrtzidis | b0f4b9a | 2011-03-09 17:21:42 +0000 | [diff] [blame] | 192 | Clang->getASTContext().setExternalSource(Reader); |
| 193 | } |
| 194 | |
Argyrios Kyrtzidis | 8e1fbbc | 2012-11-09 19:40:33 +0000 | [diff] [blame] | 195 | if (!Clang->InitializeSourceManager(InputFile)) |
Stephen Hines | 6bcf27b | 2014-05-29 04:14:42 -0700 | [diff] [blame] | 196 | return nullptr; |
Argyrios Kyrtzidis | b0f4b9a | 2011-03-09 17:21:42 +0000 | [diff] [blame] | 197 | |
| 198 | ParseAST(Clang->getSema()); |
Sebastian Redl | 0ab547c | 2011-03-31 19:29:18 +0000 | [diff] [blame] | 199 | Clang->getDiagnosticClient().EndSourceFile(); |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame^] | 200 | SerialBufs.push_back(llvm::MemoryBuffer::getMemBufferCopy(OS.str())); |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 201 | source->CIs.push_back(Clang.release()); |
Argyrios Kyrtzidis | b0f4b9a | 2011-03-09 17:21:42 +0000 | [diff] [blame] | 202 | } |
| 203 | |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame^] | 204 | assert(!SerialBufs.empty()); |
Argyrios Kyrtzidis | b0f4b9a | 2011-03-09 17:21:42 +0000 | [diff] [blame] | 205 | std::string pchName = includes.back() + ".pch-final"; |
Jonathan D. Turner | c24a1ee | 2011-08-02 17:40:32 +0000 | [diff] [blame] | 206 | serialBufNames.push_back(pchName); |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame^] | 207 | Reader = createASTReader(CI, pchName, SerialBufs, serialBufNames); |
Argyrios Kyrtzidis | b0f4b9a | 2011-03-09 17:21:42 +0000 | [diff] [blame] | 208 | if (!Reader) |
Stephen Hines | 6bcf27b | 2014-05-29 04:14:42 -0700 | [diff] [blame] | 209 | return nullptr; |
Argyrios Kyrtzidis | b0f4b9a | 2011-03-09 17:21:42 +0000 | [diff] [blame] | 210 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 211 | source->FinalReader = Reader; |
| 212 | return source; |
Argyrios Kyrtzidis | b0f4b9a | 2011-03-09 17:21:42 +0000 | [diff] [blame] | 213 | } |
| 214 | |
| 215 | //===----------------------------------------------------------------------===// |
| 216 | // ExternalASTSource interface. |
| 217 | //===----------------------------------------------------------------------===// |
| 218 | |
| 219 | Decl *ChainedIncludesSource::GetExternalDecl(uint32_t ID) { |
| 220 | return getFinalReader().GetExternalDecl(ID); |
| 221 | } |
| 222 | Selector ChainedIncludesSource::GetExternalSelector(uint32_t ID) { |
| 223 | return getFinalReader().GetExternalSelector(ID); |
| 224 | } |
| 225 | uint32_t ChainedIncludesSource::GetNumExternalSelectors() { |
| 226 | return getFinalReader().GetNumExternalSelectors(); |
| 227 | } |
| 228 | Stmt *ChainedIncludesSource::GetExternalDeclStmt(uint64_t Offset) { |
| 229 | return getFinalReader().GetExternalDeclStmt(Offset); |
| 230 | } |
| 231 | CXXBaseSpecifier * |
| 232 | ChainedIncludesSource::GetExternalCXXBaseSpecifiers(uint64_t Offset) { |
| 233 | return getFinalReader().GetExternalCXXBaseSpecifiers(Offset); |
| 234 | } |
Richard Smith | 3646c68 | 2013-02-07 03:30:24 +0000 | [diff] [blame] | 235 | bool |
Argyrios Kyrtzidis | b0f4b9a | 2011-03-09 17:21:42 +0000 | [diff] [blame] | 236 | ChainedIncludesSource::FindExternalVisibleDeclsByName(const DeclContext *DC, |
| 237 | DeclarationName Name) { |
| 238 | return getFinalReader().FindExternalVisibleDeclsByName(DC, Name); |
| 239 | } |
Douglas Gregor | ba6ffaf | 2011-07-15 21:46:17 +0000 | [diff] [blame] | 240 | ExternalLoadResult |
| 241 | ChainedIncludesSource::FindExternalLexicalDecls(const DeclContext *DC, |
Argyrios Kyrtzidis | b0f4b9a | 2011-03-09 17:21:42 +0000 | [diff] [blame] | 242 | bool (*isKindWeWant)(Decl::Kind), |
Chris Lattner | 5f9e272 | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 243 | SmallVectorImpl<Decl*> &Result) { |
Argyrios Kyrtzidis | b0f4b9a | 2011-03-09 17:21:42 +0000 | [diff] [blame] | 244 | return getFinalReader().FindExternalLexicalDecls(DC, isKindWeWant, Result); |
| 245 | } |
| 246 | void ChainedIncludesSource::CompleteType(TagDecl *Tag) { |
| 247 | return getFinalReader().CompleteType(Tag); |
| 248 | } |
| 249 | void ChainedIncludesSource::CompleteType(ObjCInterfaceDecl *Class) { |
| 250 | return getFinalReader().CompleteType(Class); |
| 251 | } |
| 252 | void ChainedIncludesSource::StartedDeserializing() { |
| 253 | return getFinalReader().StartedDeserializing(); |
| 254 | } |
| 255 | void ChainedIncludesSource::FinishedDeserializing() { |
| 256 | return getFinalReader().FinishedDeserializing(); |
| 257 | } |
| 258 | void ChainedIncludesSource::StartTranslationUnit(ASTConsumer *Consumer) { |
| 259 | return getFinalReader().StartTranslationUnit(Consumer); |
| 260 | } |
| 261 | void ChainedIncludesSource::PrintStats() { |
| 262 | return getFinalReader().PrintStats(); |
| 263 | } |
Ted Kremenek | e9b5f3d | 2011-04-28 23:46:20 +0000 | [diff] [blame] | 264 | void ChainedIncludesSource::getMemoryBufferSizes(MemoryBufferSizes &sizes)const{ |
| 265 | for (unsigned i = 0, e = CIs.size(); i != e; ++i) { |
| 266 | if (const ExternalASTSource *eSrc = |
| 267 | CIs[i]->getASTContext().getExternalSource()) { |
| 268 | eSrc->getMemoryBufferSizes(sizes); |
| 269 | } |
| 270 | } |
| 271 | |
| 272 | getFinalReader().getMemoryBufferSizes(sizes); |
| 273 | } |
Sebastian Redl | ce0682f | 2011-03-31 19:29:24 +0000 | [diff] [blame] | 274 | |
| 275 | void ChainedIncludesSource::InitializeSema(Sema &S) { |
| 276 | return getFinalReader().InitializeSema(S); |
| 277 | } |
| 278 | void ChainedIncludesSource::ForgetSema() { |
| 279 | return getFinalReader().ForgetSema(); |
| 280 | } |
Douglas Gregor | 5ac4b69 | 2012-01-25 00:49:42 +0000 | [diff] [blame] | 281 | void ChainedIncludesSource::ReadMethodPool(Selector Sel) { |
| 282 | getFinalReader().ReadMethodPool(Sel); |
Sebastian Redl | ce0682f | 2011-03-31 19:29:24 +0000 | [diff] [blame] | 283 | } |
| 284 | bool ChainedIncludesSource::LookupUnqualified(LookupResult &R, Scope *S) { |
| 285 | return getFinalReader().LookupUnqualified(R, S); |
| 286 | } |
| 287 | |