|
14 | 14 | #include "clang/AST/TemplateBase.h" |
15 | 15 | #include "clang/AST/Type.h" |
16 | 16 | #include "llvm/ADT/identity.h" |
17 | | -#include <optional> |
18 | 17 |
|
19 | 18 | namespace clang { |
20 | 19 |
|
@@ -256,17 +255,17 @@ QualType HeuristicResolverImpl::simplifyType(QualType Type, const Expr *E, |
256 | 255 | } |
257 | 256 | } |
258 | 257 | } |
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. |
260 | 261 | if (!T.Type.isNull() && |
261 | 262 | (T.Type->isUndeducedAutoType() || T.Type->isTemplateTypeParmType())) { |
262 | 263 | 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()); |
266 | 265 | if (PrDecl && PrDecl->isExplicitObjectParameter()) { |
267 | 266 | 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)}; |
270 | 269 | } |
271 | 270 | } |
272 | 271 | } |
@@ -321,14 +320,6 @@ std::vector<const NamedDecl *> HeuristicResolverImpl::resolveMemberExpr( |
321 | 320 | Expr *Base = ME->isImplicitAccess() ? nullptr : ME->getBase(); |
322 | 321 | QualType BaseType = ME->getBaseType(); |
323 | 322 | 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 | | - |
332 | 323 | return resolveDependentMember(BaseType, ME->getMember(), NoFilter); |
333 | 324 | } |
334 | 325 |
|
|
0 commit comments