aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Basic/SourceManager.cpp
diff options
context:
space:
mode:
authorJannick Kremer <jannick.kremer@mailbox.org>2024-08-16 00:32:58 +0200
committerGitHub <noreply@github.com>2024-08-16 00:32:58 +0200
commitc5b611a419ca8acab041ca52a94c6338bdcd1756 (patch)
treec7fb6eb45324fee707c17db673e97cfe0091da7c /clang/lib/Basic/SourceManager.cpp
parentc458e9e034b2c49a4b35eb732f08a30b338a9ae2 (diff)
downloadllvm-c5b611a419ca8acab041ca52a94c6338bdcd1756.zip
llvm-c5b611a419ca8acab041ca52a94c6338bdcd1756.tar.gz
llvm-c5b611a419ca8acab041ca52a94c6338bdcd1756.tar.bz2
[libclang/python] Expose `clang_isBeforeInTranslationUnit` for `SourceRange.__contains__`
Add libclang function `clang_isBeforeInTranslationUnit` to allow checking the order between two source locations. Simplify the `SourceRange.__contains__` implementation using this new function. Add tests for `SourceRange.__contains__` and the newly added functionality. Fixes #22617 Fixes #52827
Diffstat (limited to 'clang/lib/Basic/SourceManager.cpp')
-rw-r--r--clang/lib/Basic/SourceManager.cpp3
1 files changed, 1 insertions, 2 deletions
diff --git a/clang/lib/Basic/SourceManager.cpp b/clang/lib/Basic/SourceManager.cpp
index 533a9fe..b0256a8c 100644
--- a/clang/lib/Basic/SourceManager.cpp
+++ b/clang/lib/Basic/SourceManager.cpp
@@ -2038,8 +2038,7 @@ bool SourceManager::isBeforeInTranslationUnit(SourceLocation LHS,
std::pair<bool, bool> InSameTU = isInTheSameTranslationUnit(LOffs, ROffs);
if (InSameTU.first)
return InSameTU.second;
- // TODO: This should be unreachable, but some clients are calling this
- // function before making sure LHS and RHS are in the same TU.
+ // This case is used by libclang: clang_isBeforeInTranslationUnit
return LOffs.first < ROffs.first;
}