Skip to content

Commit 8eb8263

Browse files
NuriAmariNuri Amari
andauthored
Implement ClangImporter importSourceLoc and importSourceRange (#40010)
Co-authored-by: Nuri Amari <[email protected]>
1 parent a24d74b commit 8eb8263

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

lib/ClangImporter/ClangImporter.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2265,14 +2265,13 @@ ClangImporter::Implementation::exportSourceLoc(SourceLoc loc) {
22652265

22662266
SourceLoc
22672267
ClangImporter::Implementation::importSourceLoc(clang::SourceLocation loc) {
2268-
// FIXME: Implement!
2269-
return SourceLoc();
2268+
return getBufferImporterForDiagnostics().resolveSourceLocation(
2269+
getClangASTContext().getSourceManager(), loc);
22702270
}
22712271

22722272
SourceRange
22732273
ClangImporter::Implementation::importSourceRange(clang::SourceRange loc) {
2274-
// FIXME: Implement!
2275-
return SourceRange();
2274+
return SourceRange(importSourceLoc(loc.getBegin()), importSourceLoc(loc.getEnd()));
22762275
}
22772276

22782277
#pragma mark Importing names

lib/ClangImporter/ImportDecl.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3376,8 +3376,11 @@ namespace {
33763376
if (alreadyImportedResult != Impl.ImportedDecls.end())
33773377
return alreadyImportedResult->second;
33783378
result = Impl.createDeclWithClangNode<StructDecl>(
3379-
decl, AccessLevel::Public, Impl.importSourceLoc(decl->getBeginLoc()),
3380-
name, Impl.importSourceLoc(decl->getLocation()), None, nullptr, dc);
3379+
decl, AccessLevel::Public,
3380+
SourceLoc(), // FIXME: Impl.importSourceLoc(decl->getBeginLoc()) results in a bad import: SR-15440
3381+
name,
3382+
SourceLoc(), // FIXME: Impl.importSourceLoc(decl->getLocation()) result in a bad import: SR-15440
3383+
None, nullptr, dc);
33813384
Impl.ImportedDecls[{decl->getCanonicalDecl(), getVersion()}] = result;
33823385

33833386
// FIXME: Figure out what to do with superclasses in C++. One possible
@@ -4215,7 +4218,7 @@ namespace {
42154218
Impl.createDeclWithClangNode<VarDecl>(decl, AccessLevel::Public,
42164219
/*IsStatic*/ false,
42174220
VarDecl::Introducer::Var,
4218-
Impl.importSourceLoc(decl->getLocation()),
4221+
SourceLoc(), // FIXME: Impl.importSourceLoc(decl->getLocation()) result in a bad import: SR-15440
42194222
name, dc);
42204223
if (decl->getType().isConstQualified()) {
42214224
// Note that in C++ there are ways to change the values of const
@@ -6939,7 +6942,7 @@ ConstructorDecl *SwiftDeclConverter::importConstructor(
69396942
assert(!importedName.getAsyncInfo());
69406943
auto result = Impl.createDeclWithClangNode<ConstructorDecl>(
69416944
objcMethod, AccessLevel::Public, importedName.getDeclName(),
6942-
/*NameLoc=*/SourceLoc(), failability, /*FailabilityLoc=*/SourceLoc(),
6945+
/*NameLoc=*/Impl.importSourceLoc(objcMethod->getBeginLoc()), failability, /*FailabilityLoc=*/SourceLoc(),
69436946
/*Async=*/false, /*AsyncLoc=*/SourceLoc(),
69446947
/*Throws=*/importedName.getErrorInfo().hasValue(),
69456948
/*ThrowsLoc=*/SourceLoc(), bodyParams,

0 commit comments

Comments
 (0)