-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[clangd] Avoid calling resolveTypeOfCallExpr() twice in HeuristicResolver::resolveExprToType() #164353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[clangd] Avoid calling resolveTypeOfCallExpr() twice in HeuristicResolver::resolveExprToType() #164353
Conversation
|
@llvm/pr-subscribers-clang Author: Nathan Ridge (HighCommander4) ChangesFull diff: https://github.com/llvm/llvm-project/pull/164353.diff 1 Files Affected:
diff --git a/clang/lib/Sema/HeuristicResolver.cpp b/clang/lib/Sema/HeuristicResolver.cpp
index cbdefaa57aacb..056e13308b7d3 100644
--- a/clang/lib/Sema/HeuristicResolver.cpp
+++ b/clang/lib/Sema/HeuristicResolver.cpp
@@ -450,7 +450,12 @@ QualType HeuristicResolverImpl::resolveExprToType(const Expr *E) {
if (const auto *CE = dyn_cast<CallExpr>(E)) {
if (QualType Resolved = resolveTypeOfCallExpr(CE); !Resolved.isNull())
return Resolved;
+
+ // Don't proceed to try resolveExprToDecls(), it would just call
+ // resolveTypeOfCallExpr() again.
+ return E->getType();
}
+
// Similarly, unwrapping a unary dereference operation does not work via
// resolveExprToDecls.
if (const auto *UO = dyn_cast<UnaryOperator>(E->IgnoreParenCasts())) {
|
|
@kadircet Do we have a good way of writing a regression test for something like this? Checking elapsed time seems flaky. |
|
thanks a lot for the quick fix!
Unfortunately, no, I don't think we do :/ Best that comes to mind is have a callback somewhere down the stack when we resolve a dependent name, print the stack there and check for certain invariants (and hope that optimizations etc. don't trip that up). I don't think that's gonna be worthwhile either. Still having a unittest, with a comment saying "this shouldn't increase testing times", would likely be better than nothing. Long running tests are likely to catch some attention, at least from us :) |
…lver::resolveExprToType() Fixes the performance regression reported at llvm#156282 (comment)
9d90d16 to
77caef8
Compare
One idea I had was to put something like a
Sounds good, I added a test like this. |
…lver::resolveExprToType() (llvm#164353) Fixes the performance regression reported at llvm#156282 (comment)
…lver::resolveExprToType() (llvm#164353) Fixes the performance regression reported at llvm#156282 (comment)
Fixes the performance regression reported at #156282 (comment)