T->isFunctionReferenceType())
return llvm::None;
// Attempt to evaluate. If expr is dependent, evaluation crashes!
- if (E->isValueDependent() || !E->EvaluateAsRValue(Constant, Ctx))
+ if (E->isValueDependent() || !E->EvaluateAsRValue(Constant, Ctx) ||
+ // Disable printing for record-types, as they are usually confusing and
+ // might make clang crash while printing the expressions.
+ Constant.Val.isStruct() || Constant.Val.isUnion())
return llvm::None;
// Show enums symbolically, not numerically like APValue::printPretty().
if (ECD->getInitVal() == Val)
return llvm::formatv("{0} ({1})", ECD->getNameAsString(), Val).str();
}
- return Constant.Val.getAsString(Ctx, E->getType());
+ return Constant.Val.getAsString(Ctx, T);
}
llvm::Optional<std::string> printExprValue(const SelectionTree::Node *N,
HI.Parameters->back().Name = "v";
HI.AccessSpecifier = "public";
}},
+ {// Field type initializer.
+ R"cpp(
+ struct X { int x = 2; };
+ X ^[[x]];
+ )cpp",
+ [](HoverInfo &HI) {
+ HI.Name = "x";
+ HI.Kind = index::SymbolKind::Variable;
+ HI.NamespaceScope = "";
+ HI.Definition = "X x";
+ HI.Type = "struct X";
+ }},
};
for (const auto &Case : Cases) {
SCOPED_TRACE(Case.Code);
HI.LocalScope = "Foo::";
HI.Type = "int";
HI.Definition = "int x";
- HI.Value = "{1}";
+ // FIXME: Initializer for x is a DesignatedInitListExpr, hence it is
+ // of struct type and omitted.
}},
{
R"cpp(// Field, field designator
- struct Foo { int x; };
+ struct Foo { int x; int y; };
int main() {
- Foo bar = { .^[[x]] = 2 };
+ Foo bar = { .^[[x]] = 2, .y = 2 };
}
)cpp",
[](HoverInfo &HI) {
HI.LocalScope = "Foo::";
HI.Type = "int";
HI.Definition = "int x";
- HI.Value = "{2}";
}},
{
R"cpp(// Method call
HI.LocalScope = "test::";
HI.Type = "struct Test &&";
HI.Definition = "Test &&test = {}";
- HI.Value = "{}";
}},
{
R"cpp(// auto on alias
HI.NamespaceScope = "";
HI.Name = "foo";
HI.Type = "cls<cls<cls<int>>>";
- HI.Value = "{}";
}},
{
R"cpp(// type of nested templates.