llvm/clang/test/InstallAPI/hiddens.test

// RUN: rm -rf %t
// RUN: split-file %s %t
// RUN: sed -e "s|DSTROOT|%/t|g" %t/inputs.json.in > %t/inputs.json

// RUN: yaml2obj %t/Hidden.yaml -o %t/System/Library/Frameworks/Hidden.framework/Hidden

// RUN: clang-installapi --target=x86_64-apple-macos13 -x objective-c \
// RUN: -F %t/System/Library/Frameworks \
// RUN: -install_name /System/Library/Frameworks/Hidden.framework/Versions/A/Hidden\
// RUN: -current_version 1 -compatibility_version 1 %t/inputs.json \
// RUN: --verify-against=%t/System/Library/Frameworks/Hidden.framework/Hidden \
// RUN: --verify-mode=Pedantic -o %t/output.tbd 2>&1 | FileCheck %s 

// CHECK-NOT: error
// CHECK:  warning: use of __private_extern__ 

// RUN: llvm-readtapi --compare %t/output.tbd %t/expected.tbd 

//--- inputs.json.in
{
  "headers": [ {
    "path" : "DSTROOT/System/Library/Frameworks/Hidden.framework/Headers/Hidden.h",
    "type" : "public"
  }
  ],
  "version": "3"
}

//--- System/Library/Frameworks/Hidden.framework/Headers/Hidden.h
__private_extern__ int foo(); // Clang doesn't warn on this, but should.
__private_extern__ int baz;
__attribute__((visibility("hidden"))) int bar();

/// Created from: 
/// #import "Hidden.h" int foo(void) { return 1; } int bar(void) { return 1; }
//--- Hidden.yaml
--- !mach-o
FileHeader:
  magic:           0xFEEDFACF
  cputype:         0x1000007
  cpusubtype:      0x3
  filetype:        0x6
  ncmds:           12
  sizeofcmds:      920
  flags:           0x100085
  reserved:        0x0
LoadCommands:
  - cmd:             LC_SEGMENT_64
    cmdsize:         312
    segname:         __TEXT
    vmaddr:          0
    vmsize:          8192
    fileoff:         0
    filesize:        8192
    maxprot:         5
    initprot:        5
    nsects:          3
    flags:           0
    Sections:
      - sectname:        __text
        segname:         __TEXT
        addr:            0xBB8
        size:            22
        offset:          0xBB8
        align:           0
        reloff:          0x0
        nreloc:          0
        flags:           0x80000400
        reserved1:       0x0
        reserved2:       0x0
        reserved3:       0x0
        content:         554889E5B8010000005DC3554889E5B8010000005DC3
      - sectname:        __unwind_info
        segname:         __TEXT
        addr:            0xBD0
        size:            4152
        offset:          0xBD0
        align:           2
        reloff:          0x0
        nreloc:          0
        flags:           0x0
        reserved1:       0x0
        reserved2:       0x0
        reserved3:       0x0
        content:         010000001C000000010000002000000000000000200000000200000000000001B80B00003800000038000000CE0B00000000000038000000030000000C0001001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
      - sectname:        __eh_frame
        segname:         __TEXT
        addr:            0x1C08
        size:            24
        offset:          0x1C08
        align:           3
        reloff:          0x0
        nreloc:          0
        flags:           0x6000000B
        reserved1:       0x0
        reserved2:       0x0
        reserved3:       0x0
        content:         1400000000000000017A520001781001100C070890010000
  - cmd:             LC_SEGMENT_64
    cmdsize:         152
    segname:         __DATA_CONST
    vmaddr:          8192
    vmsize:          4096
    fileoff:         8192
    filesize:        4096
    maxprot:         3
    initprot:        3
    nsects:          1
    flags:           16
    Sections:
      - sectname:        __objc_imageinfo
        segname:         __DATA_CONST
        addr:            0x2000
        size:            8
        offset:          0x2000
        align:           0
        reloff:          0x0
        nreloc:          0
        flags:           0x0
        reserved1:       0x0
        reserved2:       0x0
        reserved3:       0x0
        content:         '0000000040000000'
  - cmd:             LC_SEGMENT_64
    cmdsize:         72
    segname:         __LINKEDIT
    vmaddr:          12288
    vmsize:          104
    fileoff:         12288
    filesize:        104
    maxprot:         1
    initprot:        1
    nsects:          0
    flags:           0
  - cmd:             LC_DYLD_INFO_ONLY
    cmdsize:         48
    rebase_off:      0
    rebase_size:     0
    bind_off:        0
    bind_size:       0
    weak_bind_off:   0
    weak_bind_size:  0
    lazy_bind_off:   0
    lazy_bind_size:  0
    export_off:      12288
    export_size:     16
  - cmd:             LC_SYMTAB
    cmdsize:         24
    symoff:          12312
    nsyms:           3
    stroff:          12360
    strsize:         32
  - cmd:             LC_DYSYMTAB
    cmdsize:         80
    ilocalsym:       0
    nlocalsym:       1
    iextdefsym:      1
    nextdefsym:      1
    iundefsym:       2
    nundefsym:       1
    tocoff:          0
    ntoc:            0
    modtaboff:       0
    nmodtab:         0
    extrefsymoff:    0
    nextrefsyms:     0
    indirectsymoff:  0
    nindirectsyms:   0
    extreloff:       0
    nextrel:         0
    locreloff:       0
    nlocrel:         0
  - cmd:             LC_ID_DYLIB
    cmdsize:         88
    dylib:
      name:            24
      timestamp:       0
      current_version: 65536
      compatibility_version: 65536
    Content:         '/System/Library/Frameworks/Hidden.framework/Versions/A/Hidden'
    ZeroPadBytes:    3
  - cmd:             LC_UUID
    cmdsize:         24
    uuid:            4C4C44E7-5555-3144-A133-0271E799C487
  - cmd:             LC_BUILD_VERSION
    cmdsize:         32
    platform:        1
    minos:           851968
    sdk:             983040
    ntools:          1
    Tools:
      - tool:            4
        version:         1245184
  - cmd:             LC_LOAD_DYLIB
    cmdsize:         56
    dylib:
      name:            24
      timestamp:       0
      current_version: 88473600
      compatibility_version: 65536
    Content:         '/usr/lib/libSystem.B.dylib'
    ZeroPadBytes:    6
  - cmd:             LC_FUNCTION_STARTS
    cmdsize:         16
    dataoff:         12304
    datasize:        8
  - cmd:             LC_DATA_IN_CODE
    cmdsize:         16
    dataoff:         12312
    datasize:        0
LinkEditData:
  ExportTrie:
    TerminalSize:    0
    NodeOffset:      0
    Name:            ''
    Flags:           0x0
    Address:         0x0
    Other:           0x0
    ImportName:      ''
    Children:
      - TerminalSize:    3
        NodeOffset:      8
        Name:            _foo
        Flags:           0x0
        Address:         0xBB8
        Other:           0x0
        ImportName:      ''
  NameList:
    - n_strx:          7
      n_type:          0x1E
      n_sect:          1
      n_desc:          0
      n_value:         3011
    - n_strx:          2
      n_type:          0xF
      n_sect:          1
      n_desc:          0
      n_value:         3000
    - n_strx:          12
      n_type:          0x1
      n_sect:          0
      n_desc:          256
      n_value:         0
  StringTable:
    - ' '
    - _foo
    - _bar
    - dyld_stub_binder
    - ''
    - ''
    - ''
  FunctionStarts:  [ 0xBB8, 0xBC3 ]
...

//--- expected.tbd
--- !tapi-tbd
tbd-version:     4
targets:         [ x86_64-macos ]
flags:           [ not_app_extension_safe ]
install-name:    '/System/Library/Frameworks/Hidden.framework/Versions/A/Hidden'
...