<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 22 June 2017 at 16:18, Michael Gottesman <span dir="ltr"><<a href="mailto:mgottesman@apple.com" target="_blank">mgottesman@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word"><br><div><span class="gmail-"><blockquote type="cite"><div>On Jun 21, 2017, at 4:56 PM, Richard Smith via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>> wrote:</div><br class="gmail-m_1379290276311384898Apple-interchange-newline"><div><div dir="ltr" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div class="gmail_extra"><div class="gmail_quote">On 21 June 2017 at 16:55, Bruno Cardoso Lopes<span class="gmail-m_1379290276311384898Apple-converted-space"> </span><span dir="ltr"><<a href="mailto:bruno.cardoso@gmail.com" target="_blank">bruno.cardoso@gmail.com</a><wbr>></span><span class="gmail-m_1379290276311384898Apple-converted-space"> </span>wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span>On Wed, Jun 21, 2017 at 4:44 PM, Richard Smith <<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a>> wrote:<br>> On 21 June 2017 at 14:51, Bruno Cardoso Lopes <<a href="mailto:bruno.cardoso@gmail.com" target="_blank">bruno.cardoso@gmail.com</a>><br>> wrote:<br>>><br>>> Hi Richard,<br>>><br>>> Somehow this commit caused some methods in ObjC to do not become<br>>> visible in an interface when compiling with modules on. I filed<br>>><span class="gmail-m_1379290276311384898Apple-converted-space"> </span><a href="https://bugs.llvm.org/show_bug.cgi?id=33552" rel="noreferrer" target="_blank">https://bugs.llvm.org/show_<wbr>bug.cgi?id=33552</a>, any idea what could have<br>>> gone wrong here? `hasVisibleDeclarationImpl` doesn't seem to have<br>>> changed the logic.<br>><br>><br>> DeclObjC.cpp is making some incorrect assumptions about what the isHidden()<br>> flag on Decls means. Looks like we're going to need to move all of the ObjC<br>> lookup machinery out of DeclObjC into Sema to allow it to perform correct<br>> visibility checks. (For what it's worth, this would already have been broken<br>> for Objective-C++ and local submodule visibility mode prior to this change,<br>> as those modes both have situations where the "Hidden" flag is not the<br>> complete story with regard to whether a declaration is visible in a<br>> particular lookup context.)<br><br></span>Oh, that's bad.<br><br>Is there any workaround we can do on top of this change for now in<br>order to have the previous behavior for non-LSV and ObjC? This is<br>keeping Swift from building against upstream right now.</blockquote><div><br></div><div>Yes, I'm working on what should (hopefully) be a fairly quick short-term fix.</div></div></div></div></div></blockquote><div><br></div></span><div>Thanks Richard!</div><div><br></div><div>Do you have an eta on this?</div></div></div></blockquote><div><br></div><div>Let me know if you're still having problems after r306075.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word"><div><div>This is blocking swift from compiling against ToT LLVM. As you know these changes come in fast so the longer we wait, the more likely other breakage sneaks in. I imagine we are going to probably build against the newer llvm/clang in the next bit, so this is the worst time to have a long period of time of breakage.</div><div><br></div><div>+CC Jordan Rose since I think he ran into this.</div><div><br></div><div>Thanks in advance = ),</div><div>Michael</div><div><div class="gmail-h5"><br><blockquote type="cite"><div><div dir="ltr" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div class="gmail_extra"><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail-m_1379290276311384898HOEnZb"><div class="gmail-m_1379290276311384898h5">>> Thanks,<br>>><br>>> On Wed, May 17, 2017 at 7:29 PM, Richard Smith via cfe-commits<br>>> <<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>> wrote:<br>>> > Author: rsmith<br>>> > Date: Wed May 17 21:29:20 2017<br>>> > New Revision: 303322<br>>> ><br>>> > URL:<span class="gmail-m_1379290276311384898Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project?rev=303322&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/<wbr>llvm-project?rev=303322&view=<wbr>rev</a><br>>> > Log:<br>>> > [modules] Switch from inferring owning modules based on source location<br>>> > to<br>>> > inferring based on the current module at the point of creation.<br>>> ><br>>> > This should result in no functional change except when building a<br>>> > preprocessed<br>>> > module (or more generally when using #pragma clang module begin/end to<br>>> > switch<br>>> > module in the middle of a file), in which case it allows us to correctly<br>>> > track<br>>> > the owning module for declarations. We can't map from FileID to module<br>>> > in the<br>>> > preprocessed module case, since all modules would have the same FileID.<br>>> ><br>>> > There are still a couple of remaining places that try to infer a module<br>>> > from a<br>>> > source location; I'll clean those up in follow-up changes.<br>>> ><br>>> > Modified:<br>>> >     cfe/trunk/include/clang/AST/A<wbr>STContext.h<br>>> >     cfe/trunk/include/clang/AST/D<wbr>eclBase.h<br>>> >     cfe/trunk/include/clang/<wbr>Basic/LangOptions.h<br>>> >     cfe/trunk/include/clang/Sema/<wbr>Sema.h<br>>> >     cfe/trunk/include/clang/Seria<wbr>lization/ASTWriter.h<br>>> >     cfe/trunk/lib/CodeGen/CGDebug<wbr>Info.cpp<br>>> >     cfe/trunk/lib/Sema/SemaDecl.c<wbr>pp<br>>> >     cfe/trunk/lib/Sema/<wbr>SemaLookup.cpp<br>>> >     cfe/trunk/lib/Sema/SemaTempla<wbr>te.cpp<br>>> >     cfe/trunk/lib/Serialization/A<wbr>STWriter.cpp<br>>> >     cfe/trunk/lib/Serialization/A<wbr>STWriterDecl.cpp<br>>> >     cfe/trunk/test/Modules/prepro<wbr>cess-module.cpp<br>>> >     cfe/trunk/test/SemaCXX/module<wbr>s-ts.cppm<br>>> ><br>>> > Modified: cfe/trunk/include/clang/AST/AS<wbr>TContext.h<br>>> > URL:<br>>> ><span class="gmail-m_1379290276311384898Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=303322&r1=303321&r2=303322&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/include/clan<wbr>g/AST/ASTContext.h?rev=303322&<wbr>r1=303321&r2=303322&view=diff</a><br>>> ><br>>> > ==============================<wbr>==============================<wbr>==================<br>>> > --- cfe/trunk/include/clang/AST/AS<wbr>TContext.h (original)<br>>> > +++ cfe/trunk/include/clang/AST/AS<wbr>TContext.h Wed May 17 21:29:20 2017<br>>> > @@ -935,7 +935,7 @@ public:<br>>> ><br>>> >    /// \brief Get the additional modules in which the definition \p Def<br>>> > has<br>>> >    /// been merged.<br>>> > -  ArrayRef<Module*> getModulesWithMergedDefinition<wbr>(NamedDecl *Def) {<br>>> > +  ArrayRef<Module*> getModulesWithMergedDefinition<wbr>(const NamedDecl<br>>> > *Def) {<br>>> >      auto MergedIt = MergedDefModules.find(Def);<br>>> >      if (MergedIt == MergedDefModules.end())<br>>> >        return None;<br>>> ><br>>> > Modified: cfe/trunk/include/clang/AST/De<wbr>clBase.h<br>>> > URL:<br>>> ><span class="gmail-m_1379290276311384898Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=303322&r1=303321&r2=303322&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/include/clan<wbr>g/AST/DeclBase.h?rev=303322&<wbr>r1=303321&r2=303322&view=diff</a><br>>> ><br>>> > ==============================<wbr>==============================<wbr>==================<br>>> > --- cfe/trunk/include/clang/AST/De<wbr>clBase.h (original)<br>>> > +++ cfe/trunk/include/clang/AST/De<wbr>clBase.h Wed May 17 21:29:20 2017<br>>> > @@ -332,15 +332,15 @@ private:<br>>> >    bool AccessDeclContextSanity() const;<br>>> ><br>>> >  protected:<br>>> > -<br>>> >    Decl(Kind DK, DeclContext *DC, SourceLocation L)<br>>> > -    : NextInContextAndBits(), DeclCtx(DC),<br>>> > -      Loc(L), DeclKind(DK), InvalidDecl(0),<br>>> > -      HasAttrs(false), Implicit(false), Used(false), Referenced(false),<br>>> > -      Access(AS_none), FromASTFile(0), Hidden(DC &&<br>>> > cast<Decl>(DC)->Hidden),<br>>> > -      IdentifierNamespace(getIdentif<wbr>ierNamespaceForKind(DK)),<br>>> > -      CacheValidAndLinkage(0)<br>>> > -  {<br>>> > +      : NextInContextAndBits(), DeclCtx(DC), Loc(L), DeclKind(DK),<br>>> > +        InvalidDecl(0), HasAttrs(false), Implicit(false), Used(false),<br>>> > +        Referenced(false), Access(AS_none), FromASTFile(0),<br>>> > +        Hidden(DC && cast<Decl>(DC)->Hidden &&<br>>> > +               (!cast<Decl>(DC)->isFromASTFi<wbr>le() ||<br>>> > +                hasLocalOwningModuleStorage())<wbr>),<br>>> > +        IdentifierNamespace(getIdentif<wbr>ierNamespaceForKind(DK)),<br>>> > +        CacheValidAndLinkage(0) {<br>>> >      if (StatisticsEnabled) add(DK);<br>>> >    }<br>>> ><br>>> > @@ -698,6 +698,9 @@ public:<br>>> >    Module *getLocalOwningModule() const {<br>>> >      if (isFromASTFile() || !Hidden)<br>>> >        return nullptr;<br>>> > +<br>>> > +    assert(hasLocalOwningModuleSto<wbr>rage() &&<br>>> > +           "hidden local decl but no local module storage");<br>>> >      return reinterpret_cast<Module *const *>(this)[-1];<br>>> >    }<br>>> >    void setLocalOwningModule(Module *M) {<br>>> ><br>>> > Modified: cfe/trunk/include/clang/Basic/<wbr>LangOptions.h<br>>> > URL:<br>>> ><span class="gmail-m_1379290276311384898Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.h?rev=303322&r1=303321&r2=303322&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/include/clan<wbr>g/Basic/LangOptions.h?rev=3033<wbr>22&r1=303321&r2=303322&view=<wbr>diff</a><br>>> ><br>>> > ==============================<wbr>==============================<wbr>==================<br>>> > --- cfe/trunk/include/clang/Basic/<wbr>LangOptions.h (original)<br>>> > +++ cfe/trunk/include/clang/Basic/<wbr>LangOptions.h Wed May 17 21:29:20 2017<br>>> > @@ -168,7 +168,7 @@ public:<br>>> ><br>>> >    /// Do we need to track the owning module for a local declaration?<br>>> >    bool trackLocalOwningModule() const {<br>>> > -    return ModulesLocalVisibility;<br>>> > +    return isCompilingModule() || ModulesLocalVisibility || ModulesTS;<br>>> >    }<br>>> ><br>>> >    bool isSignedOverflowDefined() const {<br>>> ><br>>> > Modified: cfe/trunk/include/clang/Sema/S<wbr>ema.h<br>>> > URL:<br>>> ><span class="gmail-m_1379290276311384898Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=303322&r1=303321&r2=303322&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/include/clan<wbr>g/Sema/Sema.h?rev=303322&r1=<wbr>303321&r2=303322&view=diff</a><br>>> ><br>>> > ==============================<wbr>==============================<wbr>==================<br>>> > --- cfe/trunk/include/clang/Sema/S<wbr>ema.h (original)<br>>> > +++ cfe/trunk/include/clang/Sema/S<wbr>ema.h Wed May 17 21:29:20 2017<br>>> > @@ -1507,6 +1507,12 @@ public:<br>>> >    hasVisibleDefaultArgument(cons<wbr>t NamedDecl *D,<br>>> >                              llvm::SmallVectorImpl<Module *> *Modules =<br>>> > nullptr);<br>>> ><br>>> > +  /// Determine if there is a visible declaration of \p D that is an<br>>> > explicit<br>>> > +  /// specialization declaration for a specialization of a template.<br>>> > (For a<br>>> > +  /// member specialization, use hasVisibleMemberSpecialization<wbr>.)<br>>> > +  bool hasVisibleExplicitSpecializati<wbr>on(<br>>> > +      const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules =<br>>> > nullptr);<br>>> > +<br>>> >    /// Determine if there is a visible declaration of \p D that is a<br>>> > member<br>>> >    /// specialization declaration (as opposed to an instantiated<br>>> > declaration).<br>>> >    bool hasVisibleMemberSpecialization<wbr>(<br>>> > @@ -2360,7 +2366,7 @@ public:<br>>> >    void MergeVarDeclTypes(VarDecl *New, VarDecl *Old, bool<br>>> > MergeTypeWithOld);<br>>> >    void MergeVarDeclExceptionSpecs(Var<wbr>Decl *New, VarDecl *Old);<br>>> >    bool checkVarDeclRedefinition(VarDe<wbr>cl *OldDefn, VarDecl *NewDefn);<br>>> > -  void notePreviousDefinition(SourceL<wbr>ocation Old, SourceLocation New);<br>>> > +  void notePreviousDefinition(const NamedDecl *Old, SourceLocation<br>>> > New);<br>>> >    bool MergeCXXFunctionDecl(FunctionD<wbr>ecl *New, FunctionDecl *Old, Scope<br>>> > *S);<br>>> ><br>>> >    // AssignmentAction - This is used by all the assignment diagnostic<br>>> > functions<br>>> ><br>>> > Modified: cfe/trunk/include/clang/Serial<wbr>ization/ASTWriter.h<br>>> > URL:<br>>> ><span class="gmail-m_1379290276311384898Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTWriter.h?rev=303322&r1=303321&r2=303322&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/include/clan<wbr>g/Serialization/ASTWriter.h?<wbr>rev=303322&r1=303321&r2=303322<wbr>&view=diff</a><br>>> ><br>>> > ==============================<wbr>==============================<wbr>==================<br>>> > --- cfe/trunk/include/clang/Serial<wbr>ization/ASTWriter.h (original)<br>>> > +++ cfe/trunk/include/clang/Serial<wbr>ization/ASTWriter.h Wed May 17<br>>> > 21:29:20 2017<br>>> > @@ -627,10 +627,6 @@ public:<br>>> >    /// \brief Add a version tuple to the given record<br>>> >    void AddVersionTuple(const VersionTuple &Version, RecordDataImpl<br>>> > &Record);<br>>> ><br>>> > -  /// \brief Infer the submodule ID that contains an entity at the<br>>> > given<br>>> > -  /// source location.<br>>> > -  serialization::SubmoduleID<br>>> > inferSubmoduleIDFromLocation(S<wbr>ourceLocation Loc);<br>>> > -<br>>> >    /// \brief Retrieve or create a submodule ID for this module, or<br>>> > return 0 if<br>>> >    /// the submodule is neither local (a submodle of the<br>>> > currently-written module)<br>>> >    /// nor from an imported module.<br>>> ><br>>> > Modified: cfe/trunk/lib/CodeGen/CGDebugI<wbr>nfo.cpp<br>>> > URL:<br>>> ><span class="gmail-m_1379290276311384898Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=303322&r1=303321&r2=303322&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/lib/CodeGen/<wbr>CGDebugInfo.cpp?rev=303322&r1=<wbr>303321&r2=303322&view=diff</a><br>>> ><br>>> > ==============================<wbr>==============================<wbr>==================<br>>> > --- cfe/trunk/lib/CodeGen/CGDebugI<wbr>nfo.cpp (original)<br>>> > +++ cfe/trunk/lib/CodeGen/CGDebugI<wbr>nfo.cpp Wed May 17 21:29:20 2017<br>>> > @@ -2613,7 +2613,7 @@ llvm::DIModule *CGDebugInfo::getParentMo<br>>> >      // best to make this behavior a command line or debugger tuning<br>>> >      // option.<br>>> >      FullSourceLoc Loc(D->getLocation(),<br>>> > CGM.getContext().getSourceMana<wbr>ger());<br>>> > -    if (Module *M = ClangModuleMap->inferModuleFro<wbr>mLocation(Loc)) {<br>>> > +    if (Module *M = D->getOwningModule()) {<br>>> >        // This is a (sub-)module.<br>>> >        auto Info = ExternalASTSource::ASTSourceDe<wbr>scriptor(*M);<br>>> >        return getOrCreateModuleRef(Info, /*SkeletonCU=*/false);<br>>> ><br>>> > Modified: cfe/trunk/lib/Sema/SemaDecl.cp<wbr>p<br>>> > URL:<br>>> ><span class="gmail-m_1379290276311384898Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=303322&r1=303321&r2=303322&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/lib/Sema/Sem<wbr>aDecl.cpp?rev=303322&r1=303321<wbr>&r2=303322&view=diff</a><br>>> ><br>>> > ==============================<wbr>==============================<wbr>==================<br>>> > --- cfe/trunk/lib/Sema/SemaDecl.cp<wbr>p (original)<br>>> > +++ cfe/trunk/lib/Sema/SemaDecl.cp<wbr>p Wed May 17 21:29:20 2017<br>>> > @@ -2021,7 +2021,7 @@ bool Sema::isIncompatibleTypedef(Ty<wbr>peDec<br>>> >      Diag(New->getLocation(),<br>>> > diag::err_redefinition_variabl<wbr>y_modified_typedef)<br>>> >        << Kind << NewType;<br>>> >      if (Old->getLocation().isValid())<br>>> > -      notePreviousDefinition(Old->ge<wbr>tLocation(), New->getLocation());<br>>> > +      notePreviousDefinition(Old, New->getLocation());<br>>> >      New->setInvalidDecl();<br>>> >      return true;<br>>> >    }<br>>> > @@ -2034,7 +2034,7 @@ bool Sema::isIncompatibleTypedef(Ty<wbr>peDec<br>>> >      Diag(New->getLocation(), diag::err_redefinition_differe<wbr>nt_typedef)<br>>> >        << Kind << NewType << OldType;<br>>> >      if (Old->getLocation().isValid())<br>>> > -      notePreviousDefinition(Old->ge<wbr>tLocation(), New->getLocation());<br>>> > +      notePreviousDefinition(Old, New->getLocation());<br>>> >      New->setInvalidDecl();<br>>> >      return true;<br>>> >    }<br>>> > @@ -2101,7 +2101,7 @@ void Sema::MergeTypedefNameDecl(Sco<wbr>pe *S<br>>> ><br>>> >      NamedDecl *OldD = OldDecls.getRepresentativeDecl<wbr>();<br>>> >      if (OldD->getLocation().isValid()<wbr>)<br>>> > -      notePreviousDefinition(OldD->g<wbr>etLocation(), New->getLocation());<br>>> > +      notePreviousDefinition(OldD, New->getLocation());<br>>> ><br>>> >      return New->setInvalidDecl();<br>>> >    }<br>>> > @@ -2193,7 +2193,7 @@ void Sema::MergeTypedefNameDecl(Sco<wbr>pe *S<br>>> ><br>>> >      Diag(New->getLocation(), diag::err_redefinition)<br>>> >        << New->getDeclName();<br>>> > -    notePreviousDefinition(Old->ge<wbr>tLocation(), New->getLocation());<br>>> > +    notePreviousDefinition(Old, New->getLocation());<br>>> >      return New->setInvalidDecl();<br>>> >    }<br>>> ><br>>> > @@ -2214,7 +2214,7 @@ void Sema::MergeTypedefNameDecl(Sco<wbr>pe *S<br>>> ><br>>> >    Diag(New->getLocation(), diag::ext_redefinition_of_type<wbr>def)<br>>> >      << New->getDeclName();<br>>> > -  notePreviousDefinition(Old->ge<wbr>tLocation(), New->getLocation());<br>>> > +  notePreviousDefinition(Old, New->getLocation());<br>>> >  }<br>>> ><br>>> >  /// DeclhasAttr - returns true if decl Declaration already has the<br>>> > target<br>>> > @@ -2448,7 +2448,7 @@ static bool mergeDeclAttribute(Sema &S,<br>>> >    return false;<br>>> >  }<br>>> ><br>>> > -static const Decl *getDefinition(const Decl *D) {<br>>> > +static const NamedDecl *getDefinition(const Decl *D) {<br>>> >    if (const TagDecl *TD = dyn_cast<TagDecl>(D))<br>>> >      return TD->getDefinition();<br>>> >    if (const VarDecl *VD = dyn_cast<VarDecl>(D)) {<br>>> > @@ -2475,7 +2475,7 @@ static void checkNewAttributesAfterDef(S<br>>> >    if (!New->hasAttrs())<br>>> >      return;<br>>> ><br>>> > -  const Decl *Def = getDefinition(Old);<br>>> > +  const NamedDecl *Def = getDefinition(Old);<br>>> >    if (!Def || Def == New)<br>>> >      return;<br>>> ><br>>> > @@ -2502,7 +2502,7 @@ static void checkNewAttributesAfterDef(S<br>>> >                              : diag::err_redefinition;<br>>> >          S.Diag(VD->getLocation(), Diag) << VD->getDeclName();<br>>> >          if (Diag == diag::err_redefinition)<br>>> > -          S.notePreviousDefinition(Def-><wbr>getLocation(),<br>>> > VD->getLocation());<br>>> > +          S.notePreviousDefinition(Def, VD->getLocation());<br>>> >          else<br>>> >            S.Diag(Def->getLocation(), diag::note_previous_definition<wbr>);<br>>> >          VD->setInvalidDecl();<br>>> > @@ -2891,7 +2891,7 @@ bool Sema::MergeFunctionDecl(Functi<wbr>onDec<br>>> >      } else {<br>>> >        Diag(New->getLocation(), diag::err_redefinition_differe<wbr>nt_kind)<br>>> >          << New->getDeclName();<br>>> > -      notePreviousDefinition(OldD->g<wbr>etLocation(), New->getLocation());<br>>> > +      notePreviousDefinition(OldD, New->getLocation());<br>>> >        return true;<br>>> >      }<br>>> >    }<br>>> > @@ -2928,7 +2928,7 @@ bool Sema::MergeFunctionDecl(Functi<wbr>onDec<br>>> >        !Old->hasAttr<InternalLinkageA<wbr>ttr>()) {<br>>> >      Diag(New->getLocation(), diag::err_internal_linkage_red<wbr>eclaration)<br>>> >          << New->getDeclName();<br>>> > -    notePreviousDefinition(Old->ge<wbr>tLocation(), New->getLocation());<br>>> > +    notePreviousDefinition(Old, New->getLocation());<br>>> >      New->dropAttr<InternalLinkageA<wbr>ttr>();<br>>> >    }<br>>> ><br>>> > @@ -3657,7 +3657,7 @@ void Sema::MergeVarDecl(VarDecl *New, Lo<br>>> >    if (!Old) {<br>>> >      Diag(New->getLocation(), diag::err_redefinition_differe<wbr>nt_kind)<br>>> >          << New->getDeclName();<br>>> > -<br>>> > notePreviousDefinition(Previou<wbr>s.getRepresentativeDecl()->get<wbr>Location(),<br>>> > +    notePreviousDefinition(Previou<wbr>s.getRepresentativeDecl(),<br>>> >                             New->getLocation());<br>>> >      return New->setInvalidDecl();<br>>> >    }<br>>> > @@ -3687,7 +3687,7 @@ void Sema::MergeVarDecl(VarDecl *New, Lo<br>>> >        Old->getStorageClass() == SC_None &&<br>>> >        !Old->hasAttr<WeakImportAttr>(<wbr>)) {<br>>> >      Diag(New->getLocation(), diag::warn_weak_import) <<<br>>> > New->getDeclName();<br>>> > -    notePreviousDefinition(Old->ge<wbr>tLocation(), New->getLocation());<br>>> > +    notePreviousDefinition(Old, New->getLocation());<br>>> >      // Remove weak_import attribute on new declaration.<br>>> >      New->dropAttr<WeakImportAttr>(<wbr>);<br>>> >    }<br>>> > @@ -3696,7 +3696,7 @@ void Sema::MergeVarDecl(VarDecl *New, Lo<br>>> >        !Old->hasAttr<InternalLinkageA<wbr>ttr>()) {<br>>> >      Diag(New->getLocation(), diag::err_internal_linkage_red<wbr>eclaration)<br>>> >          << New->getDeclName();<br>>> > -    notePreviousDefinition(Old->ge<wbr>tLocation(), New->getLocation());<br>>> > +    notePreviousDefinition(Old, New->getLocation());<br>>> >      New->dropAttr<InternalLinkageA<wbr>ttr>();<br>>> >    }<br>>> ><br>>> > @@ -3853,29 +3853,22 @@ void Sema::MergeVarDecl(VarDecl *New, Lo<br>>> >      New->setImplicitlyInline();<br>>> >  }<br>>> ><br>>> > -void Sema::notePreviousDefinition(S<wbr>ourceLocation Old, SourceLocation<br>>> > New) {<br>>> > +void Sema::notePreviousDefinition(c<wbr>onst NamedDecl *Old, SourceLocation<br>>> > New) {<br>>> >    SourceManager &SrcMgr = getSourceManager();<br>>> >    auto FNewDecLoc = SrcMgr.getDecomposedLoc(New);<br>>> > -  auto FOldDecLoc = SrcMgr.getDecomposedLoc(Old);<br>>> > +  auto FOldDecLoc = SrcMgr.getDecomposedLoc(Old->g<wbr>etLocation());<br>>> >    auto *FNew = SrcMgr.getFileEntryForID(FNewD<wbr>ecLoc.first);<br>>> >    auto *FOld = SrcMgr.getFileEntryForID(FOldD<wbr>ecLoc.first);<br>>> >    auto &HSI = PP.getHeaderSearchInfo();<br>>> > -  StringRef HdrFilename =<br>>> > SrcMgr.getFilename(SrcMgr.getS<wbr>pellingLoc(Old));<br>>> > +  StringRef HdrFilename =<br>>> > +      SrcMgr.getFilename(SrcMgr.getS<wbr>pellingLoc(Old->getLocation())<wbr>);<br>>> ><br>>> > -  auto noteFromModuleOrInclude = [&](SourceLocation &Loc,<br>>> > -                                     SourceLocation &IncLoc) -> bool {<br>>> > -    Module *Mod = nullptr;<br>>> > +  auto noteFromModuleOrInclude = [&](Module *Mod,<br>>> > +                                     SourceLocation IncLoc) -> bool {<br>>> >      // Redefinition errors with modules are common with non modular<br>>> > mapped<br>>> >      // headers, example: a non-modular header H in module A that also<br>>> > gets<br>>> >      // included directly in a TU. Pointing twice to the same<br>>> > header/definition<br>>> >      // is confusing, try to get better diagnostics when modules is on.<br>>> > -    if (getLangOpts().Modules) {<br>>> > -      auto ModLoc = SrcMgr.getModuleImportLoc(Old)<wbr>;<br>>> > -      if (!ModLoc.first.isInvalid())<br>>> > -        Mod = HSI.getModuleMap().inferModule<wbr>FromLocation(<br>>> > -            FullSourceLoc(Loc, SrcMgr));<br>>> > -    }<br>>> > -<br>>> >      if (IncLoc.isValid()) {<br>>> >        if (Mod) {<br>>> >          Diag(IncLoc, diag::note_redefinition_module<wbr>s_same_file)<br>>> > @@ -3899,19 +3892,19 @@ void Sema::notePreviousDefinition(S<wbr>ource<br>>> >    if (FNew == FOld && FNewDecLoc.second == FOldDecLoc.second) {<br>>> >      SourceLocation OldIncLoc = SrcMgr.getIncludeLoc(FOldDecLo<wbr>c.first);<br>>> >      SourceLocation NewIncLoc = SrcMgr.getIncludeLoc(FNewDecLo<wbr>c.first);<br>>> > -    EmittedDiag = noteFromModuleOrInclude(Old, OldIncLoc);<br>>> > -    EmittedDiag |= noteFromModuleOrInclude(New, NewIncLoc);<br>>> > +    EmittedDiag = noteFromModuleOrInclude(Old->g<wbr>etOwningModule(),<br>>> > OldIncLoc);<br>>> > +    EmittedDiag |= noteFromModuleOrInclude(getCur<wbr>rentModule(),<br>>> > NewIncLoc);<br>>> ><br>>> >      // If the header has no guards, emit a note suggesting one.<br>>> >      if (FOld && !HSI.isFileMultipleIncludeGuar<wbr>ded(FOld))<br>>> > -      Diag(Old, diag::note_use_ifdef_guards);<br>>> > +      Diag(Old->getLocation(), diag::note_use_ifdef_guards);<br>>> ><br>>> >      if (EmittedDiag)<br>>> >        return;<br>>> >    }<br>>> ><br>>> >    // Redefinition coming from different files or couldn't do better<br>>> > above.<br>>> > -  Diag(Old, diag::note_previous_definition<wbr>);<br>>> > +  Diag(Old->getLocation(), diag::note_previous_definition<wbr>);<br>>> >  }<br>>> ><br>>> >  /// We've just determined that \p Old and \p New both appear to be<br>>> > definitions<br>>> > @@ -3934,7 +3927,7 @@ bool Sema::checkVarDeclRedefinition<wbr>(VarD<br>>> >      return false;<br>>> >    } else {<br>>> >      Diag(New->getLocation(), diag::err_redefinition) << New;<br>>> > -    notePreviousDefinition(Old->ge<wbr>tLocation(), New->getLocation());<br>>> > +    notePreviousDefinition(Old, New->getLocation());<br>>> >      New->setInvalidDecl();<br>>> >      return true;<br>>> >    }<br>>> > @@ -13503,9 +13496,7 @@ Decl *Sema::ActOnTag(Scope *S, unsigned<br>>> >              } else if (TUK == TUK_Reference &&<br>>> >                         (PrevTagDecl->getFriendObject<wbr>Kind() ==<br>>> >                              Decl::FOK_Undeclared ||<br>>> > -                        PP.getModuleContainingLocation<wbr>(<br>>> > -                            PrevDecl->getLocation()) !=<br>>> > -                            PP.getModuleContainingLocation<wbr>(KWLoc)) &&<br>>> > +                        PrevDecl->getOwningModule() !=<br>>> > getCurrentModule()) &&<br>>> >                         SS.isEmpty()) {<br>>> >                // This declaration is a reference to an existing entity,<br>>> > but<br>>> >                // has different visibility from that entity: it either<br>>> > makes<br>>> > @@ -13561,7 +13552,7 @@ Decl *Sema::ActOnTag(Scope *S, unsigned<br>>> >                    Diag(NameLoc, diag::warn_redefinition_in_par<wbr>am_list)<br>>> > << Name;<br>>> >                  else<br>>> >                    Diag(NameLoc, diag::err_redefinition) << Name;<br>>> > -                notePreviousDefinition(Def->ge<wbr>tLocation(),<br>>> > +                notePreviousDefinition(Def,<br>>> >                                         NameLoc.isValid() ? NameLoc :<br>>> > KWLoc);<br>>> >                  // If this is a redefinition, recover by making this<br>>> >                  // struct be anonymous, which will make any later<br>>> > @@ -13652,7 +13643,7 @@ Decl *Sema::ActOnTag(Scope *S, unsigned<br>>> >          // The tag name clashes with something else in the target<br>>> > scope,<br>>> >          // issue an error and recover by making this tag be anonymous.<br>>> >          Diag(NameLoc, diag::err_redefinition_differe<wbr>nt_kind) << Name;<br>>> > -        notePreviousDefinition(PrevDec<wbr>l->getLocation(), NameLoc);<br>>> > +        notePreviousDefinition(PrevDec<wbr>l, NameLoc);<br>>> >          Name = nullptr;<br>>> >          Invalid = true;<br>>> >        }<br>>> > @@ -15356,7 +15347,7 @@ Decl *Sema::ActOnEnumConstant(Scope *S,<br>>> >          Diag(IdLoc, diag::err_redefinition_of_enum<wbr>erator) << Id;<br>>> >        else<br>>> >          Diag(IdLoc, diag::err_redefinition) << Id;<br>>> > -      notePreviousDefinition(PrevDec<wbr>l->getLocation(), IdLoc);<br>>> > +      notePreviousDefinition(PrevDec<wbr>l, IdLoc);<br>>> >        return nullptr;<br>>> >      }<br>>> >    }<br>>> ><br>>> > Modified: cfe/trunk/lib/Sema/SemaLookup.<wbr>cpp<br>>> > URL:<br>>> ><span class="gmail-m_1379290276311384898Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=303322&r1=303321&r2=303322&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/lib/Sema/Sem<wbr>aLookup.cpp?rev=303322&r1=3033<wbr>21&r2=303322&view=diff</a><br>>> ><br>>> > ==============================<wbr>==============================<wbr>==================<br>>> > --- cfe/trunk/lib/Sema/SemaLookup.<wbr>cpp (original)<br>>> > +++ cfe/trunk/lib/Sema/SemaLookup.<wbr>cpp Wed May 17 21:29:20 2017<br>>> > @@ -1420,11 +1420,46 @@ bool Sema::hasVisibleDefaultArgumen<wbr>t(con<br>>> >                                       Modules);<br>>> >  }<br>>> ><br>>> > +template<typename Filter><br>>> > +static bool hasVisibleDeclarationImpl(Sema &S, const NamedDecl *D,<br>>> > +                                      llvm::SmallVectorImpl<Module *><br>>> > *Modules,<br>>> > +                                      Filter F) {<br>>> > +  for (auto *Redecl : D->redecls()) {<br>>> > +    auto *R = cast<NamedDecl>(Redecl);<br>>> > +    if (!F(R))<br>>> > +      continue;<br>>> > +<br>>> > +    if (S.isVisible(R))<br>>> > +      return true;<br>>> > +<br>>> > +    if (Modules) {<br>>> > +      Modules->push_back(R->getOwnin<wbr>gModule());<br>>> > +      const auto &Merged = S.Context.getModulesWithMerged<wbr>Definition(R);<br>>> > +      Modules->insert(Modules->end()<wbr>, Merged.begin(), Merged.end());<br>>> > +    }<br>>> > +  }<br>>> > +<br>>> > +  return false;<br>>> > +}<br>>> > +<br>>> > +bool Sema::hasVisibleExplicitSpecia<wbr>lization(<br>>> > +    const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules) {<br>>> > +  return hasVisibleDeclarationImpl(*thi<wbr>s, D, Modules, [](const<br>>> > NamedDecl *D) {<br>>> > +    if (auto *RD = dyn_cast<CXXRecordDecl>(D))<br>>> > +      return RD->getTemplateSpecializationK<wbr>ind() ==<br>>> > TSK_ExplicitSpecialization;<br>>> > +    if (auto *FD = dyn_cast<FunctionDecl>(D))<br>>> > +      return FD->getTemplateSpecializationK<wbr>ind() ==<br>>> > TSK_ExplicitSpecialization;<br>>> > +    if (auto *VD = dyn_cast<VarDecl>(D))<br>>> > +      return VD->getTemplateSpecializationK<wbr>ind() ==<br>>> > TSK_ExplicitSpecialization;<br>>> > +    llvm_unreachable("unknown explicit specialization kind");<br>>> > +  });<br>>> > +}<br>>> > +<br>>> >  bool Sema::hasVisibleMemberSpeciali<wbr>zation(<br>>> >      const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules) {<br>>> >    assert(isa<CXXRecordDecl>(D->g<wbr>etDeclContext()) &&<br>>> >           "not a member specialization");<br>>> > -  for (auto *Redecl : D->redecls()) {<br>>> > +  return hasVisibleDeclarationImpl(*thi<wbr>s, D, Modules, [](const<br>>> > NamedDecl *D) {<br>>> >      // If the specialization is declared at namespace scope, then it's<br>>> > a member<br>>> >      // specialization declaration. If it's lexically inside the class<br>>> >      // definition then it was instantiated.<br>>> > @@ -1432,19 +1467,8 @@ bool Sema::hasVisibleMemberSpeciali<wbr>zatio<br>>> >      // FIXME: This is a hack. There should be a better way to determine<br>>> > this.<br>>> >      // FIXME: What about MS-style explicit specializations declared<br>>> > within a<br>>> >      //        class definition?<br>>> > -    if (Redecl->getLexicalDeclContext<wbr>()->isFileContext()) {<br>>> > -      auto *NonConstR =<br>>> > const_cast<NamedDecl*>(cast<Na<wbr>medDecl>(Redecl));<br>>> > -<br>>> > -      if (isVisible(NonConstR))<br>>> > -        return true;<br>>> > -<br>>> > -      if (Modules) {<br>>> > -        Modules->push_back(getOwningMo<wbr>dule(NonConstR));<br>>> > -        const auto &Merged =<br>>> > Context.getModulesWithMergedDe<wbr>finition(NonConstR);<br>>> > -        Modules->insert(Modules->end()<wbr>, Merged.begin(), Merged.end());<br>>> > -      }<br>>> > -    }<br>>> > -  }<br>>> > +    return D->getLexicalDeclContext()->is<wbr>FileContext();<br>>> > +  });<br>>> ><br>>> >    return false;<br>>> >  }<br>>> > @@ -1459,23 +1483,19 @@ bool Sema::hasVisibleMemberSpeciali<wbr>zatio<br>>> >  /// your module can see, including those later on in your module).<br>>> >  bool LookupResult::isVisibleSlow(Se<wbr>ma &SemaRef, NamedDecl *D) {<br>>> >    assert(D->isHidden() && "should not call this: not in slow case");<br>>> > -  Module *DeclModule = nullptr;<br>>> > -<br>>> > -  if (SemaRef.getLangOpts().Modules<wbr>LocalVisibility) {<br>>> > -    DeclModule = SemaRef.getOwningModule(D);<br>>> > -    if (!DeclModule) {<br>>> > -      assert(!D->isHidden() && "hidden decl not from a module");<br>>> > -      return true;<br>>> > -    }<br>>> ><br>>> > -    // If the owning module is visible, and the decl is not module<br>>> > private,<br>>> > -    // then the decl is visible too. (Module private is ignored within<br>>> > the same<br>>> > -    // top-level module.)<br>>> > -    if ((!D->isFromASTFile() || !D->isModulePrivate()) &&<br>>> > -        (SemaRef.isModuleVisible(DeclM<wbr>odule) ||<br>>> > -         SemaRef.hasVisibleMergedDefin<wbr>ition(D)))<br>>> > -      return true;<br>>> > -  }<br>>> > +  Module *DeclModule = SemaRef.getOwningModule(D);<br>>> > +  assert(DeclModule && "hidden decl not from a module");<br>>> > +<br>>> > +  // If the owning module is visible, and the decl is not module<br>>> > private,<br>>> > +  // then the decl is visible too. (Module private is ignored within<br>>> > the same<br>>> > +  // top-level module.)<br>>> > +  // FIXME: Check the owning module for module-private declarations<br>>> > rather than<br>>> > +  // assuming "same AST file" is the same thing as "same module".<br>>> > +  if ((!D->isFromASTFile() || !D->isModulePrivate()) &&<br>>> > +      (SemaRef.isModuleVisible(DeclM<wbr>odule) ||<br>>> > +       SemaRef.hasVisibleMergedDefin<wbr>ition(D)))<br>>> > +    return true;<br>>> ><br>>> >    // If this declaration is not at namespace scope nor module-private,<br>>> >    // then it is visible if its lexical parent has a visible definition.<br>>> > @@ -1571,20 +1591,8 @@ static NamedDecl *findAcceptableDecl(Sem<br>>> >  bool Sema::hasVisibleDeclarationSlo<wbr>w(const NamedDecl *D,<br>>> >                                       llvm::SmallVectorImpl<Module *><br>>> > *Modules) {<br>>> >    assert(!isVisible(D) && "not in slow case");<br>>> > -<br>>> > -  for (auto *Redecl : D->redecls()) {<br>>> > -    auto *NonConstR = const_cast<NamedDecl*>(cast<Na<wbr>medDecl>(Redecl));<br>>> > -    if (isVisible(NonConstR))<br>>> > -      return true;<br>>> > -<br>>> > -    if (Modules) {<br>>> > -      Modules->push_back(getOwningMo<wbr>dule(NonConstR));<br>>> > -      const auto &Merged =<br>>> > Context.getModulesWithMergedDe<wbr>finition(NonConstR);<br>>> > -      Modules->insert(Modules->end()<wbr>, Merged.begin(), Merged.end());<br>>> > -    }<br>>> > -  }<br>>> > -<br>>> > -  return false;<br>>> > +  return hasVisibleDeclarationImpl(*thi<wbr>s, D, Modules,<br>>> > +                                   [](const NamedDecl *) { return true;<br>>> > });<br>>> >  }<br>>> ><br>>> >  NamedDecl *LookupResult::getAcceptableDe<wbr>clSlow(NamedDecl *D) const {<br>>> > @@ -4957,6 +4965,14 @@ void Sema::diagnoseMissingImport(So<wbr>urceL<br>>> >                                   MissingImportKind MIK, bool Recover) {<br>>> >    assert(!Modules.empty());<br>>> ><br>>> > +  // Weed out duplicates from module list.<br>>> > +  llvm::SmallVector<Module*, 8> UniqueModules;<br>>> > +  llvm::SmallDenseSet<Module*, 8> UniqueModuleSet;<br>>> > +  for (auto *M : Modules)<br>>> > +    if (UniqueModuleSet.insert(M).sec<wbr>ond)<br>>> > +      UniqueModules.push_back(M);<br>>> > +  Modules = UniqueModules;<br>>> > +<br>>> >    if (Modules.size() > 1) {<br>>> >      std::string ModuleList;<br>>> >      unsigned N = 0;<br>>> ><br>>> > Modified: cfe/trunk/lib/Sema/SemaTemplat<wbr>e.cpp<br>>> > URL:<br>>> ><span class="gmail-m_1379290276311384898Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=303322&r1=303321&r2=303322&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/lib/Sema/Sem<wbr>aTemplate.cpp?rev=303322&r1=<wbr>303321&r2=303322&view=diff</a><br>>> ><br>>> > ==============================<wbr>==============================<wbr>==================<br>>> > --- cfe/trunk/lib/Sema/SemaTemplat<wbr>e.cpp (original)<br>>> > +++ cfe/trunk/lib/Sema/SemaTemplat<wbr>e.cpp Wed May 17 21:29:20 2017<br>>> > @@ -7901,6 +7901,7 @@ bool Sema::CheckFunctionTemplateSpe<wbr>ciali<br>>> >    TemplateSpecializationKind TSK =<br>>> > SpecInfo->getTemplateSpecializ<wbr>ationKind();<br>>> >    if (TSK == TSK_Undeclared || TSK == TSK_ImplicitInstantiation) {<br>>> >      Specialization->setLocation(FD<wbr>->getLocation());<br>>> > +    Specialization->setLexicalDecl<wbr>Context(FD->getLexicalDeclCont<wbr>ext());<br>>> >      // C++11 [dcl.constexpr]p1: An explicit specialization of a<br>>> > constexpr<br>>> >      // function can differ from the template declaration with respect<br>>> > to<br>>> >      // the constexpr specifier.<br>>> > @@ -7961,6 +7962,7 @@ bool Sema::CheckFunctionTemplateSpe<wbr>ciali<br>>> >        // FIXME: We need an update record for this AST mutation.<br>>> >        Specialization->setDeletedAsWr<wbr>itten(false);<br>>> >      }<br>>> > +    // FIXME: We need an update record for this AST mutation.<br>>> ><br>>> > SpecInfo->setTemplateSpecializ<wbr>ationKind(TSK_<wbr>ExplicitSpecialization);<br>>> >      MarkUnusedFileScopedDecl(Speci<wbr>alization);<br>>> >    }<br>>> > @@ -9745,7 +9747,7 @@ private:<br>>> >        IsHiddenExplicitSpecialization =<br>>> >            Spec->getMemberSpecializationI<wbr>nfo()<br>>> >                ? !S.hasVisibleMemberSpecializat<wbr>ion(Spec, &Modules)<br>>> > -              : !S.hasVisibleDeclaration(Spec)<wbr>;<br>>> > +              : !S.hasVisibleExplicitSpecializ<wbr>ation(Spec, &Modules);<br>>> >      } else {<br>>> >        checkInstantiated(Spec);<br>>> >      }<br>>> ><br>>> > Modified: cfe/trunk/lib/Serialization/AS<wbr>TWriter.cpp<br>>> > URL:<br>>> ><span class="gmail-m_1379290276311384898Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=303322&r1=303321&r2=303322&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/lib/Serializ<wbr>ation/ASTWriter.cpp?rev=<wbr>303322&r1=303321&r2=303322&<wbr>view=diff</a><br>>> ><br>>> > ==============================<wbr>==============================<wbr>==================<br>>> > --- cfe/trunk/lib/Serialization/AS<wbr>TWriter.cpp (original)<br>>> > +++ cfe/trunk/lib/Serialization/AS<wbr>TWriter.cpp Wed May 17 21:29:20 2017<br>>> > @@ -2841,25 +2841,6 @@ void ASTWriter::WriteSubmodules(Mod<wbr>ule *<br>>> >           "non-imported submodule?");<br>>> >  }<br>>> ><br>>> > -serialization::SubmoduleID<br>>> > -ASTWriter::inferSubmoduleIDFr<wbr>omLocation(SourceLocation Loc) {<br>>> > -  if (Loc.isInvalid() || !WritingModule)<br>>> > -    return 0; // No submodule<br>>> > -<br>>> > -  // Find the module that owns this location.<br>>> > -  ModuleMap &ModMap = PP->getHeaderSearchInfo().getM<wbr>oduleMap();<br>>> > -  Module *OwningMod<br>>> > -    =<br>>> > ModMap.inferModuleFromLocation<wbr>(FullSourceLoc(Loc,PP->getSour<wbr>ceManager()));<br>>> > -  if (!OwningMod)<br>>> > -    return 0;<br>>> > -<br>>> > -  // Check whether this submodule is part of our own module.<br>>> > -  if (WritingModule != OwningMod &&<br>>> > !OwningMod->isSubModuleOf(Writ<wbr>ingModule))<br>>> > -    return 0;<br>>> > -<br>>> > -  return getSubmoduleID(OwningMod);<br>>> > -}<br>>> > -<br>>> >  void ASTWriter::WritePragmaDiagnost<wbr>icMappings(const DiagnosticsEngine<br>>> > &Diag,<br>>> >                                                bool isModule) {<br>>> >    llvm::SmallDenseMap<const DiagnosticsEngine::DiagState *, unsigned,<br>>> > 64><br>>> ><br>>> > Modified: cfe/trunk/lib/Serialization/AS<wbr>TWriterDecl.cpp<br>>> > URL:<br>>> ><span class="gmail-m_1379290276311384898Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterDecl.cpp?rev=303322&r1=303321&r2=303322&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/lib/Serializ<wbr>ation/ASTWriterDecl.cpp?rev=<wbr>303322&r1=303321&r2=303322&<wbr>view=diff</a><br>>> ><br>>> > ==============================<wbr>==============================<wbr>==================<br>>> > --- cfe/trunk/lib/Serialization/AS<wbr>TWriterDecl.cpp (original)<br>>> > +++ cfe/trunk/lib/Serialization/AS<wbr>TWriterDecl.cpp Wed May 17 21:29:20<br>>> > 2017<br>>> > @@ -299,7 +299,7 @@ void ASTDeclWriter::VisitDecl(Decl *D) {<br>>> >    Record.push_back(D->isTopLevel<wbr>DeclInObjCContainer());<br>>> >    Record.push_back(D->getAccess(<wbr>));<br>>> >    Record.push_back(D->isModulePr<wbr>ivate());<br>>> > -<br>>> > Record.push_back(Writer.inferS<wbr>ubmoduleIDFromLocation(D-><wbr>getLocation()));<br>>> > +  Record.push_back(Writer.getSub<wbr>moduleID(D->getOwningModule())<wbr>);<br>>> ><br>>> >    // If this declaration injected a name into a context different from<br>>> > its<br>>> >    // lexical context, and that context is an imported namespace, we<br>>> > need to<br>>> ><br>>> > Modified: cfe/trunk/test/Modules/preproc<wbr>ess-module.cpp<br>>> > URL:<br>>> ><span class="gmail-m_1379290276311384898Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/preprocess-module.cpp?rev=303322&r1=303321&r2=303322&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/test/Modules<wbr>/preprocess-module.cpp?rev=<wbr>303322&r1=303321&r2=303322&<wbr>view=diff</a><br>>> ><br>>> > ==============================<wbr>==============================<wbr>==================<br>>> > --- cfe/trunk/test/Modules/preproc<wbr>ess-module.cpp (original)<br>>> > +++ cfe/trunk/test/Modules/preproc<wbr>ess-module.cpp Wed May 17 21:29:20<br>>> > 2017<br>>> > @@ -25,8 +25,8 @@<br>>> >  // RUN: %clang_cc1 -fmodules -fmodule-name=file<br>>> > -fmodule-file=%t/fwd.pcm<br>>> > -fmodule-map-file=%S/Inputs/pr<wbr>eprocess/module.modulemap -x<br>>> > c++-module-map-cpp-output %t/rewrite.ii -emit-module -o /dev/null<br>>> ><br>>> >  // Check the module we built works.<br>>> > -// RUN: %clang_cc1 -fmodules -fmodule-file=%t/no-rewrite.pc<wbr>m %s -verify<br>>> > -// RUN: %clang_cc1 -fmodules -fmodule-file=%t/rewrite.pcm %s -verify<br>>> > +// RUN: %clang_cc1 -fmodules -fmodule-file=%t/no-rewrite.pc<wbr>m %s -I%t<br>>> > -verify -fno-modules-error-recovery<br>>> > +// RUN: %clang_cc1 -fmodules -fmodule-file=%t/rewrite.pcm %s -I%t<br>>> > -verify -fno-modules-error-recovery -DREWRITE<br>>> ><br>>> ><br>>> >  // == module map<br>>> > @@ -95,10 +95,12 @@<br>>> >  // NO-REWRITE: #pragma clang module end<br>>> ><br>>> ><br>>> > -// expected-no-diagnostics<br>>> > -<br>>> > -// FIXME: This should be rejected: we have not imported the submodule<br>>> > defining it yet.<br>>> > -__FILE *a;<br>>> > +__FILE *a; // expected-error {{declaration of '__FILE' must be<br>>> > imported}}<br>>> > +#ifdef REWRITE<br>>> > +// <a href="mailto:expected-note@rewrite.ii" target="_blank">expected-note@rewrite.ii</a>:1 {{here}}<br>>> > +#else<br>>> > +// <a href="mailto:expected-note@no-rewrite.ii" target="_blank">expected-note@no-rewrite.ii</a>:1 {{here}}<br>>> > +#endif<br>>> ><br>>> >  #pragma clang module import file<br>>> ><br>>> ><br>>> > Modified: cfe/trunk/test/SemaCXX/modules<wbr>-ts.cppm<br>>> > URL:<br>>> ><span class="gmail-m_1379290276311384898Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/modules-ts.cppm?rev=303322&r1=303321&r2=303322&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/test/SemaCXX<wbr>/modules-ts.cppm?rev=303322&<wbr>r1=303321&r2=303322&view=diff</a><br>>> ><br>>> > ==============================<wbr>==============================<wbr>==================<br>>> > --- cfe/trunk/test/SemaCXX/modules<wbr>-ts.cppm (original)<br>>> > +++ cfe/trunk/test/SemaCXX/modules<wbr>-ts.cppm Wed May 17 21:29:20 2017<br>>> > @@ -18,7 +18,8 @@ int n;<br>>> >  #if TEST >= 2<br>>> >  // expected-error@-2 {{redefinition of '}}<br>>> >  // expected-note@-3 {{unguarded header; consider using #ifdef guards or<br>>> > #pragma once}}<br>>> > -// expected-note-re@modules-ts.cp<wbr>pm:1 {{'{{.*}}modules-ts.cppm'<br>>> > included multiple times, additional include site here}}<br>>> > +// FIXME: We should drop the "header from" in this diagnostic.<br>>> > +// expected-note-re@modules-ts.cp<wbr>pm:1 {{'{{.*}}modules-ts.cppm'<br>>> > included multiple times, additional include site in header from module<br>>> > 'foo'}}<br>>> >  #endif<br>>> ><br>>> >  #if TEST == 0<br>>> ><br>>> ><br>>> > ______________________________<wbr>_________________<br>>> > cfe-commits mailing list<br>>> ><span class="gmail-m_1379290276311384898Apple-converted-space"> </span><a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>>> ><span class="gmail-m_1379290276311384898Apple-converted-space"> </span><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-<wbr>bin/mailman/listinfo/cfe-<wbr>commits</a><br>>><br>>><br>>><br>>> --<br>>> Bruno Cardoso Lopes<br>>><span class="gmail-m_1379290276311384898Apple-converted-space"> </span><a href="http://www.brunocardoso.cc/" rel="noreferrer" target="_blank">http://www.brunocardoso.cc</a><br>><br>><br><br><br><br>--<br>Bruno Cardoso Lopes<br><a href="http://www.brunocardoso.cc/" rel="noreferrer" target="_blank">http://www.brunocardoso.cc</a><br></div></div></blockquote></div><br></div></div><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline">______________________________<wbr>_________________</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline">cfe-commits mailing list</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline"><a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a></span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline"><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-commits</a></span></div></blockquote></div></div></div><br></div></blockquote></div><br></div></div>