summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-12-06 09:25:54 +0000
committerDaniel Jasper <djasper@google.com>2013-12-06 09:25:54 +0000
commit3cd34c7637e8bee4fabd1675f15b4e001f7294b9 (patch)
treee1b6c3ff16ef92a12fdb472ff218f5b1e13077ba /clang/lib
parent67bbf967b03fdcbaa98dce5ca6cd3deced930894 (diff)
downloadbcm5719-llvm-3cd34c7637e8bee4fabd1675f15b4e001f7294b9.tar.gz
bcm5719-llvm-3cd34c7637e8bee4fabd1675f15b4e001f7294b9.zip
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. llvm-svn: 196573
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Lex/ModuleMap.cpp22
-rw-r--r--clang/lib/Lex/PPDirectives.cpp2
2 files changed, 3 insertions, 21 deletions
diff --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp
index f4dfa12854a..3ce0def1d1c 100644
--- a/clang/lib/Lex/ModuleMap.cpp
+++ b/clang/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);
}
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index 7d4c788f660..70c32c3dc69 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -610,7 +610,7 @@ void Preprocessor::verifyModuleInclude(SourceLocation FilenameLoc,
if (RequestingModule && getLangOpts().ModulesDeclUse &&
violatesUseDeclarations(RequestingModule, RequestedModule.getModule()))
Diag(FilenameLoc, diag::error_undeclared_use_of_module)
- << Filename;
+ << RequestingModule->getFullModuleName() << Filename;
}
const FileEntry *Preprocessor::LookupFile(
OpenPOWER on IntegriCloud