[libclang] Fix error handler in translateSourceLocation.

Given an invalid SourceLocation, translateSourceLocation will call
clang_getNullLocation, and then do nothing with the result. But
clang_getNullLocation has no side effects: it just constructs and
returns a null CXSourceLocation value.

Surely the intention was to //return// that null CXSourceLocation to
the caller, instead of throwing it away and pressing on anyway.

Reviewed By: miyuki

Differential Revision: https://reviews.llvm.org/D104442
This commit is contained in:
Simon Tatham 2021-06-18 13:43:13 +01:00
parent 8962c68ad0
commit fd569a11b5
1 changed files with 1 additions and 1 deletions

View File

@ -29,7 +29,7 @@ static inline CXSourceLocation
translateSourceLocation(const SourceManager &SM, const LangOptions &LangOpts,
SourceLocation Loc) {
if (Loc.isInvalid())
clang_getNullLocation();
return clang_getNullLocation();
CXSourceLocation Result = { { &SM, &LangOpts, },
Loc.getRawEncoding() };