diff --git a/llvm/test/tools/llvm-rc/Inputs/language.rc b/llvm/test/tools/llvm-rc/Inputs/language.rc new file mode 100644 --- /dev/null +++ b/llvm/test/tools/llvm-rc/Inputs/language.rc @@ -0,0 +1,15 @@ +1 MENU +LANGUAGE 1, 2 +{ + MENUITEM "foo", 1 +} + +2 MENU { + MENUITEM "bar", 2 +} + +LANGUAGE 3, 4 + +3 MENU { + MENUITEM "baz", 3 +} diff --git a/llvm/test/tools/llvm-rc/language.test b/llvm/test/tools/llvm-rc/language.test new file mode 100644 --- /dev/null +++ b/llvm/test/tools/llvm-rc/language.test @@ -0,0 +1,19 @@ +; RUN: llvm-rc /l 40A /FO %t.res -- %p/Inputs/language.rc +; RUN: llvm-readobj %t.res | FileCheck %s +; RUN: llvm-rc /l40A /FO %t.res -- %p/Inputs/language.rc +; RUN: llvm-readobj %t.res | FileCheck %s + +; CHECK: Resource name (int): 1 +; CHECK-NEXT: Data version: +; CHECK-NEXT: Memory flags: +; CHECK-NEXT: Language ID: 2049 + +; CHECK: Resource name (int): 2 +; CHECK-NEXT: Data version: +; CHECK-NEXT: Memory flags: +; CHECK-NEXT: Language ID: 1034 + +; CHECK: Resource name (int): 3 +; CHECK-NEXT: Data version: +; CHECK-NEXT: Memory flags: +; CHECK-NEXT: Language ID: 4099 diff --git a/llvm/tools/llvm-rc/Opts.td b/llvm/tools/llvm-rc/Opts.td --- a/llvm/tools/llvm-rc/Opts.td +++ b/llvm/tools/llvm-rc/Opts.td @@ -12,7 +12,7 @@ def UNDEF : Separate<[ "/", "-" ], "U">, HelpText<"Undefine a symbol for the C preprocessor.">; -def LANG_ID : Separate<[ "/", "-" ], "L">, +def LANG_ID : JoinedOrSeparate<[ "/", "-" ], "L">, HelpText<"Set the default language identifier.">; def LANG_NAME : Separate<[ "/", "-" ], "LN">, HelpText<"Set the default language name.">; diff --git a/llvm/tools/llvm-rc/llvm-rc.cpp b/llvm/tools/llvm-rc/llvm-rc.cpp --- a/llvm/tools/llvm-rc/llvm-rc.cpp +++ b/llvm/tools/llvm-rc/llvm-rc.cpp @@ -187,7 +187,16 @@ ExitOnErr(NullResource().visit(Visitor.get())); // Set the default language; choose en-US arbitrarily. - ExitOnErr(LanguageResource(0x09, 0x01).visit(Visitor.get())); + unsigned PrimaryLangId = 0x09, SubLangId = 0x01; + if (InputArgs.hasArg(OPT_LANG_ID)) { + unsigned LangId; + if (InputArgs.getLastArgValue(OPT_LANG_ID).getAsInteger(16, LangId)) + fatalError("Invalid language id: " + + InputArgs.getLastArgValue(OPT_LANG_ID)); + PrimaryLangId = LangId & 0x3ff; + SubLangId = LangId >> 10; + } + ExitOnErr(LanguageResource(PrimaryLangId, SubLangId).visit(Visitor.get())); } rc::RCParser Parser{std::move(Tokens)};