[clang] Improve HeuristicResolver further so it can replace most of getApproximateType() in SemaCodeComplete (PR #156282)

kadir çetinkaya via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 20 03:52:52 PDT 2025


kadircet wrote:

hi! we're seeing much higher (>100x) indexing times on certain code patterns after this change.

```cpp
template <typename T>
static void _CustomWrapCode(T& _class) {
  _class.def0.def0.def0.def0.staticmethod.def.def.def()
      .def()
      .def()
      .staticmethod()
      .def()
      .staticmethod()
      .def()
      .staticmethod()
      .def()
      .staticmethod()
      .def()
      .staticmethod()
      .def()
      .staticmethod()
      .def()
      .staticmethod()
      .def()
      .staticmethod()
      .def()
      .staticmethod()
      .def()
      .staticmethod()
      .def0.staticmethod0.def0.def0.def0.def0.def0.def0;
}
```

as a reproducer, before this change:
```
$ time ./bin/clangd --check=/tmp/my_ver.cc -check-locations=0`:
...
real    0m0.050s
user    0m0.034s
sys     0m0.017s
```

after this change:
```
$ time ./bin/clangd --check=/tmp/my_ver.cc -check-locations=0
...
real    0m32.580s
user    0m31.744s
sys     0m0.832s
```

with big slowdowns near indexing && semantic token generation.

I am seeing long call stacks that repeat:
```
clang::(anonymous namespace)::HeuristicResolverImpl::resolveDependentMember(clang::QualType, clang::DeclarationName, llvm::function_ref<bool (clang::NamedDecl const*)>) (.llvm.7950477370274967279)
clang::(anonymous namespace)::HeuristicResolverImpl::resolveExprToDecls(clang::Expr const*)
clang::(anonymous namespace)::HeuristicResolverImpl::resolveExprToType(clang::Expr const*) 
clang::(anonymous namespace)::HeuristicResolverImpl::resolveExprToDecls(clang::Expr const*)
clang::(anonymous namespace)::HeuristicResolverImpl::resolveExprToType(clang::Expr const*) 
clang::(anonymous namespace)::HeuristicResolverImpl::resolveExprToDecls(clang::Expr const*)
clang::(anonymous namespace)::HeuristicResolverImpl::resolveExprToDecls(clang::Expr const*)
....
```

https://github.com/llvm/llvm-project/pull/156282


More information about the cfe-commits mailing list