This revision was automatically updated to reflect the committed changes. Closed by commit rG782c3e23ba09: [AST] Fix comparison to of SourceRanges in container (authored by stephenkelly).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D100723/new/ https://reviews.llvm.org/D100723 Files: clang/lib/Tooling/NodeIntrospection.cpp clang/unittests/Introspection/IntrospectionTest.cpp Index: clang/unittests/Introspection/IntrospectionTest.cpp =================================================================== --- clang/unittests/Introspection/IntrospectionTest.cpp +++ clang/unittests/Introspection/IntrospectionTest.cpp @@ -91,6 +91,20 @@ 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>( Index: clang/lib/Tooling/NodeIntrospection.cpp =================================================================== --- clang/lib/Tooling/NodeIntrospection.cpp +++ clang/lib/Tooling/NodeIntrospection.cpp @@ -44,9 +44,6 @@ 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())
Index: clang/unittests/Introspection/IntrospectionTest.cpp =================================================================== --- clang/unittests/Introspection/IntrospectionTest.cpp +++ clang/unittests/Introspection/IntrospectionTest.cpp @@ -91,6 +91,20 @@ 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>( Index: clang/lib/Tooling/NodeIntrospection.cpp =================================================================== --- clang/lib/Tooling/NodeIntrospection.cpp +++ clang/lib/Tooling/NodeIntrospection.cpp @@ -44,9 +44,6 @@ 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())
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits