summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse/Parser.cpp
diff options
context:
space:
mode:
authorHamza Sood <hamza_sood@me.com>2017-11-21 09:42:42 +0000
committerHamza Sood <hamza_sood@me.com>2017-11-21 09:42:42 +0000
commit81fe14e4c32c76de0f4e5d670eedbfc6bccab75c (patch)
tree1d6c6157f07e1bee64b10ca0f93dfbb6a80f9750 /clang/lib/Parse/Parser.cpp
parent519ea284af84f77fea8ffdc9d9041b91ba8b49ee (diff)
downloadbcm5719-llvm-81fe14e4c32c76de0f4e5d670eedbfc6bccab75c.tar.gz
bcm5719-llvm-81fe14e4c32c76de0f4e5d670eedbfc6bccab75c.zip
[Modules TS] Added module re-export support.
This implements [dcl.modules.export] from the C++ Modules TS, which lets a module re-export another module with the "export import" syntax. Differential Revision: https://reviews.llvm.org/D40270 llvm-svn: 318744
Diffstat (limited to 'clang/lib/Parse/Parser.cpp')
-rw-r--r--clang/lib/Parse/Parser.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp
index 0b07ba1888b..72d653797c6 100644
--- a/clang/lib/Parse/Parser.cpp
+++ b/clang/lib/Parse/Parser.cpp
@@ -556,10 +556,6 @@ bool Parser::ParseTopLevelDecl(DeclGroupPtrTy &Result) {
HandlePragmaUnused();
return false;
- case tok::kw_import:
- Result = ParseModuleImport(SourceLocation());
- return false;
-
case tok::kw_export:
if (NextToken().isNot(tok::kw_module))
break;
@@ -637,6 +633,9 @@ bool Parser::ParseTopLevelDecl(DeclGroupPtrTy &Result) {
/// ';'
///
/// [C++0x/GNU] 'extern' 'template' declaration
+///
+/// [Modules-TS] module-import-declaration
+///
Parser::DeclGroupPtrTy
Parser::ParseExternalDeclaration(ParsedAttributesWithRange &attrs,
ParsingDeclSpec *DS) {
@@ -764,6 +763,9 @@ Parser::ParseExternalDeclaration(ParsedAttributesWithRange &attrs,
CurParsedObjCImpl ? Sema::PCC_ObjCImplementation : Sema::PCC_Namespace);
cutOffParsing();
return nullptr;
+ case tok::kw_import:
+ SingleDecl = ParseModuleImport(SourceLocation());
+ break;
case tok::kw_export:
if (getLangOpts().ModulesTS) {
SingleDecl = ParseExportDeclaration();
@@ -2092,7 +2094,7 @@ Parser::DeclGroupPtrTy Parser::ParseModuleDecl() {
/// '@' 'import' module-name ';'
/// [ModTS] module-import-declaration:
/// 'import' module-name attribute-specifier-seq[opt] ';'
-Parser::DeclGroupPtrTy Parser::ParseModuleImport(SourceLocation AtLoc) {
+Decl *Parser::ParseModuleImport(SourceLocation AtLoc) {
assert((AtLoc.isInvalid() ? Tok.is(tok::kw_import)
: Tok.isObjCAtKeyword(tok::objc_import)) &&
"Improper start to module import");
@@ -2119,7 +2121,7 @@ Parser::DeclGroupPtrTy Parser::ParseModuleImport(SourceLocation AtLoc) {
if (Import.isInvalid())
return nullptr;
- return Actions.ConvertDeclToDeclGroup(Import.get());
+ return Import.get();
}
/// Parse a C++ Modules TS / Objective-C module name (both forms use the same
OpenPOWER on IntegriCloud