diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2016-08-25 18:26:30 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2016-08-25 18:26:30 +0000 |
commit | bd97f35339719480001ff96efb5785d9cfd29edf (patch) | |
tree | 15bf526c0b5db3531cab46d892f4a12cb8de8cb1 /clang/lib/Serialization/GeneratePCH.cpp | |
parent | 084148fcc35d96afba07a8f12842bc80af778ece (diff) | |
download | llvm-bd97f35339719480001ff96efb5785d9cfd29edf.zip llvm-bd97f35339719480001ff96efb5785d9cfd29edf.tar.gz llvm-bd97f35339719480001ff96efb5785d9cfd29edf.tar.bz2 |
Refactor to remove the assumption that we know the name of the module we're emitting at the point when we create a PCHGenerator (with the C++ modules TS, we find that out part way through parsing the input).
llvm-svn: 279766
Diffstat (limited to 'clang/lib/Serialization/GeneratePCH.cpp')
-rw-r--r-- | clang/lib/Serialization/GeneratePCH.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/clang/lib/Serialization/GeneratePCH.cpp b/clang/lib/Serialization/GeneratePCH.cpp index 47dce37..b2d79a2 100644 --- a/clang/lib/Serialization/GeneratePCH.cpp +++ b/clang/lib/Serialization/GeneratePCH.cpp @@ -13,6 +13,7 @@ //===----------------------------------------------------------------------===// #include "clang/AST/ASTContext.h" +#include "clang/Lex/HeaderSearch.h" #include "clang/Lex/Preprocessor.h" #include "clang/Sema/SemaConsumer.h" #include "clang/Serialization/ASTWriter.h" @@ -21,12 +22,11 @@ using namespace clang; PCHGenerator::PCHGenerator( - const Preprocessor &PP, StringRef OutputFile, - clang::Module *Module, StringRef isysroot, - std::shared_ptr<PCHBuffer> Buffer, - ArrayRef<llvm::IntrusiveRefCntPtr<ModuleFileExtension>> Extensions, - bool AllowASTWithErrors, bool IncludeTimestamps) - : PP(PP), OutputFile(OutputFile), Module(Module), isysroot(isysroot.str()), + const Preprocessor &PP, StringRef OutputFile, StringRef isysroot, + std::shared_ptr<PCHBuffer> Buffer, + ArrayRef<llvm::IntrusiveRefCntPtr<ModuleFileExtension>> Extensions, + bool AllowASTWithErrors, bool IncludeTimestamps) + : PP(PP), OutputFile(OutputFile), isysroot(isysroot.str()), SemaPtr(nullptr), Buffer(Buffer), Stream(Buffer->Data), Writer(Stream, Extensions, IncludeTimestamps), AllowASTWithErrors(AllowASTWithErrors) { @@ -45,6 +45,13 @@ void PCHGenerator::HandleTranslationUnit(ASTContext &Ctx) { if (hasErrors && !AllowASTWithErrors) return; + Module *Module = nullptr; + if (PP.getLangOpts().CompilingModule) { + Module = PP.getHeaderSearchInfo().lookupModule( + PP.getLangOpts().CurrentModule, /*AllowSearch*/ false); + assert(Module && "emitting module but current module doesn't exist"); + } + // Emit the PCH file to the Buffer. assert(SemaPtr && "No Sema?"); Buffer->Signature = |