Re: r276473 - [modules] Teach the ASTWriter to ignore mutations coming from the ASTReader.
Merged to 3.9 in r276757. Cheers, Hans On Tue, Jul 26, 2016 at 2:01 AM, Richard Smith wrote: > Yes please :) > > > On 25 Jul 2016 10:13 p.m., "Vassil Vassilev via cfe-commits" > wrote: >> >> It could, it fixes a set of issues wrt to modules. >> On 25/07/16 22:39, Hans Wennborg wrote: >>> >>> Should this be merged to 3.9? >>> >>> On Fri, Jul 22, 2016 at 2:08 PM, Vassil Vassilev via cfe-commits >>> wrote: Author: vvassilev Date: Fri Jul 22 16:08:24 2016 New Revision: 276473 URL: http://llvm.org/viewvc/llvm-project?rev=276473&view=rev Log: [modules] Teach the ASTWriter to ignore mutations coming from the ASTReader. Processing update records (and loading a module, in general) might trigger unexpected calls to the ASTWriter (being a mutation listener). Now we have a mechanism to suppress those calls to the ASTWriter but notify other possible mutation listeners. Fixes https://llvm.org/bugs/show_bug.cgi?id=28332 Patch by Cristina Cristescu and me. Reviewed by Richard Smith (D21800). Added: cfe/trunk/test/Modules/Inputs/PR28332/ cfe/trunk/test/Modules/Inputs/PR28332/TextualInclude.h cfe/trunk/test/Modules/Inputs/PR28332/a.h cfe/trunk/test/Modules/Inputs/PR28332/b.h cfe/trunk/test/Modules/Inputs/PR28332/c.h cfe/trunk/test/Modules/Inputs/PR28332/module.modulemap cfe/trunk/test/Modules/pr28332.cpp Modified: cfe/trunk/include/clang/Serialization/ASTReader.h cfe/trunk/lib/Serialization/ASTReader.cpp cfe/trunk/lib/Serialization/ASTReaderDecl.cpp cfe/trunk/lib/Serialization/ASTWriter.cpp >> >> >> >> ___ >> cfe-commits mailing list >> cfe-commits@lists.llvm.org >> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r276473 - [modules] Teach the ASTWriter to ignore mutations coming from the ASTReader.
Yes please :) On 25 Jul 2016 10:13 p.m., "Vassil Vassilev via cfe-commits" < cfe-commits@lists.llvm.org> wrote: > It could, it fixes a set of issues wrt to modules. > On 25/07/16 22:39, Hans Wennborg wrote: > >> Should this be merged to 3.9? >> >> On Fri, Jul 22, 2016 at 2:08 PM, Vassil Vassilev via cfe-commits >> wrote: >> >>> Author: vvassilev >>> Date: Fri Jul 22 16:08:24 2016 >>> New Revision: 276473 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=276473&view=rev >>> Log: >>> [modules] Teach the ASTWriter to ignore mutations coming from the >>> ASTReader. >>> >>> Processing update records (and loading a module, in general) might >>> trigger >>> unexpected calls to the ASTWriter (being a mutation listener). Now we >>> have a >>> mechanism to suppress those calls to the ASTWriter but notify other >>> possible >>> mutation listeners. >>> >>> Fixes https://llvm.org/bugs/show_bug.cgi?id=28332 >>> >>> Patch by Cristina Cristescu and me. >>> >>> Reviewed by Richard Smith (D21800). >>> >>> Added: >>> cfe/trunk/test/Modules/Inputs/PR28332/ >>> cfe/trunk/test/Modules/Inputs/PR28332/TextualInclude.h >>> cfe/trunk/test/Modules/Inputs/PR28332/a.h >>> cfe/trunk/test/Modules/Inputs/PR28332/b.h >>> cfe/trunk/test/Modules/Inputs/PR28332/c.h >>> cfe/trunk/test/Modules/Inputs/PR28332/module.modulemap >>> cfe/trunk/test/Modules/pr28332.cpp >>> Modified: >>> cfe/trunk/include/clang/Serialization/ASTReader.h >>> cfe/trunk/lib/Serialization/ASTReader.cpp >>> cfe/trunk/lib/Serialization/ASTReaderDecl.cpp >>> cfe/trunk/lib/Serialization/ASTWriter.cpp >>> >> > > ___ > cfe-commits mailing list > cfe-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r276473 - [modules] Teach the ASTWriter to ignore mutations coming from the ASTReader.
It could, it fixes a set of issues wrt to modules. On 25/07/16 22:39, Hans Wennborg wrote: Should this be merged to 3.9? On Fri, Jul 22, 2016 at 2:08 PM, Vassil Vassilev via cfe-commits wrote: Author: vvassilev Date: Fri Jul 22 16:08:24 2016 New Revision: 276473 URL: http://llvm.org/viewvc/llvm-project?rev=276473&view=rev Log: [modules] Teach the ASTWriter to ignore mutations coming from the ASTReader. Processing update records (and loading a module, in general) might trigger unexpected calls to the ASTWriter (being a mutation listener). Now we have a mechanism to suppress those calls to the ASTWriter but notify other possible mutation listeners. Fixes https://llvm.org/bugs/show_bug.cgi?id=28332 Patch by Cristina Cristescu and me. Reviewed by Richard Smith (D21800). Added: cfe/trunk/test/Modules/Inputs/PR28332/ cfe/trunk/test/Modules/Inputs/PR28332/TextualInclude.h cfe/trunk/test/Modules/Inputs/PR28332/a.h cfe/trunk/test/Modules/Inputs/PR28332/b.h cfe/trunk/test/Modules/Inputs/PR28332/c.h cfe/trunk/test/Modules/Inputs/PR28332/module.modulemap cfe/trunk/test/Modules/pr28332.cpp Modified: cfe/trunk/include/clang/Serialization/ASTReader.h cfe/trunk/lib/Serialization/ASTReader.cpp cfe/trunk/lib/Serialization/ASTReaderDecl.cpp cfe/trunk/lib/Serialization/ASTWriter.cpp ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r276473 - [modules] Teach the ASTWriter to ignore mutations coming from the ASTReader.
Should this be merged to 3.9? On Fri, Jul 22, 2016 at 2:08 PM, Vassil Vassilev via cfe-commits wrote: > Author: vvassilev > Date: Fri Jul 22 16:08:24 2016 > New Revision: 276473 > > URL: http://llvm.org/viewvc/llvm-project?rev=276473&view=rev > Log: > [modules] Teach the ASTWriter to ignore mutations coming from the ASTReader. > > Processing update records (and loading a module, in general) might trigger > unexpected calls to the ASTWriter (being a mutation listener). Now we have a > mechanism to suppress those calls to the ASTWriter but notify other possible > mutation listeners. > > Fixes https://llvm.org/bugs/show_bug.cgi?id=28332 > > Patch by Cristina Cristescu and me. > > Reviewed by Richard Smith (D21800). > > Added: > cfe/trunk/test/Modules/Inputs/PR28332/ > cfe/trunk/test/Modules/Inputs/PR28332/TextualInclude.h > cfe/trunk/test/Modules/Inputs/PR28332/a.h > cfe/trunk/test/Modules/Inputs/PR28332/b.h > cfe/trunk/test/Modules/Inputs/PR28332/c.h > cfe/trunk/test/Modules/Inputs/PR28332/module.modulemap > cfe/trunk/test/Modules/pr28332.cpp > Modified: > cfe/trunk/include/clang/Serialization/ASTReader.h > cfe/trunk/lib/Serialization/ASTReader.cpp > cfe/trunk/lib/Serialization/ASTReaderDecl.cpp > cfe/trunk/lib/Serialization/ASTWriter.cpp ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r276473 - [modules] Teach the ASTWriter to ignore mutations coming from the ASTReader.
Author: vvassilev Date: Fri Jul 22 16:08:24 2016 New Revision: 276473 URL: http://llvm.org/viewvc/llvm-project?rev=276473&view=rev Log: [modules] Teach the ASTWriter to ignore mutations coming from the ASTReader. Processing update records (and loading a module, in general) might trigger unexpected calls to the ASTWriter (being a mutation listener). Now we have a mechanism to suppress those calls to the ASTWriter but notify other possible mutation listeners. Fixes https://llvm.org/bugs/show_bug.cgi?id=28332 Patch by Cristina Cristescu and me. Reviewed by Richard Smith (D21800). Added: cfe/trunk/test/Modules/Inputs/PR28332/ cfe/trunk/test/Modules/Inputs/PR28332/TextualInclude.h cfe/trunk/test/Modules/Inputs/PR28332/a.h cfe/trunk/test/Modules/Inputs/PR28332/b.h cfe/trunk/test/Modules/Inputs/PR28332/c.h cfe/trunk/test/Modules/Inputs/PR28332/module.modulemap cfe/trunk/test/Modules/pr28332.cpp Modified: cfe/trunk/include/clang/Serialization/ASTReader.h cfe/trunk/lib/Serialization/ASTReader.cpp cfe/trunk/lib/Serialization/ASTReaderDecl.cpp cfe/trunk/lib/Serialization/ASTWriter.cpp Modified: cfe/trunk/include/clang/Serialization/ASTReader.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=276473&r1=276472&r2=276473&view=diff == --- cfe/trunk/include/clang/Serialization/ASTReader.h (original) +++ cfe/trunk/include/clang/Serialization/ASTReader.h Fri Jul 22 16:08:24 2016 @@ -842,6 +842,9 @@ private: /// \brief Whether we have tried loading the global module index yet. bool TriedLoadingGlobalIndex; + ///\brief Whether we are currently processing update records. + bool ProcessingUpdateRecords; + typedef llvm::DenseMap SwitchCaseMapTy; /// \brief Mapping from switch-case IDs in the chain to switch-case statements /// @@ -1041,6 +1044,23 @@ private: ~ReadingKindTracker() { Reader.ReadingKind = PrevKind; } }; + /// \brief RAII object to mark the start of processing updates. + class ProcessingUpdatesRAIIObj { +ASTReader &Reader; +bool PrevState; + +ProcessingUpdatesRAIIObj(const ProcessingUpdatesRAIIObj &) = delete; +void operator=(const ProcessingUpdatesRAIIObj &) = delete; + + public: +ProcessingUpdatesRAIIObj(ASTReader &reader) + : Reader(reader), PrevState(Reader.ProcessingUpdateRecords) { + Reader.ProcessingUpdateRecords = true; +} + +~ProcessingUpdatesRAIIObj() { Reader.ProcessingUpdateRecords = PrevState; } + }; + /// \brief Suggested contents of the predefines buffer, after this /// PCH file has been processed. /// @@ -2129,6 +2149,8 @@ public: /// \brief Loads comments ranges. void ReadComments() override; + + bool isProcessingUpdateRecords() { return ProcessingUpdateRecords; } }; /// \brief Helper class that saves the current stream position and Modified: cfe/trunk/lib/Serialization/ASTReader.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=276473&r1=276472&r2=276473&view=diff == --- cfe/trunk/lib/Serialization/ASTReader.cpp (original) +++ cfe/trunk/lib/Serialization/ASTReader.cpp Fri Jul 22 16:08:24 2016 @@ -8644,6 +8644,7 @@ void ASTReader::FinishedDeserializing() auto Updates = std::move(PendingExceptionSpecUpdates); PendingExceptionSpecUpdates.clear(); for (auto Update : Updates) { +ProcessingUpdatesRAIIObj ProcessingUpdates(*this); auto *FPT = Update.second->getType()->castAs(); auto ESI = FPT->getExtProtoInfo().ExceptionSpec; if (auto *Listener = Context.getASTMutationListener()) @@ -8714,6 +8715,7 @@ ASTReader::ASTReader( AllowConfigurationMismatch(AllowConfigurationMismatch), ValidateSystemInputs(ValidateSystemInputs), UseGlobalIndex(UseGlobalIndex), TriedLoadingGlobalIndex(false), + ProcessingUpdateRecords(false), CurrSwitchCaseStmts(&SwitchCaseStmts), NumSLocEntriesRead(0), TotalNumSLocEntries(0), NumStatementsRead(0), TotalNumStatements(0), NumMacrosRead(0), TotalNumMacros(0), NumIdentifierLookups(0), Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=276473&r1=276472&r2=276473&view=diff == --- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original) +++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Fri Jul 22 16:08:24 2016 @@ -3489,6 +3489,7 @@ void ASTReader::loadDeclUpdateRecords(se // The declaration may have been modified by files later in the chain. // If this is the case, read the record containing the updates from each file // and pass it to ASTDeclReader to make the modifications. + ProcessingUpdatesRAIIObj ProcessingUpdates(*this