Skip to content

Commit

Permalink
[AST] Fix comparison to of SourceRanges in container
Browse files Browse the repository at this point in the history
Differential Revision: https://reviews.llvm.org/D100723
  • Loading branch information
steveire committed Apr 19, 2021
1 parent 01801d5 commit 782c3e2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
3 changes: 0 additions & 3 deletions clang/lib/Tooling/NodeIntrospection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ namespace internal {
bool RangeLessThan::operator()(
std::pair<SourceRange, SharedLocationCall> const &LHS,
std::pair<SourceRange, SharedLocationCall> const &RHS) const {
if (!LHS.first.isValid() || !RHS.first.isValid())
return false;

if (LHS.first.getBegin() < RHS.first.getBegin())
return true;
else if (LHS.first.getBegin() != RHS.first.getBegin())
Expand Down
14 changes: 14 additions & 0 deletions clang/unittests/Introspection/IntrospectionTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,20 @@ TEST(Introspection, SourceLocations_CallContainer) {
EXPECT_EQ(slm.size(), 2u);
}

TEST(Introspection, SourceLocations_CallContainer2) {
SourceRangeMap slm;
SharedLocationCall Prefix;
slm.insert(
std::make_pair(SourceRange(), llvm::makeIntrusiveRefCnt<LocationCall>(
Prefix, "getCXXOperatorNameRange")));
EXPECT_EQ(slm.size(), 1u);

slm.insert(std::make_pair(
SourceRange(),
llvm::makeIntrusiveRefCnt<LocationCall>(Prefix, "getSourceRange")));
EXPECT_EQ(slm.size(), 2u);
}

TEST(Introspection, SourceLocations_CallChainFormatting) {
SharedLocationCall Prefix;
auto chainedCall = llvm::makeIntrusiveRefCnt<LocationCall>(
Expand Down

0 comments on commit 782c3e2

Please sign in to comment.