[clang] Improve HeuristicResolver further so it can replace most of getApproximateType() in SemaCodeComplete (PR #156282)
Nathan Ridge via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 20 18:50:04 PDT 2025
HighCommander4 wrote:
The regression is caused by the additional of the following hunk to `resolveExprToType()`:
```c++
if (const auto *CE = dyn_cast<CallExpr>(E)) {
if (QualType Resolved = resolveTypeOfCallExpr(CE); !Resolved.isNull())
return Resolved;
}
```
If we have a `CallExpr`, but `resolveTypeOfCallExpr()` fails to resolve a type for it, we don't early-return but instead proceed to the rest of the function. Later in the function we call `resolveExprToDecls()`, which will call `resolveTypeOfCallExpr()` again (as part of calling `resolveTypeOfCallExpr()` + `resolveTypeToTagDecl()`). So we end up calling `resolveTypeOfCallExpr()` twice even though we know if won't produce a useful result.
As a result of this, a call to `resolveExprToDecls()` on an expression involved chained function calls will do an amount of processing that's expontential in the length of the chain.
Fix coming up.
https://github.com/llvm/llvm-project/pull/156282
More information about the cfe-commits
mailing list