[PATCH] D104442: [libclang] Fix error handler in translateSourceLocation.
Simon Tatham via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 17 01:24:33 PDT 2021
simon_tatham created this revision.
simon_tatham added reviewers: akyrtzi, rsmith.
simon_tatham requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D104442
Files:
clang/tools/libclang/CXSourceLocation.h
Index: clang/tools/libclang/CXSourceLocation.h
===================================================================
--- clang/tools/libclang/CXSourceLocation.h
+++ clang/tools/libclang/CXSourceLocation.h
@@ -29,7 +29,7 @@
translateSourceLocation(const SourceManager &SM, const LangOptions &LangOpts,
SourceLocation Loc) {
if (Loc.isInvalid())
- clang_getNullLocation();
+ return clang_getNullLocation();
CXSourceLocation Result = { { &SM, &LangOpts, },
Loc.getRawEncoding() };
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D104442.352638.patch
Type: text/x-patch
Size: 547 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210617/a435433a/attachment.bin>
More information about the cfe-commits
mailing list