From: Daniel Jasper Date: Mon, 2 Feb 2015 23:35:39 +0000 (+0000) Subject: Revert "Add some overloads so that floating point literals can be AST matched properly." X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=903b9de8eea5276b66647d5ffefd9cf75c244830;p=clang Revert "Add some overloads so that floating point literals can be AST matched properly." Apparently the build bots get angry for some reason. Can't reproduce that in a local cmake/ninja build. Will look closer. Rolling back for now. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@227895 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/ASTMatchers/ASTMatchersInternal.h b/include/clang/ASTMatchers/ASTMatchersInternal.h index bc979b21f3..ebe5cddb62 100644 --- a/include/clang/ASTMatchers/ASTMatchersInternal.h +++ b/include/clang/ASTMatchers/ASTMatchersInternal.h @@ -1456,32 +1456,6 @@ private: const ValueT ExpectedValue; }; -template <> -bool ValueEqualsMatcher::matchesNode( - const FloatingLiteral &Node) const { - if ((&Node.getSemantics()) == &llvm::APFloat::IEEEsingle) - return Node.getValue().convertToFloat() == ExpectedValue; - if ((&Node.getSemantics()) == &llvm::APFloat::IEEEdouble) - return Node.getValue().convertToDouble() == ExpectedValue; - return false; -} - -template <> -bool ValueEqualsMatcher::matchesNode( - const FloatingLiteral &Node) const { - if ((&Node.getSemantics()) == &llvm::APFloat::IEEEsingle) - return Node.getValue().convertToFloat() == ExpectedValue; - if ((&Node.getSemantics()) == &llvm::APFloat::IEEEdouble) - return Node.getValue().convertToDouble() == ExpectedValue; - return false; -} - -template <> -bool ValueEqualsMatcher::matchesNode( - const FloatingLiteral &Node) const { - return ExpectedValue.compare(Node.getValue()) == llvm::APFloat::cmpEqual; -} - /// \brief A VariadicDynCastAllOfMatcher object is a /// variadic functor that takes a number of Matcher and returns a /// Matcher that matches TargetT nodes that are matched by all of the diff --git a/unittests/ASTMatchers/ASTMatchersTest.cpp b/unittests/ASTMatchers/ASTMatchersTest.cpp index 9cc011d3a6..d2e9ee19b2 100644 --- a/unittests/ASTMatchers/ASTMatchersTest.cpp +++ b/unittests/ASTMatchers/ASTMatchersTest.cpp @@ -2104,16 +2104,8 @@ TEST(Matcher, FloatLiterals) { EXPECT_TRUE(matches("double i = 10.0;", HasFloatLiteral)); EXPECT_TRUE(matches("double i = 10.0L;", HasFloatLiteral)); EXPECT_TRUE(matches("double i = 1e10;", HasFloatLiteral)); - EXPECT_TRUE(matches("double i = 5.0;", floatLiteral(equals(5.0)))); - EXPECT_TRUE(matches("double i = 5.0;", floatLiteral(equals(5.0f)))); - EXPECT_TRUE( - matches("double i = 5.0;", floatLiteral(equals(llvm::APFloat(5.0))))); EXPECT_TRUE(notMatches("float i = 10;", HasFloatLiteral)); - EXPECT_TRUE(notMatches("double i = 5.0;", floatLiteral(equals(6.0)))); - EXPECT_TRUE(notMatches("double i = 5.0;", floatLiteral(equals(6.0f)))); - EXPECT_TRUE( - notMatches("double i = 5.0;", floatLiteral(equals(llvm::APFloat(6.0))))); } TEST(Matcher, NullPtrLiteral) {