mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-23 07:52:06 +00:00
[clangd] Fix a crash when presenting values for Hover
Summary: 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. Reviewers: sammccall Reviewed By: sammccall Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65655 llvm-svn: 367687
This commit is contained in:
parent
809e9d1efa
commit
25082817eb
@ -715,7 +715,7 @@ static HoverInfo getHoverContents(const Decl *D, const SymbolIndex *Index) {
|
||||
HI.Value.emplace();
|
||||
llvm::raw_string_ostream ValueOS(*HI.Value);
|
||||
Result.Val.printPretty(ValueOS, const_cast<ASTContext &>(Ctx),
|
||||
Var->getType());
|
||||
Init->getType());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1793,6 +1793,16 @@ TEST(Hover, All) {
|
||||
"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.
|
||||
|
Loading…
Reference in New Issue
Block a user