Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions clang-tools-extra/clangd/InlayHints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,9 @@ std::string summarizeExpr(const Expr *E) {
return getSimpleName(*E->getFoundDecl()).str();
}
std::string VisitCallExpr(const CallExpr *E) {
return Visit(E->getCallee());
std::string Result = Visit(E->getCallee());
Result += E->getNumArgs() == 0 ? "()" : "(...)";
return Result;
}
std::string
VisitCXXDependentScopeMemberExpr(const CXXDependentScopeMemberExpr *E) {
Expand Down Expand Up @@ -301,6 +303,9 @@ std::string summarizeExpr(const Expr *E) {
}

// Literals are just printed
std::string VisitCXXNullPtrLiteralExpr(const CXXNullPtrLiteralExpr *E) {
return "nullptr";
}
std::string VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *E) {
return E->getValue() ? "true" : "false";
}
Expand All @@ -319,12 +324,14 @@ std::string summarizeExpr(const Expr *E) {
std::string Result = "\"";
if (E->containsNonAscii()) {
Result += "...";
} else if (E->getLength() > 10) {
Result += E->getString().take_front(7);
Result += "...";
} else {
llvm::raw_string_ostream OS(Result);
llvm::printEscapedString(E->getString(), OS);
if (E->getLength() > 10) {
llvm::printEscapedString(E->getString().take_front(7), OS);
Result += "...";
} else {
llvm::printEscapedString(E->getString(), OS);
}
}
Result.push_back('"');
return Result;
Expand Down Expand Up @@ -1193,7 +1200,7 @@ class InlayHintVisitor : public RecursiveASTVisitor<InlayHintVisitor> {
// Otherwise, the hint shouldn't be shown.
std::optional<Range> computeBlockEndHintRange(SourceRange BraceRange,
StringRef OptionalPunctuation) {
constexpr unsigned HintMinLineLimit = 2;
constexpr unsigned HintMinLineLimit = 10;

auto &SM = AST.getSourceManager();
auto [BlockBeginFileId, BlockBeginOffset] =
Expand Down