Repository: apple/swift
File: lib/ClangImporter/ImportDecl.cpp (C++)

Code before:
        // Record of all member names, even those we don't/fail to import,
        // so that we can avoid synthesizing properties with name clashes.
        // See also: CXXMethodBridging
        if (nd->getDeclName().isIdentifier())
          allMemberNames.insert(nd->getName());

        if (Impl.SwiftContext.LangOpts.hasFeature(
                Feature::ImportCxxMembersLazily) &&
            !shouldEagerlyImportClangRecordMember(nd))
          continue;

        Decl *member = Impl.importDecl(nd, getActiveSwiftVersion());

        if (!member) {
          if (!isa<clang::TypeDecl>(nd) && !isa<clang::FunctionDecl>(nd) &&
              !isa<clang::TypeAliasTemplateDecl>(nd) &&
              !isa<clang::FunctionTemplateDecl>(nd)) {
            // We don't know what this member is.
            // Assume it may be important in C.
            hasUnreferenceableStorage = true;
            hasMemberwiseInitializer = false;
          }
          continue;
        }

        if (isa<TypeDecl>(member)) {
          // TODO: we have a problem lazily looking up unnamed members, so we
          // add them here.
          if (isa<clang::RecordDecl>(nd) &&
              !cast<clang::RecordDecl>(nd)->hasNameForLinkage())
            result->addMemberToLookupTable(member);
          continue;
        }

        if (auto CD = dyn_cast<ConstructorDecl>(member)) {
          ctors.push_back(CD);
          continue;
        }

        if (auto MD = dyn_cast<FuncDecl>(member)) {
          methods.push_back(MD);
          continue;
        }

        if (isa<VarDecl>(member) && isa<clang::CXXMethodDecl>(nd)) {
          result->addMember(member);
          continue;
        }

        auto *vd = cast<VarDecl>(member);
        auto getFieldDecl =

Review comment (suggestion):
Apologies for the late post-review. But can't this be simplified to just something like:

```suggestion
          if (auto varDecl = dyn_cast<clang::VarDecl>(nd);
              varDecl && !varDecl->isStaticDataMember()) {
            // Could not import this non-static field, meaning
            // this record contains storage not directly
            // accessible from Swift
            hasUnreferenceableStorage = true;
            hasMemberwiseInitializer = false;
          }
```

Code after:
        // Record of all member names, even those we don't/fail to import,
        // so that we can avoid synthesizing properties with name clashes.
        // See also: CXXMethodBridging
        if (nd->getDeclName().isIdentifier())
          allMemberNames.insert(nd->getName());

        if (Impl.SwiftContext.LangOpts.hasFeature(
                Feature::ImportCxxMembersLazily) &&
            !shouldEagerlyImportClangRecordMember(nd))
          continue;

        Decl *member = Impl.importDecl(nd, getActiveSwiftVersion());

        if (!member) {
          if (!isa<clang::TypeDecl>(nd) && !isa<clang::FunctionDecl>(nd) &&
              !isa<clang::TypeAliasTemplateDecl>(nd) &&
              !isa<clang::FunctionTemplateDecl>(nd)) {
            auto varDecl = dyn_cast<clang::VarDecl>(nd);
            // Static fields don't affect the memberwise initializer.
            if (!(varDecl && varDecl->isStaticDataMember())) {
              // We don't know what this member is.
              // Assume it may be important in C.
              hasUnreferenceableStorage = true;
              hasMemberwiseInitializer = false;
            }
          }
          continue;
        }

        if (isa<TypeDecl>(member)) {
          // TODO: we have a problem lazily looking up unnamed members, so we
          // add them here.
          if (isa<clang::RecordDecl>(nd) &&
              !cast<clang::RecordDecl>(nd)->hasNameForLinkage())
            result->addMemberToLookupTable(member);
          continue;
        }

        if (auto CD = dyn_cast<ConstructorDecl>(member)) {
          ctors.push_back(CD);
          continue;
        }

        if (auto MD = dyn_cast<FuncDecl>(member)) {
          methods.push_back(MD);
          continue;
        }

        if (isa<VarDecl>(member) && isa<clang::CXXMethodDecl>(nd)) {
          result->addMember(member);
          continue;