Skip to content

Implement ClangImporter importSourceLoc and importSourceRange #40010

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions lib/ClangImporter/ClangImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2265,14 +2265,13 @@ ClangImporter::Implementation::exportSourceLoc(SourceLoc loc) {

SourceLoc
ClangImporter::Implementation::importSourceLoc(clang::SourceLocation loc) {
// FIXME: Implement!
return SourceLoc();
return getBufferImporterForDiagnostics().resolveSourceLocation(
getClangASTContext().getSourceManager(), loc);
}

SourceRange
ClangImporter::Implementation::importSourceRange(clang::SourceRange loc) {
// FIXME: Implement!
return SourceRange();
return SourceRange(importSourceLoc(loc.getBegin()), importSourceLoc(loc.getEnd()));
}

#pragma mark Importing names
Expand Down
11 changes: 7 additions & 4 deletions lib/ClangImporter/ImportDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3376,8 +3376,11 @@ namespace {
if (alreadyImportedResult != Impl.ImportedDecls.end())
return alreadyImportedResult->second;
result = Impl.createDeclWithClangNode<StructDecl>(
decl, AccessLevel::Public, Impl.importSourceLoc(decl->getBeginLoc()),
name, Impl.importSourceLoc(decl->getLocation()), None, nullptr, dc);
decl, AccessLevel::Public,
SourceLoc(), // FIXME: Impl.importSourceLoc(decl->getBeginLoc()) results in a bad import: SR-15440
name,
SourceLoc(), // FIXME: Impl.importSourceLoc(decl->getLocation()) result in a bad import: SR-15440
None, nullptr, dc);
Impl.ImportedDecls[{decl->getCanonicalDecl(), getVersion()}] = result;

// FIXME: Figure out what to do with superclasses in C++. One possible
Expand Down Expand Up @@ -4215,7 +4218,7 @@ namespace {
Impl.createDeclWithClangNode<VarDecl>(decl, AccessLevel::Public,
/*IsStatic*/ false,
VarDecl::Introducer::Var,
Impl.importSourceLoc(decl->getLocation()),
SourceLoc(), // FIXME: Impl.importSourceLoc(decl->getLocation()) result in a bad import: SR-15440
name, dc);
if (decl->getType().isConstQualified()) {
// Note that in C++ there are ways to change the values of const
Expand Down Expand Up @@ -6937,7 +6940,7 @@ ConstructorDecl *SwiftDeclConverter::importConstructor(
assert(!importedName.getAsyncInfo());
auto result = Impl.createDeclWithClangNode<ConstructorDecl>(
objcMethod, AccessLevel::Public, importedName.getDeclName(),
/*NameLoc=*/SourceLoc(), failability, /*FailabilityLoc=*/SourceLoc(),
/*NameLoc=*/Impl.importSourceLoc(objcMethod->getBeginLoc()), failability, /*FailabilityLoc=*/SourceLoc(),
/*Async=*/false, /*AsyncLoc=*/SourceLoc(),
/*Throws=*/importedName.getErrorInfo().hasValue(),
/*ThrowsLoc=*/SourceLoc(), bodyParams,
Expand Down