mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-07 22:27:13 +00:00
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. llvm-svn: 223855
This commit is contained in:
parent
d73f3c6b73
commit
8759649013
@ -672,7 +672,8 @@ bool Preprocessor::HandleIdentifier(Token &Identifier) {
|
||||
// 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(Token &Result) {
|
||||
}
|
||||
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ Parser::DeclGroupPtrTy Parser::ParseObjCAtDirectives() {
|
||||
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(SourceLocation AtLoc) {
|
||||
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user