<div dir="ltr">Thanks, investigating.</div><div class="gmail_extra"><br><div class="gmail_quote">On 5 June 2017 at 13:14, Evgenii Stepanov <span dir="ltr"><<a href="mailto:eugeni.stepanov@gmail.com" target="_blank">eugeni.stepanov@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This change leaks memory:<br>
<a href="http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/5453/steps/check-clang%20asan/logs/stdio" rel="noreferrer" target="_blank">http://lab.llvm.org:8011/<wbr>builders/sanitizer-x86_64-<wbr>linux-fast/builds/5453/steps/<wbr>check-clang%20asan/logs/stdio</a><br>
<div class="HOEnZb"><div class="h5"><br>
On Mon, Jun 5, 2017 at 11:10 AM, Richard Smith via cfe-commits<br>
<<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>> wrote:<br>
> Author: rsmith<br>
> Date: Mon Jun 5 13:10:11 2017<br>
> New Revision: 304726<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=304726&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=304726&view=rev</a><br>
> Log:<br>
> Rather than rejecting attempts to run preprocessor-only actions on AST files,<br>
> replay the steps taken to create the AST file with the preprocessor-only action<br>
> installed to produce preprocessed output.<br>
><br>
> This can be used to produce the preprocessed text for an existing .pch or .pcm<br>
> file.<br>
><br>
> Modified:<br>
> cfe/trunk/include/clang/Basic/<wbr>LangOptions.h<br>
> cfe/trunk/include/clang/Basic/<wbr>SourceManager.h<br>
> cfe/trunk/include/clang/<wbr>Frontend/ASTUnit.h<br>
> cfe/trunk/include/clang/<wbr>Frontend/FrontendAction.h<br>
> cfe/trunk/lib/Basic/<wbr>SourceManager.cpp<br>
> cfe/trunk/lib/Frontend/<wbr>ASTUnit.cpp<br>
> cfe/trunk/lib/Frontend/<wbr>FrontendAction.cpp<br>
> cfe/trunk/lib/Serialization/<wbr>ASTReader.cpp<br>
> cfe/trunk/test/Modules/<wbr>preprocess-module.cpp<br>
><br>
> Modified: cfe/trunk/include/clang/Basic/<wbr>LangOptions.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.h?rev=304726&r1=304725&r2=304726&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/include/<wbr>clang/Basic/LangOptions.h?rev=<wbr>304726&r1=304725&r2=304726&<wbr>view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- cfe/trunk/include/clang/Basic/<wbr>LangOptions.h (original)<br>
> +++ cfe/trunk/include/clang/Basic/<wbr>LangOptions.h Mon Jun 5 13:10:11 2017<br>
> @@ -58,6 +58,7 @@ public:<br>
> SOB_Trapping // -ftrapv<br>
> };<br>
><br>
> + // FIXME: Unify with TUKind.<br>
> enum CompilingModuleKind {<br>
> CMK_None, ///< Not compiling a module interface at all.<br>
> CMK_ModuleMap, ///< Compiling a module from a module map.<br>
><br>
> Modified: cfe/trunk/include/clang/Basic/<wbr>SourceManager.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceManager.h?rev=304726&r1=304725&r2=304726&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/include/<wbr>clang/Basic/SourceManager.h?<wbr>rev=304726&r1=304725&r2=<wbr>304726&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- cfe/trunk/include/clang/Basic/<wbr>SourceManager.h (original)<br>
> +++ cfe/trunk/include/clang/Basic/<wbr>SourceManager.h Mon Jun 5 13:10:11 2017<br>
> @@ -722,6 +722,10 @@ public:<br>
><br>
> void clearIDTables();<br>
><br>
> + /// Initialize this source manager suitably to replay the compilation<br>
> + /// described by \p Old. Requires that \p Old outlive \p *this.<br>
> + void initializeForReplay(const SourceManager &Old);<br>
> +<br>
> DiagnosticsEngine &getDiagnostics() const { return Diag; }<br>
><br>
> FileManager &getFileManager() const { return FileMgr; }<br>
><br>
> Modified: cfe/trunk/include/clang/<wbr>Frontend/ASTUnit.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/ASTUnit.h?rev=304726&r1=304725&r2=304726&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/include/<wbr>clang/Frontend/ASTUnit.h?rev=<wbr>304726&r1=304725&r2=304726&<wbr>view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- cfe/trunk/include/clang/<wbr>Frontend/ASTUnit.h (original)<br>
> +++ cfe/trunk/include/clang/<wbr>Frontend/ASTUnit.h Mon Jun 5 13:10:11 2017<br>
> @@ -51,6 +51,7 @@ class DiagnosticsEngine;<br>
> class FileEntry;<br>
> class FileManager;<br>
> class HeaderSearch;<br>
> +class InputKind;<br>
> class MemoryBufferCache;<br>
> class Preprocessor;<br>
> class PCHContainerOperations;<br>
> @@ -305,9 +306,6 @@ private:<br>
> /// (likely to change while trying to use them).<br>
> bool UserFilesAreVolatile : 1;<br>
><br>
> - /// \brief The language options used when we load an AST file.<br>
> - LangOptions ASTFileLangOpts;<br>
> -<br>
> static void ConfigureDiags(<wbr>IntrusiveRefCntPtr<<wbr>DiagnosticsEngine> Diags,<br>
> ASTUnit &AST, bool CaptureDiagnostics);<br>
><br>
> @@ -702,6 +700,9 @@ public:<br>
> /// \brief Determine what kind of translation unit this AST represents.<br>
> TranslationUnitKind getTranslationUnitKind() const { return TUKind; }<br>
><br>
> + /// \brief Determine the input kind this AST unit represents.<br>
> + InputKind getInputKind() const;<br>
> +<br>
> /// \brief A mapping from a file name to the memory buffer that stores the<br>
> /// remapped contents of that file.<br>
> typedef std::pair<std::string, llvm::MemoryBuffer *> RemappedFile;<br>
><br>
> Modified: cfe/trunk/include/clang/<wbr>Frontend/FrontendAction.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendAction.h?rev=304726&r1=304725&r2=304726&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/include/<wbr>clang/Frontend/FrontendAction.<wbr>h?rev=304726&r1=304725&r2=<wbr>304726&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- cfe/trunk/include/clang/<wbr>Frontend/FrontendAction.h (original)<br>
> +++ cfe/trunk/include/clang/<wbr>Frontend/FrontendAction.h Mon Jun 5 13:10:11 2017<br>
> @@ -176,10 +176,10 @@ public:<br>
> virtual TranslationUnitKind getTranslationUnitKind() { return TU_Complete; }<br>
><br>
> /// \brief Does this action support use with PCH?<br>
> - virtual bool hasPCHSupport() const { return !usesPreprocessorOnly(); }<br>
> + virtual bool hasPCHSupport() const { return true; }<br>
><br>
> /// \brief Does this action support use with AST files?<br>
> - virtual bool hasASTFileSupport() const { return !usesPreprocessorOnly(); }<br>
> + virtual bool hasASTFileSupport() const { return true; }<br>
><br>
> /// \brief Does this action support use with IR files?<br>
> virtual bool hasIRSupport() const { return false; }<br>
><br>
> Modified: cfe/trunk/lib/Basic/<wbr>SourceManager.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/SourceManager.cpp?rev=304726&r1=304725&r2=304726&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/lib/Basic/<wbr>SourceManager.cpp?rev=304726&<wbr>r1=304725&r2=304726&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- cfe/trunk/lib/Basic/<wbr>SourceManager.cpp (original)<br>
> +++ cfe/trunk/lib/Basic/<wbr>SourceManager.cpp Mon Jun 5 13:10:11 2017<br>
> @@ -345,6 +345,41 @@ void SourceManager::clearIDTables() {<br>
> createExpansionLoc(<wbr>SourceLocation(),<wbr>SourceLocation(),<wbr>SourceLocation(), 1);<br>
> }<br>
><br>
> +void SourceManager::<wbr>initializeForReplay(const SourceManager &Old) {<br>
> + assert(MainFileID.isInvalid() && "expected uninitialized SourceManager");<br>
> +<br>
> + auto CloneContentCache = [&](const ContentCache *Cache) -> ContentCache * {<br>
> + auto *Clone = new (ContentCacheAlloc.Allocate<<wbr>ContentCache>()) ContentCache;<br>
> + Clone->OrigEntry = Cache->OrigEntry;<br>
> + Clone->ContentsEntry = Cache->ContentsEntry;<br>
> + Clone->BufferOverridden = Cache->BufferOverridden;<br>
> + Clone->IsSystemFile = Cache->IsSystemFile;<br>
> + Clone->IsTransient = Cache->IsTransient;<br>
> + Clone->replaceBuffer(Cache-><wbr>getRawBuffer(), /*DoNotFree*/true);<br>
> + return Clone;<br>
> + };<br>
> +<br>
> + // Set up our main file ID as a copy of the old source manager's main file.<br>
> + const SLocEntry &OldMainFile = Old.getSLocEntry(Old.<wbr>getMainFileID());<br>
> + assert(OldMainFile.isFile() && "main file is macro expansion?");<br>
> + setMainFileID(createFileID(<br>
> + CloneContentCache(OldMainFile.<wbr>getFile().getContentCache()),<br>
> + SourceLocation(), OldMainFile.getFile().<wbr>getFileCharacteristic(), 0, 0));<br>
> +<br>
> + // Ensure all SLocEntries are loaded from the external source.<br>
> + for (unsigned I = 0, N = Old.LoadedSLocEntryTable.size(<wbr>); I != N; ++I)<br>
> + if (!Old.SLocEntryLoaded[I])<br>
> + Old.loadSLocEntry(I, nullptr);<br>
> +<br>
> + // Inherit any content cache data from the old source manager.<br>
> + for (auto &FileInfo : Old.FileInfos) {<br>
> + SrcMgr::ContentCache *&Slot = FileInfos[FileInfo.first];<br>
> + if (Slot)<br>
> + continue;<br>
> + Slot = CloneContentCache(FileInfo.<wbr>second);<br>
> + }<br>
> +}<br>
> +<br>
> /// getOrCreateContentCache - Create or return a cached ContentCache for the<br>
> /// specified file.<br>
> const ContentCache *<br>
><br>
> Modified: cfe/trunk/lib/Frontend/<wbr>ASTUnit.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=304726&r1=304725&r2=304726&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/lib/<wbr>Frontend/ASTUnit.cpp?rev=<wbr>304726&r1=304725&r2=304726&<wbr>view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- cfe/trunk/lib/Frontend/<wbr>ASTUnit.cpp (original)<br>
> +++ cfe/trunk/lib/Frontend/<wbr>ASTUnit.cpp Mon Jun 5 13:10:11 2017<br>
> @@ -667,6 +667,7 @@ std::unique_ptr<ASTUnit> ASTUnit::LoadFr<br>
><br>
> ConfigureDiags(Diags, *AST, CaptureDiagnostics);<br>
><br>
> + AST->LangOpts = std::make_shared<LangOptions>(<wbr>);<br>
> AST->OnlyLocalDecls = OnlyLocalDecls;<br>
> AST->CaptureDiagnostics = CaptureDiagnostics;<br>
> AST->Diagnostics = Diags;<br>
> @@ -682,7 +683,7 @@ std::unique_ptr<ASTUnit> ASTUnit::LoadFr<br>
> AST->HeaderInfo.reset(new HeaderSearch(AST->HSOpts,<br>
> AST->getSourceManager(),<br>
> AST->getDiagnostics(),<br>
> - AST->ASTFileLangOpts,<br>
> + AST->getLangOpts(),<br>
> /*Target=*/nullptr));<br>
><br>
> auto PPOpts = std::make_shared<<wbr>PreprocessorOptions>();<br>
> @@ -696,13 +697,13 @@ std::unique_ptr<ASTUnit> ASTUnit::LoadFr<br>
> unsigned Counter;<br>
><br>
> AST->PP = std::make_shared<Preprocessor><wbr>(<br>
> - std::move(PPOpts), AST->getDiagnostics(), AST->ASTFileLangOpts,<br>
> + std::move(PPOpts), AST->getDiagnostics(), *AST->LangOpts,<br>
> AST->getSourceManager(), *AST->PCMCache, HeaderInfo, *AST,<br>
> /*IILookup=*/nullptr,<br>
> /*OwnsHeaderSearch=*/false);<br>
> Preprocessor &PP = *AST->PP;<br>
><br>
> - AST->Ctx = new ASTContext(AST-><wbr>ASTFileLangOpts, AST->getSourceManager(),<br>
> + AST->Ctx = new ASTContext(*AST->LangOpts, AST->getSourceManager(),<br>
> PP.getIdentifierTable(), PP.getSelectorTable(),<br>
> PP.getBuiltinInfo());<br>
> ASTContext &Context = *AST->Ctx;<br>
> @@ -716,7 +717,7 @@ std::unique_ptr<ASTUnit> ASTUnit::LoadFr<br>
> AllowPCHWithCompilerErrors);<br>
><br>
> AST->Reader->setListener(llvm:<wbr>:make_unique<ASTInfoCollector><wbr>(<br>
> - *AST->PP, Context, AST->ASTFileLangOpts, AST->TargetOpts, AST->Target,<br>
> + *AST->PP, Context, *AST->LangOpts, AST->TargetOpts, AST->Target,<br>
> Counter));<br>
><br>
> // Attach the AST reader to the AST context as an external AST<br>
> @@ -2879,7 +2880,32 @@ const FileEntry *ASTUnit::getPCHFile() {<br>
> }<br>
><br>
> bool ASTUnit::isModuleFile() {<br>
> - return isMainFileAST() && ASTFileLangOpts.<wbr>isCompilingModule();<br>
> + return isMainFileAST() && getLangOpts().<wbr>isCompilingModule();<br>
> +}<br>
> +<br>
> +InputKind ASTUnit::getInputKind() const {<br>
> + auto &LangOpts = getLangOpts();<br>
> +<br>
> + InputKind::Language Lang;<br>
> + if (LangOpts.OpenCL)<br>
> + Lang = InputKind::OpenCL;<br>
> + else if (LangOpts.CUDA)<br>
> + Lang = InputKind::CUDA;<br>
> + else if (LangOpts.RenderScript)<br>
> + Lang = InputKind::RenderScript;<br>
> + else if (LangOpts.CPlusPlus)<br>
> + Lang = LangOpts.ObjC1 ? InputKind::ObjCXX : InputKind::CXX;<br>
> + else<br>
> + Lang = LangOpts.ObjC1 ? InputKind::ObjC : InputKind::C;<br>
> +<br>
> + InputKind::Format Fmt = InputKind::Source;<br>
> + if (LangOpts.getCompilingModule() == LangOptions::CMK_ModuleMap)<br>
> + Fmt = InputKind::ModuleMap;<br>
> +<br>
> + // We don't know if input was preprocessed. Assume not.<br>
> + bool PP = false;<br>
> +<br>
> + return InputKind(Lang, Fmt, PP);<br>
> }<br>
><br>
> void ASTUnit::PreambleData::<wbr>countLines() const {<br>
><br>
> Modified: cfe/trunk/lib/Frontend/<wbr>FrontendAction.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendAction.cpp?rev=304726&r1=304725&r2=304726&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/lib/<wbr>Frontend/FrontendAction.cpp?<wbr>rev=304726&r1=304725&r2=<wbr>304726&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- cfe/trunk/lib/Frontend/<wbr>FrontendAction.cpp (original)<br>
> +++ cfe/trunk/lib/Frontend/<wbr>FrontendAction.cpp Mon Jun 5 13:10:11 2017<br>
> @@ -387,8 +387,7 @@ static std::error_code collectModuleHead<br>
> return std::error_code();<br>
> }<br>
><br>
> -static bool loadModuleMapForModuleBuild(<wbr>CompilerInstance &CI,<br>
> - StringRef Filename, bool IsSystem,<br>
> +static bool loadModuleMapForModuleBuild(<wbr>CompilerInstance &CI, bool IsSystem,<br>
> bool IsPreprocessed,<br>
> std::string &PresumedModuleMapFile,<br>
> unsigned &Offset) {<br>
> @@ -523,7 +522,8 @@ getInputBufferForModule(<wbr>CompilerInstance<br>
> }<br>
><br>
> bool FrontendAction::<wbr>BeginSourceFile(<wbr>CompilerInstance &CI,<br>
> - const FrontendInputFile &Input) {<br>
> + const FrontendInputFile &RealInput) {<br>
> + FrontendInputFile Input(RealInput);<br>
> assert(!Instance && "Already processing a source file!");<br>
> assert(!Input.isEmpty() && "Unexpected empty filename!");<br>
> setCurrentInput(Input);<br>
> @@ -531,15 +531,69 @@ bool FrontendAction::<wbr>BeginSourceFile(Com<br>
><br>
> StringRef InputFile = Input.getFile();<br>
> bool HasBegunSourceFile = false;<br>
> + bool ReplayASTFile = Input.getKind().getFormat() == InputKind::Precompiled &&<br>
> + usesPreprocessorOnly();<br>
> if (!BeginInvocation(CI))<br>
> goto failure;<br>
><br>
> + // If we're replaying the build of an AST file, import it and set up<br>
> + // the initial state from its build.<br>
> + if (ReplayASTFile) {<br>
> + IntrusiveRefCntPtr<<wbr>DiagnosticsEngine> Diags(&CI.getDiagnostics());<br>
> +<br>
> + // The AST unit populates its own diagnostics engine rather than ours.<br>
> + IntrusiveRefCntPtr<<wbr>DiagnosticsEngine> ASTDiags(<br>
> + new DiagnosticsEngine(Diags-><wbr>getDiagnosticIDs(),<br>
> + &Diags->getDiagnosticOptions()<wbr>));<br>
> + ASTDiags->setClient(Diags-><wbr>getClient(), /*OwnsClient*/false);<br>
> +<br>
> + std::unique_ptr<ASTUnit> AST = ASTUnit::LoadFromASTFile(<br>
> + InputFile, CI.getPCHContainerReader(), ASTDiags, CI.getFileSystemOpts(),<br>
> + CI.getCodeGenOpts().<wbr>DebugTypeExtRefs);<br>
> + if (!AST)<br>
> + goto failure;<br>
> +<br>
> + // Options relating to how we treat the input (but not what we do with it)<br>
> + // are inherited from the AST unit.<br>
> + CI.getLangOpts() = AST->getLangOpts();<br>
> +<br>
> + // Preload all the module files loaded transitively by the AST unit.<br>
> + if (auto ASTReader = AST->getASTReader()) {<br>
> + auto &MM = ASTReader->getModuleManager();<br>
> + for (ModuleFile &MF : MM)<br>
> + if (&MF != &MM.getPrimaryModule())<br>
> + CI.getFrontendOpts().<wbr>ModuleFiles.push_back(MF.<wbr>FileName);<br>
> + }<br>
> +<br>
> + // Set the shared objects, these are reset when we finish processing the<br>
> + // file, otherwise the CompilerInstance will happily destroy them.<br>
> + CI.setFileManager(&AST-><wbr>getFileManager());<br>
> + CI.createSourceManager(CI.<wbr>getFileManager());<br>
> + CI.getSourceManager().<wbr>initializeForReplay(AST-><wbr>getSourceManager());<br>
> + CI.createPreprocessor(<wbr>getTranslationUnitKind());<br>
> +<br>
> + // Set up the input file for replay purposes.<br>
> + auto Kind = AST->getInputKind();<br>
> + if (Kind.getFormat() == InputKind::ModuleMap) {<br>
> + Module *ASTModule =<br>
> + AST->getPreprocessor().<wbr>getHeaderSearchInfo().<wbr>lookupModule(<br>
> + AST->getLangOpts().<wbr>CurrentModule, /*AllowSearch*/ false);<br>
> + Input = FrontendInputFile(ASTModule-><wbr>PresumedModuleMapFile, Kind);<br>
> + } else {<br>
> + auto &SM = CI.getSourceManager();<br>
> + FileID ID = SM.getMainFileID();<br>
> + if (auto *File = SM.getFileEntryForID(ID))<br>
> + Input = FrontendInputFile(File-><wbr>getName(), Kind);<br>
> + else<br>
> + Input = FrontendInputFile(SM.<wbr>getBuffer(ID), Kind);<br>
> + }<br>
> + setCurrentInput(Input, std::move(AST));<br>
> + }<br>
> +<br>
> // AST files follow a very different path, since they share objects via the<br>
> // AST unit.<br>
> if (Input.getKind().getFormat() == InputKind::Precompiled) {<br>
> - // FIXME: We should not be asserting on bad command-line arguments.<br>
> - assert(!usesPreprocessorOnly() &&<br>
> - "Attempt to pass AST file to preprocessor only action!");<br>
> + assert(!usesPreprocessorOnly() && "this case was handled above");<br>
> assert(hasASTFileSupport() &&<br>
> "This action does not have AST file support!");<br>
><br>
> @@ -680,7 +734,7 @@ bool FrontendAction::<wbr>BeginSourceFile(Com<br>
><br>
> std::string PresumedModuleMapFile;<br>
> unsigned OffsetToContents;<br>
> - if (loadModuleMapForModuleBuild(<wbr>CI, Input.getFile(), Input.isSystem(),<br>
> + if (loadModuleMapForModuleBuild(<wbr>CI, Input.isSystem(),<br>
> Input.isPreprocessed(),<br>
> PresumedModuleMapFile, OffsetToContents))<br>
> goto failure;<br>
> @@ -829,14 +883,7 @@ bool FrontendAction::<wbr>BeginSourceFile(Com<br>
><br>
> // If we failed, reset state since the client will not end up calling the<br>
> // matching EndSourceFile().<br>
> - failure:<br>
> - if (isCurrentFileAST()) {<br>
> - CI.setASTContext(nullptr);<br>
> - CI.setPreprocessor(nullptr);<br>
> - CI.setSourceManager(nullptr);<br>
> - CI.setFileManager(nullptr);<br>
> - }<br>
> -<br>
> +failure:<br>
> if (HasBegunSourceFile)<br>
> CI.getDiagnosticClient().<wbr>EndSourceFile();<br>
> CI.clearOutputFiles(/*<wbr>EraseFiles=*/true);<br>
> @@ -914,6 +961,7 @@ void FrontendAction::EndSourceFile(<wbr>) {<br>
> CI.resetAndLeakPreprocessor();<br>
> CI.resetAndLeakSourceManager()<wbr>;<br>
> CI.resetAndLeakFileManager();<br>
> + BuryPointer(CurrentASTUnit.<wbr>release());<br>
> } else {<br>
> CI.setPreprocessor(nullptr);<br>
> CI.setSourceManager(nullptr);<br>
><br>
> Modified: cfe/trunk/lib/Serialization/<wbr>ASTReader.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=304726&r1=304725&r2=304726&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/lib/<wbr>Serialization/ASTReader.cpp?<wbr>rev=304726&r1=304725&r2=<wbr>304726&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- cfe/trunk/lib/Serialization/<wbr>ASTReader.cpp (original)<br>
> +++ cfe/trunk/lib/Serialization/<wbr>ASTReader.cpp Mon Jun 5 13:10:11 2017<br>
> @@ -4918,6 +4918,7 @@ ASTReader::ReadSubmoduleBlock(<wbr>ModuleFile<br>
> }<br>
><br>
> CurrentModule->setASTFile(F.<wbr>File);<br>
> + CurrentModule-><wbr>PresumedModuleMapFile = F.ModuleMapPath;<br>
> }<br>
><br>
> CurrentModule->Kind = ModuleKind;<br>
><br>
> Modified: cfe/trunk/test/Modules/<wbr>preprocess-module.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/preprocess-module.cpp?rev=304726&r1=304725&r2=304726&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/test/<wbr>Modules/preprocess-module.cpp?<wbr>rev=304726&r1=304725&r2=<wbr>304726&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- cfe/trunk/test/Modules/<wbr>preprocess-module.cpp (original)<br>
> +++ cfe/trunk/test/Modules/<wbr>preprocess-module.cpp Mon Jun 5 13:10:11 2017<br>
> @@ -34,10 +34,15 @@<br>
> // RUN: rm %t/fwd.h %t/file.h %t/file2.h %t/module.modulemap<br>
> // RUN: %clang_cc1 -fmodules -fmodule-name=file -fmodule-file=%t/fwd.pcm -x c++-module-map-cpp-output %t/copy.ii -emit-module -o %t/copy.pcm<br>
><br>
> -// Finally, check that our module contains correct mapping information for the headers.<br>
> +// Check that our module contains correct mapping information for the headers.<br>
> // RUN: cp %S/Inputs/preprocess/fwd.h %S/Inputs/preprocess/file.h %S/Inputs/preprocess/file2.h %S/Inputs/preprocess/module.<wbr>modulemap %t<br>
> // RUN: %clang_cc1 -fmodules -fmodule-file=%t/copy.pcm %s -I%t -verify -fno-modules-error-recovery -DCOPY -DINCLUDE<br>
><br>
> +// Check that we can preprocess from a .pcm file and that we get the same result as preprocessing from the original sources.<br>
> +// RUN: %clang_cc1 -fmodules -fmodule-name=file -fmodule-file=%t/fwd.pcm -I%S/Inputs/preprocess -x c++-module-map %S/Inputs/preprocess/module.<wbr>modulemap -emit-module -o %t/file.pcm<br>
> +// RUN: %clang_cc1 -fmodules -fmodule-name=file -fmodule-file=%t/fwd.pcm -I%S/Inputs/preprocess %t/file.pcm -E -frewrite-includes -o %t/file.rewrite.ii<br>
> +// RUN: cmp %t/rewrite.ii %t/file.rewrite.ii<br>
> +<br>
> // == module map<br>
> // CHECK: # 1 "{{.*}}module.modulemap"<br>
> // CHECK: module file {<br>
><br>
><br>
> ______________________________<wbr>_________________<br>
> cfe-commits mailing list<br>
> <a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-commits</a><br>
</div></div></blockquote></div><br></div>