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() };
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() };
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits