r223855 - Modified the Objective-C lexer and parser (only

Sean Callanan scallanan at apple.com
Wed Dec 10 11:22:12 PST 2014


Committed as r223935.

Sean

> On Dec 10, 2014, at 10:37 AM, Sean Callanan <scallanan at apple.com> wrote:
> 
> You’re right, thanks for the reminder.  I’ll get a test in today.
> 
> Sean
> 
>> On Dec 10, 2014, at 9:16 AM, jahanian <fjahanian at apple.com> wrote:
>> 
>> Test please.
>> - Fariborz
>> 
>>> On Dec 9, 2014, at 3:47 PM, Sean Callanan <scallanan at apple.com> wrote:
>>> 
>>> Author: spyffe
>>> Date: Tue Dec  9 17:47:56 2014
>>> New Revision: 223855
>>> 
>>> URL: http://llvm.org/viewvc/llvm-project?rev=223855&view=rev
>>> Log:
>>> Modified the Objective-C lexer and parser (only 
>>> in debugger mode) to accept @import declarations
>>> and pass them to the debugger.  
>>> 
>>> In the preprocessor, accept import declarations
>>> if the debugger is enabled, but don't actually
>>> load the module, just pass the import path on to 
>>> the preprocessor callbacks.
>>> 
>>> In the Objective-C parser, if it sees an import
>>> declaration in statement context (usual for LLDB),
>>> ignore it and return a NullStmt.
>>> 
>>> Modified:
>>>  cfe/trunk/lib/Lex/Preprocessor.cpp
>>>  cfe/trunk/lib/Parse/ParseObjc.cpp
>>> 
>>> Modified: cfe/trunk/lib/Lex/Preprocessor.cpp
>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Preprocessor.cpp?rev=223855&r1=223854&r2=223855&view=diff
>>> ==============================================================================
>>> --- cfe/trunk/lib/Lex/Preprocessor.cpp (original)
>>> +++ cfe/trunk/lib/Lex/Preprocessor.cpp Tue Dec  9 17:47:56 2014
>>> @@ -672,7 +672,8 @@ bool Preprocessor::HandleIdentifier(Toke
>>> // keyword when we're in a caching lexer, because caching lexers only get
>>> // used in contexts where import declarations are disallowed.
>>> if (LastTokenWasAt && II.isModulesImport() && !InMacroArgs && 
>>> -      !DisableMacroExpansion && getLangOpts().Modules && 
>>> +      !DisableMacroExpansion &&
>>> +      (getLangOpts().Modules || getLangOpts().DebuggerSupport) && 
>>>     CurLexerKind != CLK_CachingLexer) {
>>>   ModuleImportLoc = Identifier.getLocation();
>>>   ModuleImportPath.clear();
>>> @@ -745,12 +746,14 @@ void Preprocessor::LexAfterModuleImport(
>>> }
>>> 
>>> // If we have a non-empty module path, load the named module.
>>> -  if (!ModuleImportPath.empty() && getLangOpts().Modules) {
>>> -    Module *Imported = TheModuleLoader.loadModule(ModuleImportLoc,
>>> -                                                  ModuleImportPath,
>>> -                                                  Module::MacrosVisible,
>>> -                                                  /*IsIncludeDirective=*/false);
>>> -    if (Callbacks)
>>> +  if (!ModuleImportPath.empty()) {
>>> +    Module *Imported = nullptr;
>>> +    if (getLangOpts().Modules)
>>> +      Imported = TheModuleLoader.loadModule(ModuleImportLoc,
>>> +                                            ModuleImportPath,
>>> +                                            Module::MacrosVisible,
>>> +                                            /*IsIncludeDirective=*/false);
>>> +    if (Callbacks && (getLangOpts().Modules || getLangOpts().DebuggerSupport))
>>>     Callbacks->moduleImport(ModuleImportLoc, ModuleImportPath, Imported);
>>> }
>>> }
>>> 
>>> Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseObjc.cpp?rev=223855&r1=223854&r2=223855&view=diff
>>> ==============================================================================
>>> --- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
>>> +++ cfe/trunk/lib/Parse/ParseObjc.cpp Tue Dec  9 17:47:56 2014
>>> @@ -79,7 +79,7 @@ Parser::DeclGroupPtrTy Parser::ParseObjC
>>>   SingleDecl = ParseObjCPropertyDynamic(AtLoc);
>>>   break;
>>> case tok::objc_import:
>>> -    if (getLangOpts().Modules)
>>> +    if (getLangOpts().Modules || getLangOpts().DebuggerSupport)
>>>     return ParseModuleImport(AtLoc);
>>>   Diag(AtLoc, diag::err_atimport);
>>>   SkipUntil(tok::semi);
>>> @@ -2024,7 +2024,13 @@ StmtResult Parser::ParseObjCAtStatement(
>>> 
>>> if (Tok.isObjCAtKeyword(tok::objc_autoreleasepool))
>>>   return ParseObjCAutoreleasePoolStmt(AtLoc);
>>> -  
>>> +
>>> +  if (Tok.isObjCAtKeyword(tok::objc_import) &&
>>> +      getLangOpts().DebuggerSupport) {
>>> +    SkipUntil(tok::semi);
>>> +    return Actions.ActOnNullStmt(Tok.getLocation());
>>> +  }
>>> +
>>> ExprResult Res(ParseExpressionWithLeadingAt(AtLoc));
>>> if (Res.isInvalid()) {
>>>   // If the expression is invalid, skip ahead to the next semicolon. Not
>>> 
>>> 
>>> _______________________________________________
>>> cfe-commits mailing list
>>> cfe-commits at cs.uiuc.edu
>>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>> 
> 





More information about the cfe-commits mailing list