<div dir="ltr">Should be fixed in r312580, thanks!<br></div><div class="gmail_extra"><br><div class="gmail_quote">On 5 September 2017 at 13:58, Richard Smith <span dir="ltr"><<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Thanks, looking...</div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On 5 September 2017 at 13:31, Evgenii Stepanov via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Richard,<br>
<br>
this change has triggered a bunch of leak reports on the sanitizer bots:<br>
<br>
Direct leak of 1824 byte(s) in 1 object(s) allocated from:<br>
#0 0xb48430 in operator new(unsigned long)<br>
/mnt/b/sanitizer-buildbot3/san<wbr>itizer-x86_64-linux-fast/build<wbr>/llvm/projects/compiler-rt/<wbr>lib/asan/asan_new_delete.cc:82<br>
#1 0xadfd119 in<br>
clang::ModuleMap::createGlobal<wbr>ModuleForInterfaceUnit(clang::<wbr>SourceLocation)<br>
/mnt/b/sanitizer-buildbot3/san<wbr>itizer-x86_64-linux-fast/build<wbr>/llvm/tools/clang/lib/Lex/<wbr>ModuleMap.cpp:750:18<br>
#2 0x860e9be in clang::Sema::ActOnStartOfTrans<wbr>lationUnit()<br>
/mnt/b/sanitizer-buildbot3/san<wbr>itizer-x86_64-linux-fast/build<wbr>/llvm/tools/clang/lib/Sema/<wbr>Sema.cpp:775:30<br>
#3 0x7d27209 in<br>
clang::Parser::ParseFirstTopLe<wbr>velDecl(clang::OpaquePtr<<wbr>clang::DeclGroupRef>&)<br>
/mnt/b/sanitizer-buildbot3/san<wbr>itizer-x86_64-linux-fast/build<wbr>/llvm/tools/clang/lib/Parse/<wbr>Parser.cpp:529:11<br>
#4 0x7d158fe in clang::ParseAST(clang::Sema&, bool, bool)<br>
/mnt/b/sanitizer-buildbot3/san<wbr>itizer-x86_64-linux-fast/build<wbr>/llvm/tools/clang/lib/Parse/<wbr>ParseAST.cpp:146:23<br>
#5 0x618926e in clang::FrontendAction::Execute<wbr>()<br>
/mnt/b/sanitizer-buildbot3/san<wbr>itizer-x86_64-linux-fast/build<wbr>/llvm/tools/clang/lib/Frontend<wbr>/FrontendAction.cpp:902:8<br>
#6 0x6090664 in<br>
clang::CompilerInstance::Execu<wbr>teAction(clang::FrontendAction<wbr>&)<br>
/mnt/b/sanitizer-buildbot3/san<wbr>itizer-x86_64-linux-fast/build<wbr>/llvm/tools/clang/lib/Frontend<wbr>/CompilerInstance.cpp:986:11<br>
#7 0x637eb45 in<br>
clang::ExecuteCompilerInvocati<wbr>on(clang::CompilerInstance*)<br>
/mnt/b/sanitizer-buildbot3/san<wbr>itizer-x86_64-linux-fast/build<wbr>/llvm/tools/clang/lib/Frontend<wbr>Tool/ExecuteCompilerInvocation<wbr>.cpp:252:25<br>
#8 0xb5b13f in cc1_main(llvm::ArrayRef<char const*>, char const*,<br>
void*) /mnt/b/sanitizer-buildbot3/san<wbr>itizer-x86_64-linux-fast/build<wbr>/llvm/tools/clang/tools/driver<wbr>/cc1_main.cpp:221:13<br>
#9 0xb53d33 in ExecuteCC1Tool<br>
/mnt/b/sanitizer-buildbot3/san<wbr>itizer-x86_64-linux-fast/build<wbr>/llvm/tools/clang/tools/driver<wbr>/driver.cpp:302:12<br>
#10 0xb53d33 in main<br>
/mnt/b/sanitizer-buildbot3/san<wbr>itizer-x86_64-linux-fast/build<wbr>/llvm/tools/clang/tools/driver<wbr>/driver.cpp:381<br>
#11 0x7fc921b0b82f in __libc_start_main<br>
(/lib/x86_64-linux-gnu/libc.so<wbr>.6+0x2082f)<br>
<br>
Failing Tests (16):<br>
Clang :: CXX/modules-ts/basic/basic.def<wbr>.odr/p4/module.cpp<br>
Clang :: CXX/modules-ts/basic/basic.def<wbr>.odr/p4/user.cpp<br>
Clang :: CXX/modules-ts/basic/basic.lin<wbr>k/module-declaration.cpp<br>
Clang :: CXX/modules-ts/basic/basic.lin<wbr>k/p2/module.cpp<br>
Clang :: CXX/modules-ts/basic/basic.lin<wbr>k/p2/other.cpp<br>
Clang :: CXX/modules-ts/basic/basic.sea<wbr>rch/module-import.cpp<br>
Clang :: CXX/modules-ts/codegen-basics.<wbr>cppm<br>
Clang :: CXX/modules-ts/dcl.dcl/dcl.mod<wbr>ule/dcl.module.import/p1.cpp<br>
Clang :: CXX/modules-ts/dcl.dcl/dcl.mod<wbr>ule/dcl.module.interface/p1.<wbr>cpp<br>
Clang :: CXX/modules-ts/dcl.dcl/dcl.mod<wbr>ule/p5.cpp<br>
Clang :: Driver/modules-ts.cpp<br>
Clang :: Lexer/modules-ts.cpp<br>
Clang :: Modules/diag-flags.cpp<br>
Clang :: Modules/diag-pragma.cpp<br>
Clang :: Modules/import-syntax.c<br>
Clang :: SemaCXX/modules-ts.cppm<br>
<br>
<a href="http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/7630" rel="noreferrer" target="_blank">http://lab.llvm.org:8011/build<wbr>ers/sanitizer-x86_64-linux-<wbr>fast/builds/7630</a><br>
<div class="m_-5804605019892367179HOEnZb"><div class="m_-5804605019892367179h5"><br>
On Sun, Sep 3, 2017 at 10:37 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: Sun Sep 3 22:37:53 2017<br>
> New Revision: 312467<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=312467&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject?rev=312467&view=rev</a><br>
> Log:<br>
> Implement Itanium name mangling support for C++ Modules TS.<br>
><br>
> This follows the scheme agreed with Nathan Sidwell, which can be found here:<br>
><br>
> <a href="https://gcc.gnu.org/wiki/cxx-modules?action=AttachFile" rel="noreferrer" target="_blank">https://gcc.gnu.org/wiki/cxx-<wbr>modules?action=AttachFile</a><br>
><br>
> This will be proposed to the itanium-cxx-abi list once we have some experience<br>
> with how well it works; the ABI for this TS should be considered unstable until<br>
> it is part of the Itanium C++ ABI.<br>
><br>
> Modified:<br>
> cfe/trunk/include/clang/AST/D<wbr>ecl.h<br>
> cfe/trunk/include/clang/AST/D<wbr>eclBase.h<br>
> cfe/trunk/include/clang/<wbr>Basic/Module.h<br>
> cfe/trunk/include/clang/Lex/M<wbr>oduleMap.h<br>
> cfe/trunk/lib/AST/Decl.cpp<br>
> cfe/trunk/lib/AST/ItaniumMang<wbr>le.cpp<br>
> cfe/trunk/lib/Lex/ModuleMap.c<wbr>pp<br>
> cfe/trunk/lib/Sema/Sema.cpp<br>
> cfe/trunk/lib/Sema/SemaDecl.c<wbr>pp<br>
> cfe/trunk/lib/Serialization/A<wbr>STReader.cpp<br>
> cfe/trunk/lib/Serialization/A<wbr>STWriter.cpp<br>
> cfe/trunk/test/CXX/modules-<wbr>ts/basic/basic.def.odr/p4/<wbr>module.cpp<br>
> cfe/trunk/test/CXX/modules-<wbr>ts/basic/basic.def.odr/p4/<wbr>module.cppm<br>
> cfe/trunk/test/CXX/modules-<wbr>ts/basic/basic.def.odr/p4/<wbr>user.cpp<br>
> cfe/trunk/test/CXX/modules-<wbr>ts/codegen-basics.cppm<br>
> cfe/trunk/test/SemaCXX/module<wbr>s-ts.cppm<br>
><br>
> Modified: cfe/trunk/include/clang/AST/De<wbr>cl.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=312467&r1=312466&r2=312467&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/include/clang/<wbr>AST/Decl.h?rev=312467&r1=<wbr>312466&r2=312467&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- cfe/trunk/include/clang/AST/De<wbr>cl.h (original)<br>
> +++ cfe/trunk/include/clang/AST/De<wbr>cl.h Sun Sep 3 22:37:53 2017<br>
> @@ -372,6 +372,10 @@ public:<br>
> return hasCachedLinkage();<br>
> }<br>
><br>
> + /// Get the module that owns this declaration for linkage purposes.<br>
> + /// There only ever is such a module under the C++ Modules TS.<br>
> + Module *getOwningModuleForLinkage() const;<br>
> +<br>
> /// \brief Looks through UsingDecls and ObjCCompatibleAliasDecls for<br>
> /// the underlying named decl.<br>
> NamedDecl *getUnderlyingDecl() {<br>
><br>
> Modified: cfe/trunk/include/clang/AST/De<wbr>clBase.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=312467&r1=312466&r2=312467&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/include/clang/<wbr>AST/DeclBase.h?rev=312467&r1=<wbr>312466&r2=312467&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- cfe/trunk/include/clang/AST/De<wbr>clBase.h (original)<br>
> +++ cfe/trunk/include/clang/AST/De<wbr>clBase.h Sun Sep 3 22:37:53 2017<br>
> @@ -733,7 +733,7 @@ public:<br>
> return getModuleOwnershipKind() != ModuleOwnershipKind::Unowned;<br>
> }<br>
><br>
> - /// Get the module that owns this declaration.<br>
> + /// Get the module that owns this declaration (for visibility purposes).<br>
> Module *getOwningModule() const {<br>
> return isFromASTFile() ? getImportedOwningModule() : getLocalOwningModule();<br>
> }<br>
><br>
> Modified: cfe/trunk/include/clang/Basic/<wbr>Module.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Module.h?rev=312467&r1=312466&r2=312467&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/include/clang/<wbr>Basic/Module.h?rev=312467&r1=<wbr>312466&r2=312467&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- cfe/trunk/include/clang/Basic/<wbr>Module.h (original)<br>
> +++ cfe/trunk/include/clang/Basic/<wbr>Module.h Sun Sep 3 22:37:53 2017<br>
> @@ -68,7 +68,11 @@ public:<br>
> ModuleMapModule,<br>
><br>
> /// \brief This is a C++ Modules TS module interface unit.<br>
> - ModuleInterfaceUnit<br>
> + ModuleInterfaceUnit,<br>
> +<br>
> + /// \brief This is a fragment of the global module within some C++ Modules<br>
> + /// TS module.<br>
> + GlobalModuleFragment,<br>
> };<br>
><br>
> /// \brief The kind of this module.<br>
> @@ -391,6 +395,15 @@ public:<br>
> return IsFramework && Parent && Parent->isPartOfFramework();<br>
> }<br>
><br>
> + /// Set the parent of this module. This should only be used if the parent<br>
> + /// could not be set during module creation.<br>
> + void setParent(Module *M) {<br>
> + assert(!Parent);<br>
> + Parent = M;<br>
> + Parent->SubModuleIndex[Name] = Parent->SubModules.size();<br>
> + Parent->SubModules.push_back(t<wbr>his);<br>
> + }<br>
> +<br>
> /// \brief Retrieve the full name of this module, including the path from<br>
> /// its top-level module.<br>
> /// \param AllowStringLiterals If \c true, components that might not be<br>
><br>
> Modified: cfe/trunk/include/clang/Lex/Mo<wbr>duleMap.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/ModuleMap.h?rev=312467&r1=312466&r2=312467&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/include/clang/<wbr>Lex/ModuleMap.h?rev=312467&r1=<wbr>312466&r2=312467&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- cfe/trunk/include/clang/Lex/Mo<wbr>duleMap.h (original)<br>
> +++ cfe/trunk/include/clang/Lex/Mo<wbr>duleMap.h Sun Sep 3 22:37:53 2017<br>
> @@ -472,6 +472,14 @@ public:<br>
> bool IsFramework,<br>
> bool IsExplicit);<br>
><br>
> + /// \brief Create a 'global module' for a C++ Modules TS module interface<br>
> + /// unit.<br>
> + ///<br>
> + /// We model the global module as a submodule of the module interface unit.<br>
> + /// Unfortunately, we can't create the module interface unit's Module until<br>
> + /// later, because we don't know what it will be called.<br>
> + Module *createGlobalModuleForInterfac<wbr>eUnit(SourceLocation Loc);<br>
> +<br>
> /// \brief Create a new module for a C++ Modules TS module interface unit.<br>
> /// The module must not already exist, and will be configured for the current<br>
> /// compilation.<br>
> @@ -479,7 +487,8 @@ public:<br>
> /// Note that this also sets the current module to the newly-created module.<br>
> ///<br>
> /// \returns The newly-created module.<br>
> - Module *createModuleForInterfaceUnit(<wbr>SourceLocation Loc, StringRef Name);<br>
> + Module *createModuleForInterfaceUnit(<wbr>SourceLocation Loc, StringRef Name,<br>
> + Module *GlobalModule);<br>
><br>
> /// \brief Infer the contents of a framework module map from the given<br>
> /// framework directory.<br>
><br>
> Modified: cfe/trunk/lib/AST/Decl.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=312467&r1=312466&r2=312467&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/lib/AST/Decl.<wbr>cpp?rev=312467&r1=312466&r2=<wbr>312467&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- cfe/trunk/lib/AST/Decl.cpp (original)<br>
> +++ cfe/trunk/lib/AST/Decl.cpp Sun Sep 3 22:37:53 2017<br>
> @@ -652,7 +652,7 @@ LinkageComputer::getLVForNames<wbr>paceScopeD<br>
> // If the declaration of an identifier for an object has file<br>
> // scope and no storage-class specifier, its linkage is<br>
> // external.<br>
> - LinkageInfo LV;<br>
> + LinkageInfo LV = getExternalLinkageFor(D);<br>
><br>
> if (!hasExplicitVisibilityAlready<wbr>(computation)) {<br>
> if (Optional<Visibility> Vis = getExplicitVisibility(D, computation)) {<br>
> @@ -1399,6 +1399,30 @@ LinkageInfo LinkageComputer::getDeclLink<br>
> return getLVForDecl(D, usesTypeVisibility(D) ? LVForType : LVForValue);<br>
> }<br>
><br>
> +Module *NamedDecl::getOwningModuleFor<wbr>Linkage() const {<br>
> + Module *M = getOwningModule();<br>
> + if (!M)<br>
> + return nullptr;<br>
> +<br>
> + switch (M->Kind) {<br>
> + case Module::ModuleMapModule:<br>
> + // Module map modules have no special linkage semantics.<br>
> + return nullptr;<br>
> +<br>
> + case Module::ModuleInterfaceUnit:<br>
> + return M;<br>
> +<br>
> + case Module::GlobalModuleFragment:<br>
> + // External linkage declarations in the global module have no owning module<br>
> + // for linkage purposes. But internal linkage declarations in the global<br>
> + // module fragment of a particular module are owned by that module for<br>
> + // linkage purposes.<br>
> + return hasExternalFormalLinkage() ? nullptr : M->Parent;<br>
> + }<br>
> +<br>
> + llvm_unreachable("unknown module kind");<br>
> +}<br>
> +<br>
> void NamedDecl::printName(raw_ostre<wbr>am &os) const {<br>
> os << Name;<br>
> }<br>
><br>
> Modified: cfe/trunk/lib/AST/ItaniumMangl<wbr>e.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ItaniumMangle.cpp?rev=312467&r1=312466&r2=312467&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/lib/AST/Itaniu<wbr>mMangle.cpp?rev=312467&r1=<wbr>312466&r2=312467&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- cfe/trunk/lib/AST/ItaniumMangl<wbr>e.cpp (original)<br>
> +++ cfe/trunk/lib/AST/ItaniumMangl<wbr>e.cpp Sun Sep 3 22:37:53 2017<br>
> @@ -381,6 +381,7 @@ class CXXNameMangler {<br>
> AbiTagState AbiTagsRoot;<br>
><br>
> llvm::DenseMap<uintptr_t, unsigned> Substitutions;<br>
> + llvm::DenseMap<StringRef, unsigned> ModuleSubstitutions;<br>
><br>
> ASTContext &getASTContext() const { return Context.getASTContext(); }<br>
><br>
> @@ -475,6 +476,8 @@ private:<br>
><br>
> void mangleNameWithAbiTags(const NamedDecl *ND,<br>
> const AbiTagList *AdditionalAbiTags);<br>
> + void mangleModuleName(const Module *M);<br>
> + void mangleModuleNamePrefix(StringR<wbr>ef Name);<br>
> void mangleTemplateName(const TemplateDecl *TD,<br>
> const TemplateArgument *TemplateArgs,<br>
> unsigned NumTemplateArgs);<br>
> @@ -845,9 +848,9 @@ void CXXNameMangler::mangleName(con<wbr>st Na<br>
><br>
> void CXXNameMangler::mangleNameWith<wbr>AbiTags(const NamedDecl *ND,<br>
> const AbiTagList *AdditionalAbiTags) {<br>
> - // <name> ::= <nested-name><br>
> - // ::= <unscoped-name><br>
> - // ::= <unscoped-template-name> <template-args><br>
> + // <name> ::= [<module-name>] <nested-name><br>
> + // ::= [<module-name>] <unscoped-name><br>
> + // ::= [<module-name>] <unscoped-template-name> <template-args><br>
> // ::= <local-name><br>
> //<br>
> const DeclContext *DC = getEffectiveDeclContext(ND);<br>
> @@ -866,6 +869,19 @@ void CXXNameMangler::mangleNameWith<wbr>AbiTa<br>
><br>
> DC = IgnoreLinkageSpecDecls(DC);<br>
><br>
> + if (isLocalContainerContext(DC)) {<br>
> + mangleLocalName(ND, AdditionalAbiTags);<br>
> + return;<br>
> + }<br>
> +<br>
> + // Do not mangle the owning module for an external linkage declaration.<br>
> + // This enables backwards-compatibility with non-modular code, and is<br>
> + // a valid choice since conflicts are not permitted by C++ Modules TS<br>
> + // [basic.def.odr]/6.2.<br>
> + if (!ND->hasExternalFormalLinkage<wbr>())<br>
> + if (Module *M = ND->getOwningModuleForLinkage(<wbr>))<br>
> + mangleModuleName(M);<br>
> +<br>
> if (DC->isTranslationUnit() || isStdNamespace(DC)) {<br>
> // Check if we have a template.<br>
> const TemplateArgumentList *TemplateArgs = nullptr;<br>
> @@ -879,12 +895,42 @@ void CXXNameMangler::mangleNameWith<wbr>AbiTa<br>
> return;<br>
> }<br>
><br>
> - if (isLocalContainerContext(DC)) {<br>
> - mangleLocalName(ND, AdditionalAbiTags);<br>
> + mangleNestedName(ND, DC, AdditionalAbiTags);<br>
> +}<br>
> +<br>
> +void CXXNameMangler::mangleModuleNa<wbr>me(const Module *M) {<br>
> + // Implement the C++ Modules TS name mangling proposal; see<br>
> + // <a href="https://gcc.gnu.org/wiki/cxx-modules?action=AttachFile" rel="noreferrer" target="_blank">https://gcc.gnu.org/wiki/cxx-<wbr>modules?action=AttachFile</a><br>
> + //<br>
> + // <module-name> ::= W <unscoped-name>+ E<br>
> + // ::= W <module-subst> <unscoped-name>* E<br>
> + Out << 'W';<br>
> + mangleModuleNamePrefix(M->Name<wbr>);<br>
> + Out << 'E';<br>
> +}<br>
> +<br>
> +void CXXNameMangler::mangleModuleNa<wbr>mePrefix(StringRef Name) {<br>
> + // <module-subst> ::= _ <seq-id> # 0 < seq-id < 10<br>
> + // ::= W <seq-id - 10> _ # otherwise<br>
> + auto It = ModuleSubstitutions.find(Name)<wbr>;<br>
> + if (It != ModuleSubstitutions.end()) {<br>
> + if (It->second < 10)<br>
> + Out << '_' << static_cast<char>('0' + It->second);<br>
> + else<br>
> + Out << 'W' << (It->second - 10) << '_';<br>
> return;<br>
> }<br>
><br>
> - mangleNestedName(ND, DC, AdditionalAbiTags);<br>
> + // FIXME: Preserve hierarchy in module names rather than flattening<br>
> + // them to strings; use Module*s as substitution keys.<br>
> + auto Parts = Name.rsplit('.');<br>
> + if (Parts.second.empty())<br>
> + Parts.second = Parts.first;<br>
> + else<br>
> + mangleModuleNamePrefix(Parts.f<wbr>irst);<br>
> +<br>
> + Out << Parts.second.size() << Parts.second;<br>
> + ModuleSubstitutions.insert({Na<wbr>me, ModuleSubstitutions.size()});<br>
> }<br>
><br>
> void CXXNameMangler::mangleTemplate<wbr>Name(const TemplateDecl *TD,<br>
> @@ -1233,13 +1279,16 @@ void CXXNameMangler::mangleUnqualif<wbr>iedNa<br>
> }<br>
><br>
> if (II) {<br>
> - // We must avoid conflicts between internally- and externally-<br>
> - // linked variable and function declaration names in the same TU:<br>
> + // Match GCC's naming convention for internal linkage symbols, for<br>
> + // symbols that are not actually visible outside of this TU. GCC<br>
> + // distinguishes between internal and external linkage symbols in<br>
> + // its mangling, to support cases like this that were valid C++ prior<br>
> + // to DR426:<br>
> + //<br>
> // void test() { extern void foo(); }<br>
> // static void foo();<br>
> - // This naming convention is the same as that followed by GCC,<br>
> - // though it shouldn't actually matter.<br>
> if (ND && ND->getFormalLinkage() == InternalLinkage &&<br>
> + !ND->isExternallyVisible() &&<br>
> getEffectiveDeclContext(ND)->i<wbr>sFileContext())<br>
> Out << 'L';<br>
><br>
><br>
> Modified: cfe/trunk/lib/Lex/ModuleMap.cp<wbr>p<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/ModuleMap.cpp?rev=312467&r1=312466&r2=312467&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/lib/Lex/Module<wbr>Map.cpp?rev=312467&r1=312466&<wbr>r2=312467&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- cfe/trunk/lib/Lex/ModuleMap.cp<wbr>p (original)<br>
> +++ cfe/trunk/lib/Lex/ModuleMap.cp<wbr>p Sun Sep 3 22:37:53 2017<br>
> @@ -746,8 +746,16 @@ std::pair<Module *, bool> ModuleMap::fin<br>
> return std::make_pair(Result, true);<br>
> }<br>
><br>
> +Module *ModuleMap::createGlobalModule<wbr>ForInterfaceUnit(<wbr>SourceLocation Loc) {<br>
> + auto *Result = new Module("<global>", Loc, nullptr, /*IsFramework*/ false,<br>
> + /*IsExplicit*/ true, NumCreatedModules++);<br>
> + Result->Kind = Module::GlobalModuleFragment;<br>
> + return Result;<br>
> +}<br>
> +<br>
> Module *ModuleMap::createModuleForInt<wbr>erfaceUnit(SourceLocation Loc,<br>
> - StringRef Name) {<br>
> + StringRef Name,<br>
> + Module *GlobalModule) {<br>
> assert(LangOpts.CurrentModule == Name && "module name mismatch");<br>
> assert(!Modules[Name] && "redefining existing module");<br>
><br>
> @@ -757,6 +765,9 @@ Module *ModuleMap::createModuleForInt<wbr>erf<br>
> Result->Kind = Module::ModuleInterfaceUnit;<br>
> Modules[Name] = SourceModule = Result;<br>
><br>
> + // Reparent the current global module fragment as a submodule of this module.<br>
> + GlobalModule->setParent(Result<wbr>);<br>
> +<br>
> // Mark the main source file as being within the newly-created module so that<br>
> // declarations and macros are properly visibility-restricted to it.<br>
> auto *MainFile = SourceMgr.getFileEntryForID(So<wbr>urceMgr.getMainFileID());<br>
><br>
> Modified: cfe/trunk/lib/Sema/Sema.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=312467&r1=312466&r2=312467&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/lib/Sema/Sema.<wbr>cpp?rev=312467&r1=312466&r2=<wbr>312467&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- cfe/trunk/lib/Sema/Sema.cpp (original)<br>
> +++ cfe/trunk/lib/Sema/Sema.cpp Sun Sep 3 22:37:53 2017<br>
> @@ -766,10 +766,24 @@ void Sema::emitAndClearUnusedLocalT<wbr>ypede<br>
> /// declarations.<br>
> void Sema::ActOnStartOfTranslationU<wbr>nit() {<br>
> if (getLangOpts().ModulesTS) {<br>
> + SourceLocation StartOfTU =<br>
> + SourceMgr.getLocForStartOfFile<wbr>(SourceMgr.getMainFileID());<br>
> +<br>
> // We start in the global module; all those declarations are implicitly<br>
> // module-private (though they do not have module linkage).<br>
> - Context.getTranslationUnitDecl<wbr>()->setModuleOwnershipKind(<br>
> - Decl::ModuleOwnershipKind::Mod<wbr>ulePrivate);<br>
> + auto &Map = PP.getHeaderSearchInfo().getMo<wbr>duleMap();<br>
> + auto *GlobalModule = Map.createGlobalModuleForInter<wbr>faceUnit(StartOfTU);<br>
> + assert(GlobalModule && "module creation should not fail");<br>
> +<br>
> + // Enter the scope of the global module.<br>
> + ModuleScopes.push_back({});<br>
> + ModuleScopes.back().Module = GlobalModule;<br>
> + VisibleModules.setVisible(Glob<wbr>alModule, StartOfTU);<br>
> +<br>
> + // All declarations created from now on are owned by the global module.<br>
> + auto *TU = Context.getTranslationUnitDecl<wbr>();<br>
> + TU->setModuleOwnershipKind(Dec<wbr>l::ModuleOwnershipKind::Visibl<wbr>e);<br>
> + TU->setLocalOwningModule(Globa<wbr>lModule);<br>
> }<br>
> }<br>
><br>
><br>
> Modified: cfe/trunk/lib/Sema/SemaDecl.cp<wbr>p<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=312467&r1=312466&r2=312467&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/lib/Sema/SemaD<wbr>ecl.cpp?rev=312467&r1=312466&<wbr>r2=312467&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- cfe/trunk/lib/Sema/SemaDecl.cp<wbr>p (original)<br>
> +++ cfe/trunk/lib/Sema/SemaDecl.cp<wbr>p Sun Sep 3 22:37:53 2017<br>
> @@ -16052,6 +16052,9 @@ Sema::DeclGroupPtrTy Sema::ActOnModuleDe<br>
> SourceLocation ModuleLoc,<br>
> ModuleDeclKind MDK,<br>
> ModuleIdPath Path) {<br>
> + assert(getLangOpts().ModulesTS &&<br>
> + "should only have module decl in modules TS");<br>
> +<br>
> // A module implementation unit requires that we are not compiling a module<br>
> // of any kind. A module interface unit requires that we are not compiling a<br>
> // module map.<br>
> @@ -16104,10 +16107,10 @@ Sema::DeclGroupPtrTy Sema::ActOnModuleDe<br>
> auto &Map = PP.getHeaderSearchInfo().getMo<wbr>duleMap();<br>
> Module *Mod;<br>
><br>
> + assert(ModuleScopes.size() == 1 && "expected to be at global module scope");<br>
> +<br>
> switch (MDK) {<br>
> case ModuleDeclKind::Module: {<br>
> - // FIXME: Check we're not in a submodule.<br>
> -<br>
> // We can't have parsed or imported a definition of this module or parsed a<br>
> // module map defining it already.<br>
> if (auto *M = Map.findModule(ModuleName)) {<br>
> @@ -16121,7 +16124,8 @@ Sema::DeclGroupPtrTy Sema::ActOnModuleDe<br>
> }<br>
><br>
> // Create a Module for the module that we're defining.<br>
> - Mod = Map.createModuleForInterfaceUn<wbr>it(ModuleLoc, ModuleName);<br>
> + Mod = Map.createModuleForInterfaceUn<wbr>it(ModuleLoc, ModuleName,<br>
> + ModuleScopes.front().Module);<br>
> assert(Mod && "module creation should not fail");<br>
> break;<br>
> }<br>
> @@ -16140,16 +16144,16 @@ Sema::DeclGroupPtrTy Sema::ActOnModuleDe<br>
> break;<br>
> }<br>
><br>
> - // Enter the semantic scope of the module.<br>
> - ModuleScopes.push_back({});<br>
> + // Switch from the global module to the named module.<br>
> ModuleScopes.back().Module = Mod;<br>
> - ModuleScopes.back().OuterVisib<wbr>leModules = std::move(VisibleModules);<br>
> VisibleModules.setVisible(Mod, ModuleLoc);<br>
><br>
> // From now on, we have an owning module for all declarations we see.<br>
> // However, those declarations are module-private unless explicitly<br>
> // exported.<br>
> - Context.getTranslationUnitDecl<wbr>()->setLocalOwningModule(Mod);<br>
> + auto *TU = Context.getTranslationUnitDecl<wbr>();<br>
> + TU->setModuleOwnershipKind(Dec<wbr>l::ModuleOwnershipKind::Module<wbr>Private);<br>
> + TU->setLocalOwningModule(Mod);<br>
><br>
> // FIXME: Create a ModuleDecl.<br>
> return nullptr;<br>
> @@ -16327,7 +16331,7 @@ Decl *Sema::ActOnStartExportDecl(Sc<wbr>ope *<br>
> // C++ Modules TS draft:<br>
> // An export-declaration shall appear in the purview of a module other than<br>
> // the global module.<br>
> - if (ModuleScopes.empty() || !ModuleScopes.back().Module ||<br>
> + if (ModuleScopes.empty() ||<br>
> ModuleScopes.back().Module->Ki<wbr>nd != Module::ModuleInterfaceUnit)<br>
> Diag(ExportLoc, diag::err_export_not_in_module<wbr>_interface);<br>
><br>
><br>
> Modified: cfe/trunk/lib/Serialization/AS<wbr>TReader.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=312467&r1=312466&r2=312467&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/lib/Serializat<wbr>ion/ASTReader.cpp?rev=312467&<wbr>r1=312466&r2=312467&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- cfe/trunk/lib/Serialization/AS<wbr>TReader.cpp (original)<br>
> +++ cfe/trunk/lib/Serialization/AS<wbr>TReader.cpp Sun Sep 3 22:37:53 2017<br>
> @@ -4871,7 +4871,6 @@ ASTReader::ReadSubmoduleBlock(<wbr>ModuleFile<br>
> ModuleMap &ModMap = PP.getHeaderSearchInfo().getMo<wbr>duleMap();<br>
> bool First = true;<br>
> Module *CurrentModule = nullptr;<br>
> - Module::ModuleKind ModuleKind = Module::ModuleMapModule;<br>
> RecordData Record;<br>
> while (true) {<br>
> llvm::BitstreamEntry Entry = F.Stream.advanceSkippingSubblo<wbr>cks();<br>
> @@ -4919,6 +4918,7 @@ ASTReader::ReadSubmoduleBlock(<wbr>ModuleFile<br>
> unsigned Idx = 0;<br>
> SubmoduleID GlobalID = getGlobalSubmoduleID(F, Record[Idx++]);<br>
> SubmoduleID Parent = getGlobalSubmoduleID(F, Record[Idx++]);<br>
> + Module::ModuleKind Kind = (Module::ModuleKind)Record[Idx<wbr>++];<br>
> bool IsFramework = Record[Idx++];<br>
> bool IsExplicit = Record[Idx++];<br>
> bool IsSystem = Record[Idx++];<br>
> @@ -4965,7 +4965,7 @@ ASTReader::ReadSubmoduleBlock(<wbr>ModuleFile<br>
> CurrentModule->PresumedModuleM<wbr>apFile = F.ModuleMapPath;<br>
> }<br>
><br>
> - CurrentModule->Kind = ModuleKind;<br>
> + CurrentModule->Kind = Kind;<br>
> CurrentModule->Signature = F.Signature;<br>
> CurrentModule->IsFromModuleFil<wbr>e = true;<br>
> CurrentModule->IsSystem = IsSystem || CurrentModule->IsSystem;<br>
> @@ -5064,7 +5064,6 @@ ASTReader::ReadSubmoduleBlock(<wbr>ModuleFile<br>
><br>
> SubmodulesLoaded.resize(Submod<wbr>ulesLoaded.size() + F.LocalNumSubmodules);<br>
> }<br>
> - ModuleKind = (Module::ModuleKind)Record[2];<br>
> break;<br>
> }<br>
><br>
><br>
> Modified: cfe/trunk/lib/Serialization/AS<wbr>TWriter.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=312467&r1=312466&r2=312467&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/lib/Serializat<wbr>ion/ASTWriter.cpp?rev=312467&<wbr>r1=312466&r2=312467&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- cfe/trunk/lib/Serialization/AS<wbr>TWriter.cpp (original)<br>
> +++ cfe/trunk/lib/Serialization/AS<wbr>TWriter.cpp Sun Sep 3 22:37:53 2017<br>
> @@ -2716,6 +2716,7 @@ void ASTWriter::WriteSubmodules(Mod<wbr>ule *<br>
> Abbrev->Add(BitCodeAbbrevOp(SU<wbr>BMODULE_DEFINITION));<br>
> Abbrev->Add(BitCodeAbbrevOp(Bi<wbr>tCodeAbbrevOp::VBR, 6)); // ID<br>
> Abbrev->Add(BitCodeAbbrevOp(Bi<wbr>tCodeAbbrevOp::VBR, 6)); // Parent<br>
> + Abbrev->Add(BitCodeAbbrevOp(Bi<wbr>tCodeAbbrevOp::Fixed, 2)); // Kind<br>
> Abbrev->Add(BitCodeAbbrevOp(Bi<wbr>tCodeAbbrevOp::Fixed, 1)); // IsFramework<br>
> Abbrev->Add(BitCodeAbbrevOp(Bi<wbr>tCodeAbbrevOp::Fixed, 1)); // IsExplicit<br>
> Abbrev->Add(BitCodeAbbrevOp(Bi<wbr>tCodeAbbrevOp::Fixed, 1)); // IsSystem<br>
> @@ -2793,8 +2794,7 @@ void ASTWriter::WriteSubmodules(Mod<wbr>ule *<br>
> // Write the submodule metadata block.<br>
> RecordData::value_type Record[] = {<br>
> getNumberOfModules(WritingModu<wbr>le),<br>
> - FirstSubmoduleID - NUM_PREDEF_SUBMODULE_IDS,<br>
> - (unsigned)WritingModule->Kind}<wbr>;<br>
> + FirstSubmoduleID - NUM_PREDEF_SUBMODULE_IDS};<br>
> Stream.EmitRecord(SUBMODULE_ME<wbr>TADATA, Record);<br>
><br>
> // Write all of the submodules.<br>
> @@ -2816,6 +2816,7 @@ void ASTWriter::WriteSubmodules(Mod<wbr>ule *<br>
> RecordData::value_type Record[] = {SUBMODULE_DEFINITION,<br>
> ID,<br>
> ParentID,<br>
> + Mod->Kind,<br>
> Mod->IsFramework,<br>
> Mod->IsExplicit,<br>
> Mod->IsSystem,<br>
><br>
> Modified: cfe/trunk/test/CXX/modules-ts/<wbr>basic/basic.def.odr/p4/module.<wbr>cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cpp?rev=312467&r1=312466&r2=312467&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/test/CXX/modul<wbr>es-ts/basic/basic.def.odr/p4/<wbr>module.cpp?rev=312467&r1=<wbr>312466&r2=312467&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- cfe/trunk/test/CXX/modules-ts/<wbr>basic/basic.def.odr/p4/module.<wbr>cpp (original)<br>
> +++ cfe/trunk/test/CXX/modules-ts/<wbr>basic/basic.def.odr/p4/module.<wbr>cpp Sun Sep 3 22:37:53 2017<br>
> @@ -4,15 +4,15 @@<br>
> // CHECK-DAG: @extern_var_exported = external global<br>
> // FIXME: Should this be 'external global'?<br>
> // CHECK-DAG: @inline_var_exported = linkonce_odr global<br>
> -// CHECK-DAG: @_ZL19static_var_exported = external global<br>
> +// CHECK-DAG: @_ZW6ModuleE19static_var_expor<wbr>ted = external global<br>
> // CHECK-DAG: @const_var_exported = external constant<br>
> //<br>
> // FIXME: The module name should be mangled into all of these.<br>
> // CHECK-DAG: @extern_var_module_linkage = external global<br>
> // FIXME: Should this be 'external global'?<br>
> // CHECK-DAG: @inline_var_module_linkage = linkonce_odr global<br>
> -// CHECK-DAG: @_ZL25static_var_module_linkag<wbr>e = external global<br>
> -// CHECK-DAG: @_ZL24const_var_module_linkage = external constant<br>
> +// CHECK-DAG: @_ZW6ModuleE25static_var_modul<wbr>e_linkage = external global<br>
> +// CHECK-DAG: @_ZW6ModuleE24const_var_module<wbr>_linkage = external constant<br>
><br>
> module Module;<br>
><br>
> @@ -28,15 +28,13 @@ void use() {<br>
> (void)&const_var_exported;<br>
><br>
> // FIXME: This symbol should not be visible here.<br>
> - // CHECK: declare {{.*}}@_ZL26used_static_module<wbr>_linkagev<br>
> + // CHECK: declare {{.*}}@_ZW6ModuleE26used_stati<wbr>c_module_linkagev<br>
> used_static_module_linkage();<br>
><br>
> - // FIXME: The module name should be mangled into the name of this function.<br>
> - // CHECK: define linkonce_odr {{.*}}@_Z26used_inline_module_<wbr>linkagev<br>
> + // CHECK: define linkonce_odr {{.*}}@_ZW6ModuleE26used_inlin<wbr>e_module_linkagev<br>
> used_inline_module_linkage();<br>
><br>
> - // FIXME: The module name should be mangled into the name of this function.<br>
> - // CHECK: declare {{.*}}@_Z24noninline_module_li<wbr>nkagev<br>
> + // CHECK: declare {{.*}}@_ZW6ModuleE24noninline_<wbr>module_linkagev<br>
> noninline_module_linkage();<br>
><br>
> (void)&extern_var_module_linka<wbr>ge;<br>
><br>
> Modified: cfe/trunk/test/CXX/modules-ts/<wbr>basic/basic.def.odr/p4/module.<wbr>cppm<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cppm?rev=312467&r1=312466&r2=312467&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/test/CXX/modul<wbr>es-ts/basic/basic.def.odr/p4/<wbr>module.cppm?rev=312467&r1=<wbr>312466&r2=312467&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- cfe/trunk/test/CXX/modules-ts/<wbr>basic/basic.def.odr/p4/module.<wbr>cppm (original)<br>
> +++ cfe/trunk/test/CXX/modules-ts/<wbr>basic/basic.def.odr/p4/module.<wbr>cppm Sun Sep 3 22:37:53 2017<br>
> @@ -11,7 +11,7 @@<br>
> // can discard this global and its initializer (if any), and other TUs are not<br>
> // permitted to run the initializer for this variable.<br>
> // CHECK-DAG: @inline_var_exported = linkonce_odr global<br>
> -// CHECK-DAG: @_ZL19static_var_exported = global<br>
> +// CHECK-DAG: @_ZW6ModuleE19static_var_expor<wbr>ted = global<br>
> // CHECK-DAG: @const_var_exported = constant<br>
> //<br>
> // FIXME: The module name should be mangled into all of these.<br>
> @@ -20,8 +20,8 @@<br>
> // can discard this global and its initializer (if any), and other TUs are not<br>
> // permitted to run the initializer for this variable.<br>
> // CHECK-DAG: @inline_var_module_linkage = linkonce_odr global<br>
> -// CHECK-DAG: @_ZL25static_var_module_linkag<wbr>e = global<br>
> -// CHECK-DAG: @_ZL24const_var_module_linkage = constant<br>
> +// CHECK-DAG: @_ZW6ModuleE25static_var_modul<wbr>e_linkage = global<br>
> +// CHECK-DAG: @_ZW6ModuleE24const_var_module<wbr>_linkage = constant<br>
><br>
> static void unused_static_global_module() {}<br>
> static void used_static_global_module() {}<br>
> @@ -57,9 +57,9 @@ export module Module;<br>
> export {<br>
> // FIXME: These should be ill-formed: you can't export an internal linkage<br>
> // symbol, per [dcl.module.interface]p2.<br>
> - // CHECK: define void {{.*}}@_ZL22unused_static_expo<wbr>rtedv<br>
> + // CHECK: define void {{.*}}@_ZW6ModuleE22unused_sta<wbr>tic_exportedv<br>
> static void unused_static_exported() {}<br>
> - // CHECK: define void {{.*}}@_ZL20used_static_export<wbr>edv<br>
> + // CHECK: define void {{.*}}@_ZW6ModuleE20used_stati<wbr>c_exportedv<br>
> static void used_static_exported() {}<br>
><br>
> inline void unused_inline_exported() {}<br>
> @@ -88,11 +88,9 @@ export {<br>
> // FIXME: Ideally we wouldn't emit this as its name is not visible outside this<br>
> // TU, but this module interface might contain a template that can use this<br>
> // function so we conservatively emit it for now.<br>
> -// FIXME: The module name should be mangled into the name of this function.<br>
> -// CHECK: define void {{.*}}@_ZL28unused_static_modu<wbr>le_linkagev<br>
> +// CHECK: define void {{.*}}@_ZW6ModuleE28unused_sta<wbr>tic_module_linkagev<br>
> static void unused_static_module_linkage() {}<br>
> -// FIXME: The module name should be mangled into the name of this function.<br>
> -// CHECK: define void {{.*}}@_ZL26used_static_module<wbr>_linkagev<br>
> +// CHECK: define void {{.*}}@_ZW6ModuleE26used_stati<wbr>c_module_linkagev<br>
> static void used_static_module_linkage() {}<br>
><br>
> inline void unused_inline_module_linkage() {}<br>
> @@ -103,12 +101,10 @@ inline int inline_var_module_linkage;<br>
> static int static_var_module_linkage;<br>
> const int const_var_module_linkage = 3;<br>
><br>
> -// FIXME: The module name should be mangled into the name of this function.<br>
> -// CHECK: define void {{.*}}@_Z24noninline_module_li<wbr>nkagev<br>
> +// CHECK: define void {{.*}}@_ZW6ModuleE24noninline_<wbr>module_linkagev<br>
> void noninline_module_linkage() {<br>
> used_static_module_linkage();<br>
> - // FIXME: The module name should be mangled into the name of this function.<br>
> - // CHECK: define linkonce_odr {{.*}}@_Z26used_inline_module_<wbr>linkagev<br>
> + // CHECK: define linkonce_odr {{.*}}@_ZW6ModuleE26used_inlin<wbr>e_module_linkagev<br>
> used_inline_module_linkage();<br>
><br>
> (void)&extern_var_module_linka<wbr>ge;<br>
> @@ -116,3 +112,10 @@ void noninline_module_linkage() {<br>
> (void)&static_var_module_linka<wbr>ge;<br>
> (void)&const_var_module_linkag<wbr>e;<br>
> }<br>
> +<br>
> +struct a {<br>
> + struct b {};<br>
> + struct c {};<br>
> +};<br>
> +// CHECK: define void @_ZW6ModuleE1fW_0EN1a1bEW_0ENS<wbr>_1cE(<br>
> +void f(a::b, a::c) {}<br>
><br>
> Modified: cfe/trunk/test/CXX/modules-ts/<wbr>basic/basic.def.odr/p4/user.cp<wbr>p<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p4/user.cpp?rev=312467&r1=312466&r2=312467&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/test/CXX/modul<wbr>es-ts/basic/basic.def.odr/p4/<wbr>user.cpp?rev=312467&r1=312466&<wbr>r2=312467&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- cfe/trunk/test/CXX/modules-ts/<wbr>basic/basic.def.odr/p4/user.cp<wbr>p (original)<br>
> +++ cfe/trunk/test/CXX/modules-ts/<wbr>basic/basic.def.odr/p4/user.cp<wbr>p Sun Sep 3 22:37:53 2017<br>
> @@ -5,7 +5,7 @@<br>
> // FIXME: Should this be 'external global'?<br>
> // CHECK-DAG: @inline_var_exported = linkonce_odr global<br>
> // FIXME: These should be 'extern global' and 'extern constant'.<br>
> -// CHECK-DAG: @_ZL19static_var_exported = global<br>
> +// CHECK-DAG: @_ZW6ModuleE19static_var_expor<wbr>ted = global<br>
> // CHECK-DAG: @const_var_exported = constant<br>
><br>
> import Module;<br>
><br>
> Modified: cfe/trunk/test/CXX/modules-ts/<wbr>codegen-basics.cppm<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/modules-ts/codegen-basics.cppm?rev=312467&r1=312466&r2=312467&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/test/CXX/modul<wbr>es-ts/codegen-basics.cppm?rev=<wbr>312467&r1=312466&r2=312467&<wbr>view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- cfe/trunk/test/CXX/modules-ts/<wbr>codegen-basics.cppm (original)<br>
> +++ cfe/trunk/test/CXX/modules-ts/<wbr>codegen-basics.cppm Sun Sep 3 22:37:53 2017<br>
> @@ -4,20 +4,18 @@<br>
> export module FooBar;<br>
><br>
> export {<br>
> - // CHECK-LABEL: define i32 @_Z1fv(<br>
> + // CHECK-DAG: define i32 @_Z1fv(<br>
> int f() { return 0; }<br>
> }<br>
><br>
> -// CHECK-LABEL: define weak_odr void @_Z2f2v(<br>
> +// CHECK-DAG: define weak_odr void @_ZW6FooBarE2f2v(<br>
> inline void f2() { }<br>
><br>
> -// FIXME: Emit global variables and their initializers with this TU.<br>
> -// Emit an initialization function that other TUs can call, with guard variable.<br>
> -<br>
> -// FIXME: Mangle non-exported symbols so they don't collide with<br>
> -// non-exported symbols from other modules?<br>
> +// CHECK-DAG: define void @_ZW6FooBarE2f3v(<br>
> +static void f3() {}<br>
> +export void use_f3() { f3(); }<br>
><br>
> -// FIXME: Formally-internal-linkage symbols that are used from an exported<br>
> -// symbol need a mangled name and external linkage.<br>
> +// FIXME: Emit global variables and their initializers with this TU.<br>
> +// Emit an initialization function that other TUs can call, with guard variable?<br>
><br>
> // FIXME: const-qualified variables don't have implicit internal linkage when owned by a module.<br>
><br>
> Modified: cfe/trunk/test/SemaCXX/modules<wbr>-ts.cppm<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/modules-ts.cppm?rev=312467&r1=312466&r2=312467&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/test/SemaCXX/<wbr>modules-ts.cppm?rev=312467&r1=<wbr>312466&r2=312467&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- cfe/trunk/test/SemaCXX/modules<wbr>-ts.cppm (original)<br>
> +++ cfe/trunk/test/SemaCXX/modules<wbr>-ts.cppm Sun Sep 3 22:37:53 2017<br>
> @@ -1,7 +1,7 @@<br>
> -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface %s -o %t.pcm -verify -DTEST=0<br>
> -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface %s -o %t.pcm -verify -DTEST=1<br>
> -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface %s -fmodule-file=%t.pcm -o %t.pcm -verify -DTEST=2<br>
> -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface %s -fmodule-file=%t.pcm -o %t.pcm -verify -Dfoo=bar -DTEST=3<br>
> +// RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface %s -o %t.0.pcm -verify -DTEST=0<br>
> +// RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface %s -o %t.1.pcm -verify -DTEST=1<br>
> +// RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface %s -fmodule-file=%t.0.pcm -o %t.2.pcm -verify -DTEST=2<br>
> +// RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface %s -fmodule-file=%t.0.pcm -o %t.3.pcm -verify -Dfoo=bar -DTEST=3<br>
><br>
> #if TEST == 0<br>
> // expected-no-diagnostics<br>
> @@ -21,7 +21,7 @@ static int m;<br>
> // expected-note-re@modules-ts.cp<wbr>pm:1 {{'{{.*}}modules-ts.cppm' included multiple times, additional include site in header from module 'foo'}}<br>
> #endif<br>
> int n;<br>
> -#if TEST >= 2<br>
> +#if TEST == 2<br>
> // expected-error@-2 {{redefinition of '}}<br>
> // expected-note@-3 {{unguarded header; consider using #ifdef guards or #pragma once}}<br>
> // FIXME: We should drop the "header from" in this diagnostic.<br>
> @@ -60,7 +60,7 @@ int use_b = b;<br>
> int use_n = n; // FIXME: this should not be visible, because it is not exported<br>
><br>
> extern int n;<br>
> -static_assert(&n == p); // FIXME: these are not the same entity<br>
> +static_assert(&n != p);<br>
> #endif<br>
><br>
><br>
><br>
><br>
> ______________________________<wbr>_________________<br>
> cfe-commits mailing list<br>
> <a href="mailto:cfe-commits@lists.llvm.org" target="_blank">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>
______________________________<wbr>_________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">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>
</div></div></blockquote></div><br></div>