diff --git a/lld/MachO/InputFiles.cpp b/lld/MachO/InputFiles.cpp
--- a/lld/MachO/InputFiles.cpp
+++ b/lld/MachO/InputFiles.cpp
@@ -576,9 +576,9 @@
   if (currentTopLevelTapi) {
     for (InterfaceFile &child :
          make_pointee_range(currentTopLevelTapi->documents())) {
+      assert(child.documents().empty());
       if (path == child.getInstallName())
         return make<DylibFile>(child, umbrella);
-      assert(child.documents().empty());
     }
   }
 
diff --git a/lld/test/MachO/Inputs/MacOSX.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation.tbd b/lld/test/MachO/Inputs/MacOSX.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation.tbd
--- a/lld/test/MachO/Inputs/MacOSX.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation.tbd
+++ b/lld/test/MachO/Inputs/MacOSX.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation.tbd
@@ -11,3 +11,4 @@
     objc-classes:  [ NSObject ]
     objc-ivars:    [ NSConstantArray._count ]
     objc-eh-types: [ NSException ]
+...
diff --git a/lld/test/MachO/Inputs/iPhoneSimulator.sdk/usr/lib/libSystem.tbd b/lld/test/MachO/Inputs/iPhoneSimulator.sdk/usr/lib/libSystem.tbd
--- a/lld/test/MachO/Inputs/iPhoneSimulator.sdk/usr/lib/libSystem.tbd
+++ b/lld/test/MachO/Inputs/iPhoneSimulator.sdk/usr/lib/libSystem.tbd
@@ -6,7 +6,7 @@
 current-version:  1281
 exports:
   - archs:      [ i386, x86_64 ]
-    re-exports: [ '/usr/lib/system/libcache.dylib', ]
+    re-exports: [ '/usr/lib/system/libcache.dylib' ]
     symbols:    [ __crashreporter_info__, _cache_create ]
 --- !tapi-tbd-v3
 archs:            [ i386, x86_64 ]
diff --git a/lld/test/MachO/Inputs/iPhoneSimulator.sdk/usr/lib/libReexportSystem.tbd b/lld/test/MachO/Inputs/libReexportSystem.tbd
rename from lld/test/MachO/Inputs/iPhoneSimulator.sdk/usr/lib/libReexportSystem.tbd
rename to lld/test/MachO/Inputs/libReexportSystem.tbd
--- a/lld/test/MachO/Inputs/iPhoneSimulator.sdk/usr/lib/libReexportSystem.tbd
+++ b/lld/test/MachO/Inputs/libReexportSystem.tbd
@@ -1,10 +1,9 @@
 --- !tapi-tbd-v3
 archs:            [ i386, x86_64 ]
 uuids:            [ 'i386: 00000000-0000-0000-0000-000000000000', 'x86_64: 00000000-0000-0000-0000-000000000001' ]
-platform:         ios
+platform:         macosx
 install-name:     '/usr/lib/libReexportSystem.dylib'
 exports:
   - archs:      [ i386, x86_64 ]
-    re-exports: [ '/usr/lib/libSystem' ]
-    symbols:    [ __crashreporter_info__, _cache_create ]
-
+    re-exports: [ '/usr/lib/libSystem.dylib' ]
+...
diff --git a/lld/test/MachO/reexport-nested-lib.s b/lld/test/MachO/reexport-nested-lib.s
deleted file mode 100644
--- a/lld/test/MachO/reexport-nested-lib.s
+++ /dev/null
@@ -1,28 +0,0 @@
-# REQUIRES: x86
-#
-# This tests that we can reference symbols from a dylib,
-# re-exported by a top-level tapi document, which itself is
-# re-exported by another top-level tapi document.
-#
-# RUN: rm -rf %t; mkdir -p %t
-# RUN: llvm-mc -filetype obj -triple x86_64-apple-darwin %s -o %t/test.o
-# RUN: %lld -o %t/test -syslibroot %S/Inputs/iPhoneSimulator.sdk -lReexportSystem %t/test.o
-# RUN: llvm-objdump %t/test --macho --bind %t/test | FileCheck %s
-
-# CHECK: segment  section   address            type        addend  dylib               symbol
-# CHECK: __DATA   __data    0x{{[0-9a-f]*}}    pointer     0       libReexportSystem __crashreporter_info__
-# CHECK: __DATA   __data    0x{{[0-9a-f]*}}    pointer     0       libReexportSystem _cache_create
-
-.text
-.globl _main
-
-_main:
-  ret
-
-.data
-// This symbol is from libSystem, which is re-exported by libReexportSystem.
-// Reference it here to verify that it is visible.
-.quad __crashreporter_info__
-
-// This symbol is from /usr/lib/system/libcache.dylib, which is re-exported in libSystem.
-.quad _cache_create
diff --git a/lld/test/MachO/stub-link.s b/lld/test/MachO/stub-link.s
--- a/lld/test/MachO/stub-link.s
+++ b/lld/test/MachO/stub-link.s
@@ -3,10 +3,16 @@
 # RUN: mkdir -p %t
 #
 # RUN: llvm-mc -filetype obj -triple x86_64-apple-darwin %s -o %t/test.o
+
 # RUN: %lld -o %t/test -lSystem -lc++ -framework CoreFoundation %t/test.o
-#
 # RUN: llvm-objdump --bind --no-show-raw-insn -d -r %t/test | FileCheck %s
 
+## libReexportSystem.tbd tests that we can reference symbols from a dylib,
+## re-exported by a top-level tapi document, which itself is re-exported by
+## another top-level tapi document.
+# RUN: %lld -o %t/with-reexport %S/Inputs/libReexportSystem.tbd -lc++ -framework CoreFoundation %t/test.o
+# RUN: llvm-objdump --bind --no-show-raw-insn -d -r %t/with-reexport | FileCheck %s
+
 # CHECK: Disassembly of section __TEXT,__text:
 # CHECK: movq {{.*}} # [[ADDR:[0-9a-f]+]]
 
@@ -21,6 +27,9 @@
 # RUN: llvm-objdump --macho --all-headers %t/test | \
 # RUN:     FileCheck --check-prefix=LOAD %s
 
+# RUN: llvm-objdump --macho --all-headers %t/with-reexport | \
+# RUN:     FileCheck --check-prefixes=LOAD,LOAD-REEXPORT %s
+
 # LOAD:          cmd LC_LOAD_DYLIB
 # LOAD-NEXT:               cmdsize
 # LOAD-NEXT:                  name /usr/lib/libSystem.dylib
@@ -28,6 +37,13 @@
 # LOAD-NEXT:       current version 1.1.1
 # LOAD-NEXT: compatibility version
 
+# LOAD-REEXPORT:          cmd LC_LOAD_DYLIB
+# LOAD-REEXPORT-NEXT:               cmdsize
+# LOAD-REEXPORT-NEXT:                  name /usr/lib/libReexportSystem.dylib
+# LOAD-REEXPORT-NEXT:            time stamp
+# LOAD-REEXPORT-NEXT:       current version 1.0.0
+# LOAD-REEXPORT-NEXT: compatibility version
+
 .section __TEXT,__text
 .global _main