[PATCH] D65655: [clangd] Fix a crash when presenting values for Hover
Ilya Biryukov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 2 06:28:31 PDT 2019
ilya-biryukov created this revision.
ilya-biryukov added a reviewer: sammccall.
Herald added subscribers: kadircet, arphaman, jkorous, MaskRay.
Herald added a project: clang.
We should pass the expression type, not a variable type when printing
the resulting value. Variable type may be different from what the
pretty-printing function expects, e.g. have references.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D65655
Files:
clang-tools-extra/clangd/XRefs.cpp
clang-tools-extra/clangd/unittests/XRefsTests.cpp
Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -1793,6 +1793,16 @@
"int\n"
"]",
},
+ {
+ R"cpp(// Should not crash when evaluating the initializer.
+ struct Test {};
+ void test() { Test && te^st = {}; }
+ )cpp",
+ "text[Declared in]code[test]\n"
+ "codeblock(cpp) [\n"
+ "struct Test &&test = {}\n"
+ "]",
+ },
};
// Create a tiny index, so tests above can verify documentation is fetched.
Index: clang-tools-extra/clangd/XRefs.cpp
===================================================================
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -715,7 +715,7 @@
HI.Value.emplace();
llvm::raw_string_ostream ValueOS(*HI.Value);
Result.Val.printPretty(ValueOS, const_cast<ASTContext &>(Ctx),
- Var->getType());
+ Init->getType());
}
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65655.213037.patch
Type: text/x-patch
Size: 1186 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190802/c3b34786/attachment.bin>
More information about the cfe-commits
mailing list