MS ABI: Delay default constructor closure checking until the outermost class scope ends

Previously, we would error out on this code because the default argument
wasn't parsed until the end of Outer:

  struct __declspec(dllexport) Outer {
    struct __declspec(dllexport) Inner {
      Inner(void *p = 0);
    };
  };

Now we do the checking on the closing brace of Outer instead of Inner.

llvm-svn: 232519
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 01bd42c..32e3924 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -12067,24 +12067,6 @@
          "Broken injected-class-name");
 }
 
-static void getDefaultArgExprsForConstructors(Sema &S, CXXRecordDecl *Class) {
-  for (Decl *Member : Class->decls()) {
-    auto *CD = dyn_cast<CXXConstructorDecl>(Member);
-    if (!CD || !CD->isDefaultConstructor() || !CD->hasAttr<DLLExportAttr>())
-      continue;
-
-    for (unsigned I = 0, E = CD->getNumParams(); I != E; ++I) {
-      // Skip any default arguments that we've already instantiated.
-      if (S.Context.getDefaultArgExprForConstructor(CD, I))
-        continue;
-
-      Expr *DefaultArg = S.BuildCXXDefaultArgExpr(Class->getLocation(), CD,
-                                                  CD->getParamDecl(I)).get();
-      S.Context.addDefaultArgExprForConstructor(CD, I, DefaultArg);
-    }
-  }
-}
-
 void Sema::ActOnTagFinishDefinition(Scope *S, Decl *TagD,
                                     SourceLocation RBraceLoc) {
   AdjustDeclIfTemplate(TagD);
@@ -12098,17 +12080,9 @@
       RD->completeDefinition();
   }
 
-  if (auto *Class = dyn_cast<CXXRecordDecl>(Tag)) {
+  if (isa<CXXRecordDecl>(Tag))
     FieldCollector->FinishClass();
 
-    // Default constructors that are annotated with __declspec(dllexport) which
-    // have default arguments or don't use the standard calling convention are
-    // wrapped with a thunk called the default constructor closure.
-    if (!Class->getDescribedClassTemplate() &&
-        Context.getTargetInfo().getCXXABI().isMicrosoft())
-      getDefaultArgExprsForConstructors(*this, Class);
-  }
-
   // Exit this scope of this tag's definition.
   PopDeclContext();