Skip to content

Commit b48fa0e

Browse files
committed
code review + misc cleanup
1 parent bf73e27 commit b48fa0e

File tree

3 files changed

+8
-16
lines changed

3 files changed

+8
-16
lines changed

clang-tools-extra/clangd/unittests/RenameTests.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2488,6 +2488,7 @@ TEST(CrossFileRenameTests, adjustmentCost) {
24882488
T.ExpectedCost);
24892489
}
24902490
}
2491+
24912492
} // namespace
24922493
} // namespace clangd
24932494
} // namespace clang

clang/lib/Sema/HeuristicResolver.cpp

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#include "clang/AST/TemplateBase.h"
1515
#include "clang/AST/Type.h"
1616
#include "llvm/ADT/identity.h"
17-
#include <optional>
1817

1918
namespace clang {
2019

@@ -256,17 +255,17 @@ QualType HeuristicResolverImpl::simplifyType(QualType Type, const Expr *E,
256255
}
257256
}
258257
}
259-
// check if member expr is in the context of an explicit object method
258+
// Check if the expression refers to an explicit object parameter of
259+
// templated type. If so, heuristically treat it as having the type of the
260+
// enclosing class.
260261
if (!T.Type.isNull() &&
261262
(T.Type->isUndeducedAutoType() || T.Type->isTemplateTypeParmType())) {
262263
if (auto *DRE = dyn_cast_if_present<DeclRefExpr>(T.E)) {
263-
auto *PrDecl = dyn_cast_if_present<ParmVarDecl>(DRE->getDecl());
264-
// Then the type of 'this' should be type of the record the method is
265-
// defined in
264+
auto *PrDecl = dyn_cast<ParmVarDecl>(DRE->getDecl());
266265
if (PrDecl && PrDecl->isExplicitObjectParameter()) {
267266
const auto *Parent =
268-
dyn_cast<TypeDecl>(PrDecl->getDeclContext()->getParent());
269-
return {Ctx.getTypeDeclType(Parent)};
267+
dyn_cast<TagDecl>(PrDecl->getDeclContext()->getParent());
268+
return {Ctx.getCanonicalTagType(Parent)};
270269
}
271270
}
272271
}
@@ -321,14 +320,6 @@ std::vector<const NamedDecl *> HeuristicResolverImpl::resolveMemberExpr(
321320
Expr *Base = ME->isImplicitAccess() ? nullptr : ME->getBase();
322321
QualType BaseType = ME->getBaseType();
323322
BaseType = simplifyType(BaseType, Base, ME->isArrow());
324-
325-
// fflush(stdout);
326-
// fflush(stderr);
327-
// std::flush(std::cout);
328-
// std::flush(std::cerr);
329-
// using namespace std::chrono_literals;
330-
// std::this_thread::sleep_for(10ms);
331-
332323
return resolveDependentMember(BaseType, ME->getMember(), NoFilter);
333324
}
334325

clang/unittests/Sema/HeuristicResolverTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ template <typename InputNode, typename ParamT, typename InputMatcher,
4141
typename... OutputMatchers>
4242
void expectResolution(llvm::StringRef Code, ResolveFnT<ParamT> ResolveFn,
4343
const InputMatcher &IM, const OutputMatchers &...OMS) {
44-
auto TU = tooling::buildASTFromCodeWithArgs(Code, {"-std=c++23"});
44+
auto TU = tooling::buildASTFromCodeWithArgs(Code, {"-std=c++20"});
4545
auto &Ctx = TU->getASTContext();
4646
auto InputMatches = match(IM, Ctx);
4747
ASSERT_EQ(1u, InputMatches.size());

0 commit comments

Comments
 (0)