================ @@ -143,8 +143,16 @@ std::string printDefinition(const Decl *D, PrintingPolicy PP, // Initializers might be huge and result in lots of memory allocations in // some catostrophic cases. Such long lists are not useful in hover cards // anyway. - if (200 < TB.expandedTokens(IE->getSourceRange()).size()) + const auto &SM = VD->getASTContext().getSourceManager(); + if (!SM.isInMainFile(VD->getLocation())) { ---------------- kadircet wrote:
we actually need `IE->getSourceRange()` to be inside the mainfile, this can still be `int x[] = EXPANDS_TO_CRAZY_LONG_INIT_DEFINED_OUTSIDE_THE_MAINFILE`. also you're just checking the first level of children now, we can have something like: `int **x = { {CRAZY_EXPANSION} };` which only has a single children at top level, but still has a ton nested underneath. can we just have: ``` auto TotalChildrenInStmt = [&](const Stmt *S) { size_t res = 1; for(auto &C : S->children()) res += TotalChildrenInStmt(C); return res; }; PP.SuppressInitializers = 200 < TB.expandedTokens(IE->getSourceRange()).size() || 100 < TotalChildrenInExpr(IE); ``` https://github.com/llvm/llvm-project/pull/79746 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits