Index: llvm/trunk/test/tools/llvm-rc/Inputs/tag-dialog-headers.rc =================================================================== --- llvm/trunk/test/tools/llvm-rc/Inputs/tag-dialog-headers.rc +++ llvm/trunk/test/tools/llvm-rc/Inputs/tag-dialog-headers.rc @@ -54,3 +54,8 @@ 27 DIALOGEX 5, 5, 5, 5 CLASS "Foobar" {} 28 DIALOG 5, 5, 5, 5 CLASS 42 {} +29 DIALOGEX 0, 1, 0, 9 EXSTYLE 0x01234567 {} +30 DIALOG 0, 1, 0, 9 EXSTYLE 0x01234567 {} + +31 DIALOGEX 0, 1, 0, 9 STYLE 0x76543210 EXSTYLE 0x01234567 {} +32 DIALOG 0, 1, 0, 9 EXSTYLE 0x0123456 STYLE 0x76543210 {} Index: llvm/trunk/test/tools/llvm-rc/tag-dialog.test =================================================================== --- llvm/trunk/test/tools/llvm-rc/tag-dialog.test +++ llvm/trunk/test/tools/llvm-rc/tag-dialog.test @@ -579,6 +579,62 @@ ; HEADERS-NEXT: 0010: 05000000 FFFF2A00 0000 |......*...| ; HEADERS-NEXT: ) +; HEADERS-DAG: Resource type (int): 5 +; HEADERS-NEXT: Resource name (int): 29 +; HEADERS-NEXT: Data version: 0 +; HEADERS-NEXT: Memory flags: 0x1030 +; HEADERS-NEXT: Language ID: 1033 +; HEADERS-NEXT: Version (major): 0 +; HEADERS-NEXT: Version (minor): 0 +; HEADERS-NEXT: Characteristics: 0 +; HEADERS-NEXT: Data size: 32 +; HEADERS-NEXT: Data: ( +; HEADERS-NEXT: 0000: 0100FFFF 00000000 67452301 00008880 |........gE#.....| +; HEADERS-NEXT: 0010: 00000000 01000000 09000000 00000000 |................| +; HEADERS-NEXT: ) + +; HEADERS-DAG: Resource type (int): 5 +; HEADERS-NEXT: Resource name (int): 30 +; HEADERS-NEXT: Data version: 0 +; HEADERS-NEXT: Memory flags: 0x1030 +; HEADERS-NEXT: Language ID: 1033 +; HEADERS-NEXT: Version (major): 0 +; HEADERS-NEXT: Version (minor): 0 +; HEADERS-NEXT: Characteristics: 0 +; HEADERS-NEXT: Data size: 24 +; HEADERS-NEXT: Data: ( +; HEADERS-NEXT: 0000: 00008880 67452301 00000000 01000000 |....gE#.........| +; HEADERS-NEXT: 0010: 09000000 00000000 |........| +; HEADERS-NEXT: ) + +; HEADERS-DAG: Resource type (int): 5 +; HEADERS-NEXT: Resource name (int): 31 +; HEADERS-NEXT: Data version: 0 +; HEADERS-NEXT: Memory flags: 0x1030 +; HEADERS-NEXT: Language ID: 1033 +; HEADERS-NEXT: Version (major): 0 +; HEADERS-NEXT: Version (minor): 0 +; HEADERS-NEXT: Characteristics: 0 +; HEADERS-NEXT: Data size: 32 +; HEADERS-NEXT: Data: ( +; HEADERS-NEXT: 0000: 0100FFFF 00000000 67452301 10325476 |........gE#..2Tv| +; HEADERS-NEXT: 0010: 00000000 01000000 09000000 00000000 |................| +; HEADERS-NEXT: ) + +; HEADERS-DAG: Resource type (int): 5 +; HEADERS-NEXT: Resource name (int): 32 +; HEADERS-NEXT: Data version: 0 +; HEADERS-NEXT: Memory flags: 0x1030 +; HEADERS-NEXT: Language ID: 1033 +; HEADERS-NEXT: Version (major): 0 +; HEADERS-NEXT: Version (minor): 0 +; HEADERS-NEXT: Characteristics: 0 +; HEADERS-NEXT: Data size: 24 +; HEADERS-NEXT: Data: ( +; HEADERS-NEXT: 0000: 10325476 56341200 00000000 01000000 |.2TvV4..........| +; HEADERS-NEXT: 0010: 09000000 00000000 |........| +; HEADERS-NEXT: ) + ; RUN: not llvm-rc /FO %t %p/Inputs/tag-dialog-large-coord.rc 2>&1 | FileCheck %s --check-prefix COORD1 Index: llvm/trunk/tools/llvm-rc/ResourceFileWriter.h =================================================================== --- llvm/trunk/tools/llvm-rc/ResourceFileWriter.h +++ llvm/trunk/tools/llvm-rc/ResourceFileWriter.h @@ -63,6 +63,7 @@ Error visitCaptionStmt(const CaptionStmt *) override; Error visitCharacteristicsStmt(const CharacteristicsStmt *) override; Error visitClassStmt(const ClassStmt *) override; + Error visitExStyleStmt(const ExStyleStmt *) override; Error visitFontStmt(const FontStmt *) override; Error visitLanguageStmt(const LanguageResource *) override; Error visitStyleStmt(const StyleStmt *) override; @@ -80,6 +81,7 @@ uint32_t VersionInfo; Optional Style; + Optional ExStyle; StringRef Caption; struct FontInfo { uint32_t Size; Index: llvm/trunk/tools/llvm-rc/ResourceFileWriter.cpp =================================================================== --- llvm/trunk/tools/llvm-rc/ResourceFileWriter.cpp +++ llvm/trunk/tools/llvm-rc/ResourceFileWriter.cpp @@ -514,6 +514,11 @@ return Error::success(); } +Error ResourceFileWriter::visitExStyleStmt(const ExStyleStmt *Stmt) { + ObjectData.ExStyle = Stmt->Value; + return Error::success(); +} + Error ResourceFileWriter::visitFontStmt(const FontStmt *Stmt) { RETURN_IF_ERROR(checkNumberFits(Stmt->Size, "Font size")); RETURN_IF_ERROR(checkNumberFits(Stmt->Weight, "Font weight")); @@ -1065,6 +1070,7 @@ UsedStyle |= StyleCaptionFlag; const uint16_t DialogExMagic = 0xFFFF; + uint32_t ExStyle = ObjectData.ExStyle.getValueOr(0); // Write DIALOG(EX) header prefix. These are pretty different. if (!Res->IsExtended) { @@ -1083,7 +1089,7 @@ ulittle32_t Style; ulittle32_t ExtStyle; } Prefix{ulittle32_t(UsedStyle), - ulittle32_t(0)}; // As of now, we don't keep EXSTYLE. + ulittle32_t(ExStyle)}; writeObject(Prefix); } else { @@ -1094,7 +1100,7 @@ ulittle32_t ExtStyle; ulittle32_t Style; } Prefix{ulittle16_t(1), ulittle16_t(DialogExMagic), - ulittle32_t(Res->HelpID), ulittle32_t(0), ulittle32_t(UsedStyle)}; + ulittle32_t(Res->HelpID), ulittle32_t(ExStyle), ulittle32_t(UsedStyle)}; writeObject(Prefix); } Index: llvm/trunk/tools/llvm-rc/ResourceScriptParser.h =================================================================== --- llvm/trunk/tools/llvm-rc/ResourceScriptParser.h +++ llvm/trunk/tools/llvm-rc/ResourceScriptParser.h @@ -172,6 +172,7 @@ ParseOptionType parseVersionStmt(); ParseOptionType parseCaptionStmt(); ParseOptionType parseClassStmt(); + ParseOptionType parseExStyleStmt(); ParseOptionType parseFontStmt(OptStmtType DialogType); ParseOptionType parseStyleStmt(); Index: llvm/trunk/tools/llvm-rc/ResourceScriptParser.cpp =================================================================== --- llvm/trunk/tools/llvm-rc/ResourceScriptParser.cpp +++ llvm/trunk/tools/llvm-rc/ResourceScriptParser.cpp @@ -388,6 +388,8 @@ return parseCaptionStmt(); if (TypeToken->equals_lower("CLASS")) return parseClassStmt(); + if (TypeToken->equals_lower("EXSTYLE")) + return parseExStyleStmt(); if (TypeToken->equals_lower("FONT")) return parseFontStmt(StmtsType); if (TypeToken->equals_lower("STYLE")) @@ -817,6 +819,11 @@ return llvm::make_unique(*Arg); } +RCParser::ParseOptionType RCParser::parseExStyleStmt() { + ASSIGN_OR_RETURN(Arg, readInt()); + return llvm::make_unique(*Arg); +} + Error RCParser::getExpectedError(const Twine &Message, bool IsAlreadyRead) { return make_error( Message, IsAlreadyRead ? std::prev(CurLoc) : CurLoc, End); Index: llvm/trunk/tools/llvm-rc/ResourceScriptStmt.h =================================================================== --- llvm/trunk/tools/llvm-rc/ResourceScriptStmt.h +++ llvm/trunk/tools/llvm-rc/ResourceScriptStmt.h @@ -866,6 +866,19 @@ Error visit(Visitor *V) const override { return V->visitStyleStmt(this); } }; +// EXSTYLE optional statement. +// +// Ref: docs.microsoft.com/en-us/windows/desktop/menurc/exstyle-statement +class ExStyleStmt : public OptionalStmt { +public: + uint32_t Value; + + ExStyleStmt(uint32_t ExStyle) : Value(ExStyle) {} + raw_ostream &log(raw_ostream &) const override; + Twine getResourceTypeName() const override { return "EXSTYLE"; } + Error visit(Visitor *V) const override { return V->visitExStyleStmt(this); } +}; + // CLASS optional statement. // // Ref: msdn.microsoft.com/en-us/library/windows/desktop/aa380883(v=vs.85).aspx Index: llvm/trunk/tools/llvm-rc/ResourceScriptStmt.cpp =================================================================== --- llvm/trunk/tools/llvm-rc/ResourceScriptStmt.cpp +++ llvm/trunk/tools/llvm-rc/ResourceScriptStmt.cpp @@ -283,5 +283,9 @@ return OS << "Style: " << Value << "\n"; } +raw_ostream &ExStyleStmt::log(raw_ostream &OS) const { + return OS << "ExStyle: " << Value << "\n"; +} + } // namespace rc } // namespace llvm Index: llvm/trunk/tools/llvm-rc/ResourceVisitor.h =================================================================== --- llvm/trunk/tools/llvm-rc/ResourceVisitor.h +++ llvm/trunk/tools/llvm-rc/ResourceVisitor.h @@ -24,6 +24,7 @@ class CaptionStmt; class ClassStmt; class CharacteristicsStmt; +class ExStyleStmt; class FontStmt; class LanguageResource; class StyleStmt; @@ -46,6 +47,7 @@ virtual Error visitCaptionStmt(const CaptionStmt *) = 0; virtual Error visitClassStmt(const ClassStmt *) = 0; virtual Error visitCharacteristicsStmt(const CharacteristicsStmt *) = 0; + virtual Error visitExStyleStmt(const ExStyleStmt *) = 0; virtual Error visitFontStmt(const FontStmt *) = 0; virtual Error visitLanguageStmt(const LanguageResource *) = 0; virtual Error visitStyleStmt(const StyleStmt *) = 0;