Author: Simon Tatham Date: 2021-06-18T13:43:14+01:00 New Revision: fd569a11b585d13cdceac2d890c2beda0fa5f0eb
URL: https://github.com/llvm/llvm-project/commit/fd569a11b585d13cdceac2d890c2beda0fa5f0eb DIFF: https://github.com/llvm/llvm-project/commit/fd569a11b585d13cdceac2d890c2beda0fa5f0eb.diff LOG: [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 Added: Modified: clang/tools/libclang/CXSourceLocation.h Removed: ################################################################################ diff --git a/clang/tools/libclang/CXSourceLocation.h b/clang/tools/libclang/CXSourceLocation.h index ce3d09e1c9eb8..c86f6850375bb 100644 --- a/clang/tools/libclang/CXSourceLocation.h +++ b/clang/tools/libclang/CXSourceLocation.h @@ -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() }; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits