On Thu, Mar 20, 2014 at 8:33 PM, Richard Smith <[email protected]> wrote: > Author: rsmith > Date: Thu Mar 20 19:33:59 2014 > New Revision: 204417 > > URL: http://llvm.org/viewvc/llvm-project?rev=204417&view=rev > Log: > PR19215: When writing/reading a PCH that imported a module, store the location > at which that PCH imported each visible submodule of the module. Such > locations > are needed when synthesizing macro directives resulting from the import. > > Added: > cfe/trunk/test/Modules/Inputs/macro-undef-through-pch/ > cfe/trunk/test/Modules/Inputs/macro-undef-through-pch/A.h > cfe/trunk/test/Modules/Inputs/macro-undef-through-pch/foo.h > cfe/trunk/test/Modules/Inputs/macro-undef-through-pch/module.map > cfe/trunk/test/Modules/macro-undef-through-pch.m > Modified: > cfe/trunk/include/clang/Serialization/ASTReader.h > cfe/trunk/lib/Serialization/ASTReader.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=204417&r1=204416&r2=204417&view=diff > ============================================================================== > --- cfe/trunk/include/clang/Serialization/ASTReader.h (original) > +++ cfe/trunk/include/clang/Serialization/ASTReader.h Thu Mar 20 19:33:59 2014 > @@ -767,9 +767,14 @@ private: > // \brief A list of late parsed template function data. > SmallVector<uint64_t, 1> LateParsedTemplates; > > + struct ImportedSubmodule { > + serialization::SubmoduleID ID; > + SourceLocation ImportLoc; > + }; > + > /// \brief A list of modules that were imported by precompiled headers or > /// any other non-module AST file. > - SmallVector<serialization::SubmoduleID, 2> ImportedModules; > + SmallVector<ImportedSubmodule, 2> ImportedModules; > //@} > > /// \brief The directory that the PCH we are reading is stored in. > > Modified: cfe/trunk/lib/Serialization/ASTReader.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=204417&r1=204416&r2=204417&view=diff > ============================================================================== > --- cfe/trunk/lib/Serialization/ASTReader.cpp (original) > +++ cfe/trunk/lib/Serialization/ASTReader.cpp Thu Mar 20 19:33:59 2014 > @@ -1811,6 +1811,7 @@ void ASTReader::installImportedMacro(Ide > // Use the location at which the containing module file was first > imported > // for now. > ImportLoc = MMI->F->DirectImportLoc; > + assert(ImportLoc.isValid() && "no import location for a visible macro?"); > } > > llvm::SmallVectorImpl<DefMacroDirective*> *Prev = > @@ -3012,9 +3013,11 @@ bool ASTReader::ReadASTBlock(ModuleFile > // If we aren't loading a module (which has its own exports), make > // all of the imported modules visible. > // FIXME: Deal with macros-only imports. > - for (unsigned I = 0, N = Record.size(); I != N; ++I) { > - if (unsigned GlobalID = getGlobalSubmoduleID(F, Record[I])) > - ImportedModules.push_back(GlobalID); > + for (unsigned I = 0, N = Record.size(); I != N; /**/) { > + unsigned GlobalID = getGlobalSubmoduleID(F, Record[I++]); > + SourceLocation Loc = ReadSourceLocation(F, Record, I); > + if (GlobalID) > + ImportedModules.push_back({GlobalID, Loc});
Unfortunately, this construct doesn't work in MSVC 2012. I fixed up similar usages in r204471. It does work in MSVC 2013, so eventually we can use it instead of explicit constructors. ~Aaron _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
