[clang] [libclang/python] Fix bug in `SourceRange.__contains__`, add tests (PR #101802)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 15 06:03:06 PDT 2024
================
@@ -74,6 +74,16 @@ CINDEX_LINKAGE CXSourceLocation clang_getNullLocation(void);
CINDEX_LINKAGE unsigned clang_equalLocations(CXSourceLocation loc1,
CXSourceLocation loc2);
+/**
+ * Determine for two source locations if they refer to the same file
+ * and one of them comes strictly before the other in the source code.
+ *
+ * \returns non-zero if the source locations refer to the same file and the
+ * first one comes strictly before the second one, zero otherwise.
+ */
+CINDEX_LINKAGE unsigned clang_lessThanLocations(CXSourceLocation loc1,
----------------
AaronBallman wrote:
Can we rename this to `clang_isBeforeInTranslationUnit()`?
I think of source locations as a tuple: file, line, column, and tuple comparison is usually "is each element of the tuple less than each element of the other tuple" which doesn't really apply to source locations (for example, the rhs column numbers can be greater than the lhs column number but the lhs is still before the rhs in the source; also, what does it mean for one file to be less than another file?).
https://github.com/llvm/llvm-project/pull/101802
More information about the cfe-commits
mailing list