Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions clang/lib/Sema/HeuristicResolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())) {
Expand Down
22 changes: 22 additions & 0 deletions clang/unittests/Sema/HeuristicResolverTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,28 @@ TEST(HeuristicResolver, MemberExpr_HangIssue126536) {
cxxDependentScopeMemberExpr(hasMemberName("foo")).bind("input"));
}

TEST(HeuristicResolver, MemberExpr_HangOnLongCallChain) {
const size_t CallChainLength = 50;
std::string Code = R"cpp(
template <typename T>
void foo(T t) {
t
)cpp";
for (size_t I = 0; I < CallChainLength; ++I)
Code.append(".method()\n");
Code.append(R"cpp(
.lastMethod();
}
)cpp");
// Test that resolution of a name whose base is a long call chain
// does not hang. Note that the hang for which this is a regression
// test is finite (exponential runtime in the length of the chain),
// so a "failure" here manifests as abnormally long runtime.
expectResolution(
Code, &HeuristicResolver::resolveMemberExpr,
cxxDependentScopeMemberExpr(hasMemberName("lastMethod")).bind("input"));
}

TEST(HeuristicResolver, MemberExpr_DefaultTemplateArgument) {
std::string Code = R"cpp(
struct Default {
Expand Down
Loading