@@ -163,13 +163,12 @@ const Type *getPointeeType(const Type *T) {
163
163
}
164
164
165
165
// Forward declaration, needed as this function is mutually recursive
166
- // with resolveDependentExprToDecls .
167
- const Type *resolveDependentExprToType (const Expr *E);
166
+ // with resolveExprToDecls .
167
+ const Type *resolveExprToType (const Expr *E);
168
168
169
- // Try to heuristically resolve a dependent expression `E` to one
169
+ // Try to heuristically resolve a possibly- dependent expression `E` to one
170
170
// or more declarations that it likely references.
171
- std::vector<const NamedDecl *> resolveDependentExprToDecls (const Expr *E) {
172
- assert (E->isTypeDependent ());
171
+ std::vector<const NamedDecl *> resolveExprToDecls (const Expr *E) {
173
172
if (const auto *ME = dyn_cast<CXXDependentScopeMemberExpr>(E)) {
174
173
const Type *BaseType = ME->getBaseType ().getTypePtrOrNull ();
175
174
if (ME->isArrow ()) {
@@ -183,7 +182,7 @@ std::vector<const NamedDecl *> resolveDependentExprToDecls(const Expr *E) {
183
182
// can get further by analyzing the depedent expression.
184
183
Expr *Base = ME->isImplicitAccess () ? nullptr : ME->getBase ();
185
184
if (Base && BT->getKind () == BuiltinType::Dependent) {
186
- BaseType = resolveDependentExprToType (Base);
185
+ BaseType = resolveExprToType (Base);
187
186
}
188
187
}
189
188
return getMembersReferencedViaDependentName (
@@ -197,7 +196,7 @@ std::vector<const NamedDecl *> resolveDependentExprToDecls(const Expr *E) {
197
196
/* IsNonstaticMember=*/ false );
198
197
}
199
198
if (const auto *CE = dyn_cast<CallExpr>(E)) {
200
- const auto *CalleeType = resolveDependentExprToType (CE->getCallee ());
199
+ const auto *CalleeType = resolveExprToType (CE->getCallee ());
201
200
if (!CalleeType)
202
201
return {};
203
202
if (const auto *FnTypePtr = CalleeType->getAs <PointerType>())
@@ -209,15 +208,16 @@ std::vector<const NamedDecl *> resolveDependentExprToDecls(const Expr *E) {
209
208
}
210
209
}
211
210
}
212
- if (const auto *ME = dyn_cast<MemberExpr>(E)) {
211
+ if (const auto *ME = dyn_cast<MemberExpr>(E))
213
212
return {ME->getMemberDecl ()};
214
- }
213
+ if (const auto *DRE = dyn_cast<DeclRefExpr>(E))
214
+ return {DRE->getFoundDecl ()};
215
215
return {};
216
216
}
217
217
218
- // Try to heuristically resolve the type of a dependent expression `E`.
219
- const Type *resolveDependentExprToType (const Expr *E) {
220
- std::vector<const NamedDecl *> Decls = resolveDependentExprToDecls (E);
218
+ // Try to heuristically resolve the type of a possibly- dependent expression `E`.
219
+ const Type *resolveExprToType (const Expr *E) {
220
+ std::vector<const NamedDecl *> Decls = resolveExprToDecls (E);
221
221
if (Decls.size () != 1 ) // Names an overload set -- just bail.
222
222
return nullptr ;
223
223
if (const auto *TD = dyn_cast<TypeDecl>(Decls[0 ])) {
@@ -426,12 +426,12 @@ struct TargetFinder {
426
426
}
427
427
void
428
428
VisitCXXDependentScopeMemberExpr (const CXXDependentScopeMemberExpr *E) {
429
- for (const NamedDecl *D : resolveDependentExprToDecls (E)) {
429
+ for (const NamedDecl *D : resolveExprToDecls (E)) {
430
430
Outer.add (D, Flags);
431
431
}
432
432
}
433
433
void VisitDependentScopeDeclRefExpr (const DependentScopeDeclRefExpr *E) {
434
- for (const NamedDecl *D : resolveDependentExprToDecls (E)) {
434
+ for (const NamedDecl *D : resolveExprToDecls (E)) {
435
435
Outer.add (D, Flags);
436
436
}
437
437
}
0 commit comments