Skip to content

Commit c88aad6

Browse files
committed
Override TraversePseudoObjectExpr
1 parent 8813a4f commit c88aad6

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

clang-tools-extra/clangd/InlayHints.cpp

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -589,17 +589,22 @@ class InlayHintVisitor : public RecursiveASTVisitor<InlayHintVisitor> {
589589
return true;
590590
}
591591

592-
bool dataTraverseStmtPre(Stmt *S) {
593-
// Do not show inlay hints for the __builtin_dump_struct, which would expand
594-
// to a PseudoObjectExpr that includes a couple of calls to a printf
595-
// function. Printing parameter names for that anyway would end up with
596-
// duplicate parameter names (which, however, got de-duplicated after
592+
bool TraversePseudoObjectExpr(PseudoObjectExpr *E) {
593+
// Do not show inlay hints for the __builtin_dump_struct, which would
594+
// expand to a PseudoObjectExpr that includes a couple of calls to a
595+
// printf function. Printing parameter names for that anyway would end up
596+
// with duplicate parameter names (which, however, got de-duplicated after
597597
// visiting) for the printf function.
598-
if (auto *POE = dyn_cast<PseudoObjectExpr>(S))
599-
if (auto *CE = dyn_cast<CallExpr>(POE->getSyntacticForm());
600-
CE && CE->getBuiltinCallee() == Builtin::BI__builtin_dump_struct)
601-
return false;
602-
return true;
598+
if (auto *CE = dyn_cast<CallExpr>(E->getSyntacticForm());
599+
CE && CE->getBuiltinCallee() == Builtin::BI__builtin_dump_struct)
600+
// Only traverse the syntactic forms. This leaves the door open in case
601+
// the arguments in the syntactic form for __builtin_dump_struct could
602+
// possibly get parameter names.
603+
return RecursiveASTVisitor<InlayHintVisitor>::TraverseStmt(
604+
E->getSyntacticForm());
605+
// FIXME: Shall we ignore semantic forms for other pseudo object
606+
// expressions?
607+
return RecursiveASTVisitor<InlayHintVisitor>::TraversePseudoObjectExpr(E);
603608
}
604609

605610
bool VisitCallExpr(CallExpr *E) {

0 commit comments

Comments
 (0)