aboutsummaryrefslogtreecommitdiff
path: root/lib/Lex/Preprocessor.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2012-01-03 18:04:46 +0000
committerDouglas Gregor <dgregor@apple.com>2012-01-03 18:04:46 +0000
commit5948ae1021122164b22f74353bb7fe325a64f616 (patch)
treeb10150c1440f0bd3dd2e91cb551228dd191ed587 /lib/Lex/Preprocessor.cpp
parent674949fe3fdd796fc643f0e7660cb973da1dd383 (diff)
Introduce a non-uglified syntax for module imports in Objective-C:
@import identifier [. identifier]* ; git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147452 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/Preprocessor.cpp')
-rw-r--r--lib/Lex/Preprocessor.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/Lex/Preprocessor.cpp b/lib/Lex/Preprocessor.cpp
index 08d8b920d1..8722be93d3 100644
--- a/lib/Lex/Preprocessor.cpp
+++ b/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.