Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions clang-tools-extra/clangd/unittests/RenameTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2488,6 +2488,7 @@ TEST(CrossFileRenameTests, adjustmentCost) {
T.ExpectedCost);
}
}

} // namespace
} // namespace clangd
} // namespace clang
21 changes: 6 additions & 15 deletions clang/lib/Sema/HeuristicResolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include "clang/AST/TemplateBase.h"
#include "clang/AST/Type.h"
#include "llvm/ADT/identity.h"
#include <optional>

namespace clang {

Expand Down Expand Up @@ -256,17 +255,17 @@ QualType HeuristicResolverImpl::simplifyType(QualType Type, const Expr *E,
}
}
}
// check if member expr is in the context of an explicit object method
// Check if the expression refers to an explicit object parameter of
// templated type. If so, heuristically treat it as having the type of the
// enclosing class.
if (!T.Type.isNull() &&
(T.Type->isUndeducedAutoType() || T.Type->isTemplateTypeParmType())) {
if (auto *DRE = dyn_cast_if_present<DeclRefExpr>(T.E)) {
auto *PrDecl = dyn_cast_if_present<ParmVarDecl>(DRE->getDecl());
// Then the type of 'this' should be type of the record the method is
// defined in
auto *PrDecl = dyn_cast<ParmVarDecl>(DRE->getDecl());
if (PrDecl && PrDecl->isExplicitObjectParameter()) {
const auto *Parent =
dyn_cast<TypeDecl>(PrDecl->getDeclContext()->getParent());
return {Ctx.getTypeDeclType(Parent)};
dyn_cast<TagDecl>(PrDecl->getDeclContext()->getParent());
return {Ctx.getCanonicalTagType(Parent)};
}
}
}
Expand Down Expand Up @@ -321,14 +320,6 @@ std::vector<const NamedDecl *> HeuristicResolverImpl::resolveMemberExpr(
Expr *Base = ME->isImplicitAccess() ? nullptr : ME->getBase();
QualType BaseType = ME->getBaseType();
BaseType = simplifyType(BaseType, Base, ME->isArrow());

// fflush(stdout);
// fflush(stderr);
// std::flush(std::cout);
// std::flush(std::cerr);
// using namespace std::chrono_literals;
// std::this_thread::sleep_for(10ms);

return resolveDependentMember(BaseType, ME->getMember(), NoFilter);
}

Expand Down
2 changes: 1 addition & 1 deletion clang/unittests/Sema/HeuristicResolverTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ template <typename InputNode, typename ParamT, typename InputMatcher,
typename... OutputMatchers>
void expectResolution(llvm::StringRef Code, ResolveFnT<ParamT> ResolveFn,
const InputMatcher &IM, const OutputMatchers &...OMS) {
auto TU = tooling::buildASTFromCodeWithArgs(Code, {"-std=c++23"});
auto TU = tooling::buildASTFromCodeWithArgs(Code, {"-std=c++20"});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change (from c++20 to c++23) should be kept.

(It looks like the this auto test case manages to pass even without it, but that looks like a bug in the test suite; code with error diagnostics should cause the test to fail.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh whoops, done

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(It looks like the this auto test case manages to pass even without it, but that looks like a bug in the test suite; code with error diagnostics should cause the test to fail.)

(Filed #155545 for this.)

auto &Ctx = TU->getASTContext();
auto InputMatches = match(IM, Ctx);
ASSERT_EQ(1u, InputMatches.size());
Expand Down