diff options
author | Douglas Gregor <dgregor@apple.com> | 2012-01-03 18:04:46 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2012-01-03 18:04:46 +0000 |
commit | 22d0974b40673d2492c5427e4066743223cab696 (patch) | |
tree | c6f73e4f476920769896981552fb01f646313085 /clang/lib/Lex/Preprocessor.cpp | |
parent | e097d4ba268d4a04845d23143672953d9efb6302 (diff) | |
download | llvm-22d0974b40673d2492c5427e4066743223cab696.zip llvm-22d0974b40673d2492c5427e4066743223cab696.tar.gz llvm-22d0974b40673d2492c5427e4066743223cab696.tar.bz2 |
Introduce a non-uglified syntax for module imports in Objective-C:
@import identifier [. identifier]* ;
llvm-svn: 147452
Diffstat (limited to 'clang/lib/Lex/Preprocessor.cpp')
-rw-r--r-- | clang/lib/Lex/Preprocessor.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp index 08d8b92..8722be9 100644 --- a/clang/lib/Lex/Preprocessor.cpp +++ b/clang/lib/Lex/Preprocessor.cpp @@ -548,9 +548,10 @@ void Preprocessor::HandleIdentifier(Token &Identifier) { if (II.isExtensionToken() && !DisableMacroExpansion) Diag(Identifier, diag::ext_token_used); - // If this is the '__import_module__' keyword, note that the next token - // indicates a module name. - if (II.getTokenID() == tok::kw___import_module__ && + // If this is the '__import_module__' or 'import' keyword, note that the next + // token indicates a module name. + if ((II.getTokenID() == tok::kw___import_module__ || + II.getObjCKeywordID() == tok::objc_import) && !InMacroArgs && !DisableMacroExpansion) { ModuleImportLoc = Identifier.getLocation(); ModuleImportPath.clear(); @@ -559,7 +560,8 @@ void Preprocessor::HandleIdentifier(Token &Identifier) { } } -/// \brief Lex a token following the __import_module__ keyword. +/// \brief Lex a token following the __import_module__ or 'import' keyword. +/// void Preprocessor::LexAfterModuleImport(Token &Result) { // Figure out what kind of lexer we actually have. if (CurLexer) @@ -578,8 +580,12 @@ void Preprocessor::LexAfterModuleImport(Token &Result) { // // __import_module__ identifier (. identifier)* // + // or + // + // import identifier (. identifier)* + // // indicates a module import directive. We already saw the __import_module__ - // keyword, so now we're looking for the identifiers. + // or 'import' keyword, so now we're looking for the identifiers. if (ModuleImportExpectsIdentifier && Result.getKind() == tok::identifier) { // We expected to see an identifier here, and we did; continue handling // identifiers. |