Revamp our representation of C++ nested-name-specifiers. We now have a
uniqued representation that should both save some memory and make it
far easier to properly build canonical types for types involving
dependent nested-name-specifiers, e.g., "typename T::Nested::type".
This approach will greatly simplify the representation of
CXXScopeSpec. That'll be next.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67799 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp
index cb44cfc..bb306e4 100644
--- a/lib/Sema/SemaDeclCXX.cpp
+++ b/lib/Sema/SemaDeclCXX.cpp
@@ -1159,9 +1159,13 @@
/// Method declaration as if we had just parsed the qualified method
/// name. However, it should not bring the parameters into scope;
/// that will be performed by ActOnDelayedCXXMethodParameter.
-void Sema::ActOnStartDelayedCXXMethodDeclaration(Scope *S, DeclTy *Method) {
+void Sema::ActOnStartDelayedCXXMethodDeclaration(Scope *S, DeclTy *MethodD) {
CXXScopeSpec SS;
- SS.setScopeRep(((FunctionDecl*)Method)->getDeclContext());
+ FunctionDecl *Method = (FunctionDecl*)MethodD;
+ QualType ClassTy
+ = Context.getTypeDeclType(cast<RecordDecl>(Method->getDeclContext()));
+ SS.setScopeRep(
+ NestedNameSpecifier::Create(Context, 0, false, ClassTy.getTypePtr()));
ActOnCXXEnterDeclaratorScope(S, SS);
}
@@ -1192,7 +1196,10 @@
void Sema::ActOnFinishDelayedCXXMethodDeclaration(Scope *S, DeclTy *MethodD) {
FunctionDecl *Method = (FunctionDecl*)MethodD;
CXXScopeSpec SS;
- SS.setScopeRep(Method->getDeclContext());
+ QualType ClassTy
+ = Context.getTypeDeclType(cast<RecordDecl>(Method->getDeclContext()));
+ SS.setScopeRep(
+ NestedNameSpecifier::Create(Context, 0, false, ClassTy.getTypePtr()));
ActOnCXXExitDeclaratorScope(S, SS);
// Now that we have our default arguments, check the constructor