[clang-tools-extra] 84deed2 - [clangd] Fix a build failure. NFC

Younan Zhang via cfe-commits cfe-commits at lists.llvm.org
Tue May 9 17:30:53 PDT 2023


Author: Younan Zhang
Date: 2023-05-10T08:28:07+08:00
New Revision: 84deed2b7b6325f99d50ce46512de2c078cefb3a

URL: https://github.com/llvm/llvm-project/commit/84deed2b7b6325f99d50ce46512de2c078cefb3a
DIFF: https://github.com/llvm/llvm-project/commit/84deed2b7b6325f99d50ce46512de2c078cefb3a.diff

LOG: [clangd] Fix a build failure. NFC

This is caused by 7385cc389aba.

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 61bed1ad8141f..de589e70f4afa 100644
--- a/clang-tools-extra/clangd/Hover.cpp
+++ b/clang-tools-extra/clangd/Hover.cpp
@@ -468,9 +468,9 @@ struct PrintExprResult {
   std::optional<std::string> PrintedValue;
   /// The Expr object that represents the closest evaluable
   /// expression.
-  const clang::Expr *Expr;
+  const clang::Expr *TheExpr;
   /// The node of selection tree where the traversal stops.
-  const SelectionTree::Node *Node;
+  const SelectionTree::Node *TheNode;
 };
 
 // Seek the closest evaluable expression along the ancestors of node N
@@ -731,12 +731,12 @@ HoverInfo evaluateMacroExpansion(unsigned int SpellingBeginOffset,
   // Attempt to evaluate it from Expr first.
   auto ExprResult = printExprValue(StartNode, Context);
   HI.Value = std::move(ExprResult.PrintedValue);
-  if (auto *E = ExprResult.Expr)
+  if (auto *E = ExprResult.TheExpr)
     HI.Type = printType(E->getType(), Context, PP);
 
   // If failed, extract the type from Decl if possible.
-  if (!HI.Value && !HI.Type && ExprResult.Node)
-    if (auto *VD = ExprResult.Node->ASTNode.get<VarDecl>())
+  if (!HI.Value && !HI.Type && ExprResult.TheNode)
+    if (auto *VD = ExprResult.TheNode->ASTNode.get<VarDecl>())
       HI.Type = printType(VD->getType(), Context, PP);
 
   return HI;

diff  --git a/clang-tools-extra/clangd/unittests/HoverTests.cpp b/clang-tools-extra/clangd/unittests/HoverTests.cpp
index 677cd5c4e6323..f95c947559936 100644
--- a/clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ b/clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -3998,7 +3998,8 @@ constexpr u64 pow_with_mod(u64 a, u64 b, u64 p) {
   auto H = getHover(AST, C.point(), format::getLLVMStyle(), nullptr);
 
   ASSERT_TRUE(H);
-  EXPECT_EQ(H->Value, "4");
+  EXPECT_TRUE(H->Value);
+  EXPECT_TRUE(H->Type);
 }
 
 } // namespace


        


More information about the cfe-commits mailing list