Author: Sam McCall Date: 2022-05-31T22:30:20+02:00 New Revision: 218393f44ec903341125b70ce3fbb6dc731a9399
URL: https://github.com/llvm/llvm-project/commit/218393f44ec903341125b70ce3fbb6dc731a9399 DIFF: https://github.com/llvm/llvm-project/commit/218393f44ec903341125b70ce3fbb6dc731a9399.diff LOG: Revert "[clangd] Fix hover crashing on integral or enumeral casts" This reverts commit ce5ebf0b9113df8ccaec1bcfd6804fb16cdef69d. Fails on bots e.g. https://buildkite-cloud.s3.amazonaws.com/logs-by-pipeline/f8ab115f-a384-49e8-a048-0f71ab03c5d0/0181020b-0737-40e5-a05a-ab198347d8ad/0181020b-ecbe-4ac6-ad23-e04c17217893.log?response-content-disposition=inline&response-content-type=text%2Fplain&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=ASIAQPCP3C7LT7IGTS76%2F20220531%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20220531T202904Z&X-Amz-Expires=600&X-Amz-Security-Token=IQoJb3JpZ2luX2VjEDwaCXVzLWVhc3QtMSJGMEQCIEfw6ocELTUWa2mj4reHKLe5OdUmQqVJpPsdZS2wNDhhAiB7qx6Q17HVVY%2BkJZ5hwTQ6b1MkOG4czysfciD9GghJmCrSBAg1EAAaDDAzMjM3OTcwNTMwMyIMgdUfJT4A6wcP2hl2Kq8EefYtGIt0yaiOSfuq05UzI6WcBY9yOOyYCs3%2FJJDvK3jkpiYQhjA1kgVluePIb3P4yOTXs8lv9U6p8HU555Vzvrv1Wg%2FGvx7U398lH8zg%2BqkvEwnpGuRf0pTInPJftg2bgm%2F7l%2BCM6PtW4mRlzjeQ0IoA3AeENqVM35RYtQdh%2BcAZIfV4l7uAySVgwY1yFu0XznuGAVVryZyYcA2cjKkkNE%2F9n2QTo80%2FbZBvoh1bxJqXRbs5WrSnWlIEj3RPX61ir7lDpRNL5tyVlqsv%2BvV01aS%2F9JbM4cNDXZ%2BDwOR1Q%2By1ajJOomuK9Bqm%2Fq8%2B9%2Byo1t8rFSN7I4X%2BGGuicXFQQnIJAkW3zSQlx9SWrf2uDg7cbXL4MukD9cQB5aN8yX85a%2BRcbb5l4%2BOC%2B8UFKMeemUZyEl5PyyJSBnAnzqvKviJPev9Thj9rZeHGEJD9vOkVM%2FG2tOlC7HUxXAE4kuLlAdeKdIOtHz%2Bx8FzRn%2Bgl6EB2nB4kSVLvfgrsrlHS0L0J1zWbN%2F6prqzum%2FEVIhT7Y5fyZRqtygAX2n7iBjQEM3vpF2GTneUI1FlDeQvGPLADFdq7bXSUOt577YOTw1mW1JzqmZljrJeIM40HdMYnuIg3%2FwW8oK6RKGADdW7URPw%2FoFeGKfrnN%2BuDwJKvrRGCpReseGse2sdYIe28rgGHpc5xsp3pzipQDLfW3hTNtM%2FNNuPJjUWZoBRTMr2eMuk2zs2c6jNvnuBTbgXjcdjCbjCX2dmUBjqqAUalggvk2TGoJzTuqAT%2Fj1kz0vnHdmsHY3B9aR2kY501gISXQMKj7l03E7OfFsu4oPzEgmnyQFKcAolRDI%2F7NRmG8HwtP40iTCjflOHIxkJ1%2FnVNqkeyIznUu6zOr589zIjNqFCm74jOfWjj2%2FO8WU4pc%2FRqeBuGzzpQkAIGGxCwsmd3WG8Z8pyMoJomij7c4LO6ep4O0OUESxbXHcIfzUfR6ajPsKFKS9lb&X-Amz-SignedHeaders=host&X-Amz-Signature=96a132be6f99b5cd5cf29f3226115e480508079047bc8639d69c672f1fe9f0c1 Added: Modified: clang-tools-extra/clangd/Hover.cpp clang-tools-extra/clangd/unittests/HoverTests.cpp Removed: ################################################################################ diff --git a/clang-tools-extra/clangd/Hover.cpp b/clang-tools-extra/clangd/Hover.cpp index 00fb992876178..fcf3af7561845 100644 --- a/clang-tools-extra/clangd/Hover.cpp +++ b/clang-tools-extra/clangd/Hover.cpp @@ -429,8 +429,7 @@ llvm::Optional<std::string> printExprValue(const Expr *E, return llvm::None; // Show enums symbolically, not numerically like APValue::printPretty(). - if (T->isEnumeralType() && Constant.Val.isInt() && - Constant.Val.getInt().getMinSignedBits() <= 64) { + if (T->isEnumeralType() && Constant.Val.getInt().getMinSignedBits() <= 64) { // Compare to int64_t to avoid bit-width match requirements. int64_t Val = Constant.Val.getInt().getExtValue(); for (const EnumConstantDecl *ECD : @@ -441,7 +440,7 @@ llvm::Optional<std::string> printExprValue(const Expr *E, .str(); } // Show hex value of integers if they're at least 10 (or negative!) - if (T->isIntegralOrEnumerationType() && Constant.Val.isInt() && + if (T->isIntegralOrEnumerationType() && Constant.Val.getInt().getMinSignedBits() <= 64 && Constant.Val.getInt().uge(10)) return llvm::formatv("{0} ({1})", Constant.Val.getAsString(Ctx, T), diff --git a/clang-tools-extra/clangd/unittests/HoverTests.cpp b/clang-tools-extra/clangd/unittests/HoverTests.cpp index 86ecda4e454c4..25ce19b2c580b 100644 --- a/clang-tools-extra/clangd/unittests/HoverTests.cpp +++ b/clang-tools-extra/clangd/unittests/HoverTests.cpp @@ -3206,33 +3206,6 @@ TEST(Hover, HideBigInitializers) { ASSERT_TRUE(H); EXPECT_EQ(H->Definition, "int arr[]"); } - -TEST(Hover, GlobalVarEnumeralCastNoCrash) { - Annotations T(R"cpp( - enum Test : unsigned long {}; - unsigned global_var; - void foo() { Test v^al = (Test)(unsigned long)&global_var; } - )cpp"); - - TestTU TU = TestTU::withCode(T.code()); - auto AST = TU.build(); - auto HI = getHover(AST, T.point(), format::getLLVMStyle(), nullptr); - ASSERT_TRUE(HI); - EXPECT_EQ(*HI->Value, "&global_var"); -} - -TEST(Hover, GlobalVarIntCastNoCrash) { - Annotations T(R"cpp( - unsigned global_var; - int foo() { unsigned long a^ddress = (unsigned long)&global_var; } - )cpp"); - - TestTU TU = TestTU::withCode(T.code()); - auto AST = TU.build(); - auto HI = getHover(AST, T.point(), format::getLLVMStyle(), nullptr); - ASSERT_TRUE(HI); - EXPECT_EQ(*HI->Value, "&global_var"); -} } // namespace } // namespace clangd } // namespace clang _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits