Skip to content

Commit 782c3e2

Browse files
committed
[AST] Fix comparison to of SourceRanges in container
Differential Revision: https://reviews.llvm.org/D100723
1 parent 01801d5 commit 782c3e2

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

clang/lib/Tooling/NodeIntrospection.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@ namespace internal {
4444
bool RangeLessThan::operator()(
4545
std::pair<SourceRange, SharedLocationCall> const &LHS,
4646
std::pair<SourceRange, SharedLocationCall> const &RHS) const {
47-
if (!LHS.first.isValid() || !RHS.first.isValid())
48-
return false;
49-
5047
if (LHS.first.getBegin() < RHS.first.getBegin())
5148
return true;
5249
else if (LHS.first.getBegin() != RHS.first.getBegin())

clang/unittests/Introspection/IntrospectionTest.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,20 @@ TEST(Introspection, SourceLocations_CallContainer) {
9191
EXPECT_EQ(slm.size(), 2u);
9292
}
9393

94+
TEST(Introspection, SourceLocations_CallContainer2) {
95+
SourceRangeMap slm;
96+
SharedLocationCall Prefix;
97+
slm.insert(
98+
std::make_pair(SourceRange(), llvm::makeIntrusiveRefCnt<LocationCall>(
99+
Prefix, "getCXXOperatorNameRange")));
100+
EXPECT_EQ(slm.size(), 1u);
101+
102+
slm.insert(std::make_pair(
103+
SourceRange(),
104+
llvm::makeIntrusiveRefCnt<LocationCall>(Prefix, "getSourceRange")));
105+
EXPECT_EQ(slm.size(), 2u);
106+
}
107+
94108
TEST(Introspection, SourceLocations_CallChainFormatting) {
95109
SharedLocationCall Prefix;
96110
auto chainedCall = llvm::makeIntrusiveRefCnt<LocationCall>(

0 commit comments

Comments
 (0)