diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-09-04 05:37:53 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-09-04 05:37:53 +0000 |
commit | 5f4efc24c888d4c43af20c2c5a8e028720b8644d (patch) | |
tree | d7817091f553e041c93ba5ed431166062083c682 /lib/Sema/Sema.cpp | |
parent | 7ede89db2c39be7ae220fdb4d1d5c9325a6c776a (diff) | |
download | clang-5f4efc24c888d4c43af20c2c5a8e028720b8644d.tar.gz |
Implement Itanium name mangling support for C++ Modules TS.
This follows the scheme agreed with Nathan Sidwell, which can be found here:
https://gcc.gnu.org/wiki/cxx-modules?action=AttachFile
This will be proposed to the itanium-cxx-abi list once we have some experience
with how well it works; the ABI for this TS should be considered unstable until
it is part of the Itanium C++ ABI.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@312467 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/Sema.cpp')
-rw-r--r-- | lib/Sema/Sema.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp index e99e73fc8d..66cb4976da 100644 --- a/lib/Sema/Sema.cpp +++ b/lib/Sema/Sema.cpp @@ -766,10 +766,24 @@ void Sema::emitAndClearUnusedLocalTypedefWarnings() { /// declarations. void Sema::ActOnStartOfTranslationUnit() { if (getLangOpts().ModulesTS) { + SourceLocation StartOfTU = + SourceMgr.getLocForStartOfFile(SourceMgr.getMainFileID()); + // We start in the global module; all those declarations are implicitly // module-private (though they do not have module linkage). - Context.getTranslationUnitDecl()->setModuleOwnershipKind( - Decl::ModuleOwnershipKind::ModulePrivate); + auto &Map = PP.getHeaderSearchInfo().getModuleMap(); + auto *GlobalModule = Map.createGlobalModuleForInterfaceUnit(StartOfTU); + assert(GlobalModule && "module creation should not fail"); + + // Enter the scope of the global module. + ModuleScopes.push_back({}); + ModuleScopes.back().Module = GlobalModule; + VisibleModules.setVisible(GlobalModule, StartOfTU); + + // All declarations created from now on are owned by the global module. + auto *TU = Context.getTranslationUnitDecl(); + TU->setModuleOwnershipKind(Decl::ModuleOwnershipKind::Visible); + TU->setLocalOwningModule(GlobalModule); } } |