diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2017-08-29 15:30:18 +0000 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2017-08-29 15:30:18 +0000 |
commit | 734d8548ee93d053be45b36b612a737e6e4c61d3 (patch) | |
tree | 66a91905adeeb3d22c512559cc5e9553d9059cb1 /clang/lib/Frontend/CompilerInstance.cpp | |
parent | a54ca1a66232e655d2c0417d57f252bca5fc351b (diff) | |
download | bcm5719-llvm-734d8548ee93d053be45b36b612a737e6e4c61d3.tar.gz bcm5719-llvm-734d8548ee93d053be45b36b612a737e6e4c61d3.zip |
[modules-ts] Omit submodule semantics for TS modules
If a TS module name has more than one component (e.g., foo.bar) then we
erroneously activated the submodule semantics when encountering a module
declaration in the module implementation unit (e.g., 'module foo.bar;').
Reviewed By: rsmith
Differential Revision: https://reviews.llvm.org/D35678
llvm-svn: 312007
Diffstat (limited to 'clang/lib/Frontend/CompilerInstance.cpp')
-rw-r--r-- | clang/lib/Frontend/CompilerInstance.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp index 740dabea45a..84d837d4883 100644 --- a/clang/lib/Frontend/CompilerInstance.cpp +++ b/clang/lib/Frontend/CompilerInstance.cpp @@ -1601,7 +1601,22 @@ CompilerInstance::loadModule(SourceLocation ImportLoc, Module::NameVisibilityKind Visibility, bool IsInclusionDirective) { // Determine what file we're searching from. - StringRef ModuleName = Path[0].first->getName(); + // FIXME: Should we be deciding whether this is a submodule (here and + // below) based on -fmodules-ts or should we pass a flag and make the + // caller decide? + std::string ModuleName; + if (getLangOpts().ModulesTS) { + // FIXME: Same code as Sema::ActOnModuleDecl() so there is probably a + // better place/way to do this. + for (auto &Piece : Path) { + if (!ModuleName.empty()) + ModuleName += "."; + ModuleName += Piece.first->getName(); + } + } + else + ModuleName = Path[0].first->getName(); + SourceLocation ModuleNameLoc = Path[0].second; // If we've already handled this import, just return the cached result. @@ -1816,7 +1831,7 @@ CompilerInstance::loadModule(SourceLocation ImportLoc, // Verify that the rest of the module path actually corresponds to // a submodule. - if (Path.size() > 1) { + if (!getLangOpts().ModulesTS && Path.size() > 1) { for (unsigned I = 1, N = Path.size(); I != N; ++I) { StringRef Name = Path[I].first->getName(); clang::Module *Sub = Module->findSubmodule(Name); |