diff --git a/llvm/lib/Support/YAMLTraits.cpp b/llvm/lib/Support/YAMLTraits.cpp --- a/llvm/lib/Support/YAMLTraits.cpp +++ b/llvm/lib/Support/YAMLTraits.cpp @@ -435,6 +435,11 @@ // Copy string to permanent storage KeyStr = StringStorage.str().copy(StringAllocator); } + if (mapHNode->Mapping.count(KeyStr)) + // From YAML spec: "The content of a mapping node is an unordered set of + // key/value node pairs, with the restriction that each of the keys is + // unique." + setError(KeyNode, Twine("duplicated mapping key '") + KeyStr); auto ValueHNode = createHNodes(Value); if (EC) break; diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/select-int-ext.mir b/llvm/test/CodeGen/AArch64/GlobalISel/select-int-ext.mir --- a/llvm/test/CodeGen/AArch64/GlobalISel/select-int-ext.mir +++ b/llvm/test/CodeGen/AArch64/GlobalISel/select-int-ext.mir @@ -128,7 +128,6 @@ --- name: anyext_v2s64_from_v2s32 alignment: 4 -tracksRegLiveness: true legalized: true regBankSelected: true tracksRegLiveness: true diff --git a/llvm/test/CodeGen/ARM/machine-sink-multidef.mir b/llvm/test/CodeGen/ARM/machine-sink-multidef.mir --- a/llvm/test/CodeGen/ARM/machine-sink-multidef.mir +++ b/llvm/test/CodeGen/ARM/machine-sink-multidef.mir @@ -40,7 +40,6 @@ liveins: - { reg: '$r0', virtual-reg: '%8' } - { reg: '$r1', virtual-reg: '%9' } -liveins: [] body: | ; CHECK-LABEL: name: g ; CHECK: bb.0: diff --git a/llvm/test/CodeGen/PowerPC/jump-tables-collapse-rotate-remove-SrcMI.mir b/llvm/test/CodeGen/PowerPC/jump-tables-collapse-rotate-remove-SrcMI.mir --- a/llvm/test/CodeGen/PowerPC/jump-tables-collapse-rotate-remove-SrcMI.mir +++ b/llvm/test/CodeGen/PowerPC/jump-tables-collapse-rotate-remove-SrcMI.mir @@ -31,7 +31,6 @@ frameInfo: maxAlignment: 1 machineFunctionInfo: {} -body: | body: | bb.0.entry: liveins: $x3, $x4 diff --git a/llvm/test/CodeGen/PowerPC/mi-peephole.mir b/llvm/test/CodeGen/PowerPC/mi-peephole.mir --- a/llvm/test/CodeGen/PowerPC/mi-peephole.mir +++ b/llvm/test/CodeGen/PowerPC/mi-peephole.mir @@ -15,7 +15,6 @@ frameInfo: maxAlignment: 1 machineFunctionInfo: {} -body: | body: | bb.0.entry: liveins: $x3, $x4 diff --git a/llvm/test/CodeGen/X86/fixup-bw-inst.mir b/llvm/test/CodeGen/X86/fixup-bw-inst.mir --- a/llvm/test/CodeGen/X86/fixup-bw-inst.mir +++ b/llvm/test/CodeGen/X86/fixup-bw-inst.mir @@ -139,7 +139,8 @@ alignment: 16 tracksRegLiveness: true liveins: - - { reg: '$ch', reg: '$bl' } + - { reg: '$ch' } + - { reg: '$bl' } body: | bb.0: liveins: $ch, $bl diff --git a/llvm/test/tools/llvm-objcopy/COFF/redefine-symbol.test b/llvm/test/tools/llvm-objcopy/COFF/redefine-symbol.test --- a/llvm/test/tools/llvm-objcopy/COFF/redefine-symbol.test +++ b/llvm/test/tools/llvm-objcopy/COFF/redefine-symbol.test @@ -39,7 +39,6 @@ - Name: .text Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] - Name: .rdata - Characteristics: [ ] Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ] symbols: - Name: .text diff --git a/llvm/test/tools/llvm-objcopy/ELF/strip-all-gnu.test b/llvm/test/tools/llvm-objcopy/ELF/strip-all-gnu.test --- a/llvm/test/tools/llvm-objcopy/ELF/strip-all-gnu.test +++ b/llvm/test/tools/llvm-objcopy/ELF/strip-all-gnu.test @@ -25,9 +25,8 @@ Type: SHT_STRTAB Flags: [ SHF_ALLOC ] - Name: .symtab.dyn - Type: SHT_SYMTAB - Flags: [ SHF_ALLOC ] Type: SHT_NOBITS + Flags: [ SHF_ALLOC ] - Name: .text Type: SHT_PROGBITS Flags: [ SHF_ALLOC, SHF_EXECINSTR ] diff --git a/llvm/test/tools/llvm-reduce/mir/preserve-func-info.mir b/llvm/test/tools/llvm-reduce/mir/preserve-func-info.mir --- a/llvm/test/tools/llvm-reduce/mir/preserve-func-info.mir +++ b/llvm/test/tools/llvm-reduce/mir/preserve-func-info.mir @@ -45,7 +45,6 @@ tracksDebugUserValues: true callsEHReturn: true callsUnwindInit: true -callsUnwindInit: true hasEHCatchret: true hasEHScopes: true hasEHFunclets: true diff --git a/llvm/test/tools/yaml2obj/map_duplicate_key.test b/llvm/test/tools/yaml2obj/map_duplicate_key.test new file mode 100644 --- /dev/null +++ b/llvm/test/tools/yaml2obj/map_duplicate_key.test @@ -0,0 +1,11 @@ +# RUN: not yaml2obj %s 2>&1 | FileCheck %s + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_REL + Type: ET_REL + ABIVersion: 0x05 + +# CHECK: error: duplicated mapping key 'Type diff --git a/llvm/test/tools/yaml2obj/map_duplicate_key_2.test b/llvm/test/tools/yaml2obj/map_duplicate_key_2.test new file mode 100644 --- /dev/null +++ b/llvm/test/tools/yaml2obj/map_duplicate_key_2.test @@ -0,0 +1,15 @@ +# RUN: not yaml2obj %s 2>&1 | FileCheck %s + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_REL + ABIVersion: 0x05 +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_REL + ABIVersion: 0x05 + +# CHECK: error: duplicated mapping key 'FileHeader diff --git a/llvm/unittests/Support/YAMLIOTest.cpp b/llvm/unittests/Support/YAMLIOTest.cpp --- a/llvm/unittests/Support/YAMLIOTest.cpp +++ b/llvm/unittests/Support/YAMLIOTest.cpp @@ -105,6 +105,18 @@ EXPECT_TRUE(!!yin.error()); } +// +// Test the reading of a map containing duplicated keys +// +TEST(YAMLIO, TestMapDuplicatedKeysRead) { + FooBar doc; + // YAML spec: "The content of a mapping node is an unordered set of key/value + // node pairs, with the restriction that each of the keys is unique." + Input yin("{foo: 3\n bar: 5\nfoo: 3}", nullptr, suppressErrorMessages); + yin >> doc; + EXPECT_TRUE(!!yin.error()); +} + // // Test the reading of a yaml sequence of mappings // diff --git a/llvm/unittests/TextAPI/TextStubV4Tests.cpp b/llvm/unittests/TextAPI/TextStubV4Tests.cpp --- a/llvm/unittests/TextAPI/TextStubV4Tests.cpp +++ b/llvm/unittests/TextAPI/TextStubV4Tests.cpp @@ -936,7 +936,7 @@ static const char TBDv4File[] = "--- !tapi-tbd\n" "tbd-version: 4\n" - "targets: [ i386-macos, x86_64-macos, x86_64-ios ]\n" + "targets: [ i386-macos, x86_64-macos, x86_64-ios, i386-maccatalyst, x86_64-maccatalyst ]\n" "uuids:\n" " - target: i386-macos\n" " value: 00000000-0000-0000-0000-000000000000\n" @@ -944,6 +944,10 @@ " value: 11111111-1111-1111-1111-111111111111\n" " - target: x86_64-ios\n" " value: 11111111-1111-1111-1111-111111111111\n" + " - target: i386-maccatalyst\n" + " value: 00000000-0000-0000-0000-000000000000\n" + " - target: x86_64-maccatalyst\n" + " value: 11111111-1111-1111-1111-111111111111\n" "flags: [ flat_namespace, installapi ]\n" "install-name: Umbrella.framework/Umbrella\n" "current-version: 1.2.3\n" @@ -970,6 +974,13 @@ " symbols: [_symB]\n" " - targets: [ x86_64-macos, x86_64-ios ]\n" " symbols: [_symAB]\n" + " - targets: [ i386-maccatalyst ]\n" + " weak-symbols: [ _symC ]\n" + " - targets: [ i386-maccatalyst, x86_64-maccatalyst ]\n" + " symbols: [ _symA ]\n" + " objc-classes: [ Class1 ]\n" + " - targets: [ x86_64-maccatalyst ]\n" + " symbols: [ _symAB ]\n" "reexports:\n" " - targets: [ i386-macos ]\n" " symbols: [_symC]\n" @@ -986,22 +997,6 @@ " objc-ivars: []\n" " weak-symbols: []\n" " thread-local-symbols: []\n" - "tbd-version: 4\n" - "targets: [ i386-maccatalyst, x86_64-maccatalyst ]\n" - "uuids:\n" - " - target: i386-maccatalyst\n" - " value: 00000000-0000-0000-0000-000000000000\n" - " - target: x86_64-maccatalyst\n" - " value: 11111111-1111-1111-1111-111111111111\n" - "install-name: '/System/Library/Frameworks/A.framework/A'\n" - "exports:\n" - " - targets: [ i386-maccatalyst ]\n" - " weak-symbols: [ _symC ]\n" - " - targets: [ i386-maccatalyst, x86_64-maccatalyst ]\n" - " symbols: [ _symA ]\n" - " objc-classes: [ Class1 ]\n" - " - targets: [ x86_64-maccatalyst ]\n" - " symbols: [ _symAB ]\n" "...\n"; Expected ResultA =