From 69e46036a391a12d2eb3149569c335ce3634bf31 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Fri, 6 Dec 2013 09:25:54 +0000 Subject: Allow string literals as module names. In order to make the migration to modules easier, it seems to be helpful to allow a 1:1 mapping between target names of a current build system and the corresponding C++ modules. As such targets commonly contain characters like "-". ":" and "/", allowing arbitrary quote-escaped strings seems to be a straightforward option. After several offline discussions, the precise mechanisms for C++ module names especially regarding submodules and import statements has yet to be determined. Thus, this patch only enables string literals as names inside the module map files which can be used by automatic module import (through #include). Also improve the error message on missing use-declarations. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196573 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Lex/ModuleMap.cpp | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) (limited to 'lib/Lex/ModuleMap.cpp') diff --git a/lib/Lex/ModuleMap.cpp b/lib/Lex/ModuleMap.cpp index f4dfa12854..3ce0def1d1 100644 --- a/lib/Lex/ModuleMap.cpp +++ b/lib/Lex/ModuleMap.cpp @@ -1066,7 +1066,7 @@ void ModuleMapParser::skipUntil(MMToken::TokenKind K) { bool ModuleMapParser::parseModuleId(ModuleId &Id) { Id.clear(); do { - if (Tok.is(MMToken::Identifier)) { + if (Tok.is(MMToken::Identifier) || Tok.is(MMToken::StringLiteral)) { Id.push_back(std::make_pair(Tok.getString(), Tok.getLocation())); consumeToken(); } else { @@ -1687,25 +1687,7 @@ void ModuleMapParser::parseUseDecl() { consumeToken(); // Parse the module-id. ModuleId ParsedModuleId; - - do { - if (Tok.is(MMToken::Identifier)) { - ParsedModuleId.push_back( - std::make_pair(Tok.getString(), Tok.getLocation())); - consumeToken(); - - if (Tok.is(MMToken::Period)) { - consumeToken(); - continue; - } - - break; - } - - Diags.Report(Tok.getLocation(), diag::err_mmap_module_id); - HadError = true; - return; - } while (true); + parseModuleId(ParsedModuleId); ActiveModule->UnresolvedDirectUses.push_back(ParsedModuleId); } -- cgit v1.2.3