[PATCH] Allow more lookup of types in dependent base classes
Richard Smith
richard at metafoo.co.uk
Fri Jun 27 08:17:46 PDT 2014
================
Comment at: lib/Sema/SemaDecl.cpp:139-141
@@ +138,5 @@
+ for (const auto &Base : RD->bases()) {
+ auto *TST = Base.getType()->getAs<TemplateSpecializationType>();
+ if (!TST)
+ continue;
+ auto *TD = TST->getTemplateName().getAsTemplateDecl();
----------------
It'd be nice to also handle deriving from `A<T>::B`, and so on.
================
Comment at: lib/Sema/SemaDecl.cpp:259-268
@@ -212,1 +258,12 @@
+ // For unqualified lookup in a class template in MSVC mode, look into
+ // dependent base classes where the primary class template is known.
+ if (Result.empty() && getLangOpts().MSVCCompat && (!SS || SS->isEmpty())) {
+ auto *RD = dyn_cast<CXXRecordDecl>(CurContext);
+ if (RD && RD->getDescribedClassTemplate()) {
+ ParsedType TypeInBase =
+ recoverFromTypeInKnownDependentBase(*this, RD, II, NameLoc);
+ if (TypeInBase)
+ return TypeInBase;
+ }
+ }
}
----------------
I suspect you'll also need to do something like this in `ClassifyName`.
================
Comment at: lib/Sema/SemaDecl.cpp:261-262
@@ +260,4 @@
+ if (Result.empty() && getLangOpts().MSVCCompat && (!SS || SS->isEmpty())) {
+ auto *RD = dyn_cast<CXXRecordDecl>(CurContext);
+ if (RD && RD->getDescribedClassTemplate()) {
+ ParsedType TypeInBase =
----------------
This seems rather specific. I suppose we don't need to worry much about function contexts, because we'll delay-parse most of those, but what about the cases where we don't (`auto` return type, `constexpr` functions) and nested classes of class templates? Is it feasible to walk upwards until we see a class template, if we're in a dependent context?
Also, what about a class template within another class template? Should we look in dependent base classes of both?
http://reviews.llvm.org/D4237
More information about the cfe-commits
mailing list