Skip to content

Commit f694044

Browse files
author
Gabor Horvath
committed
[cxx-interop] Fix assert failure due to invalid location
We hit an assert failure do to creating a range where the begin was a valid source location while the end range was an invalid one. Unfortunately, I was not able to create a minimal reproducer but I was able to verify that this fix works because I was able to reproduce this issue while compiling Swift with a patched version of Clang. rdar://155379027
1 parent 4064ad1 commit f694044

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/ClangImporter/ImportType.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2885,9 +2885,10 @@ ParameterList *ClangImporter::Implementation::importFunctionParameterList(
28852885
// Estimate locations for the begin and end of parameter list.
28862886
auto begin = clangDecl->getLocation();
28872887
auto end = begin;
2888-
if (!params.empty()) {
2889-
begin = params.front()->getBeginLoc();
2890-
end = params.back()->getEndLoc();
2888+
auto paramsRange = clangDecl->getParametersSourceRange();
2889+
if (paramsRange.isValid()) {
2890+
begin = paramsRange.getBegin();
2891+
end = paramsRange.getEnd();
28912892
}
28922893
return ParameterList::create(SwiftContext, importSourceLoc(begin), parameters,
28932894
importSourceLoc(end));

0 commit comments

Comments
 (0)