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 @@ -51,3 +51,6 @@ 26 DIALOGEX 1, 2, 3, 4, 5 {} +27 DIALOGEX 5, 5, 5, 5 CLASS "Foobar" {} +28 DIALOG 5, 5, 5, 5 CLASS 42 {} + 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 @@ -550,6 +550,35 @@ ; HEADERS-NEXT: 0010: 00000100 02000300 04000000 00000000 |................| ; HEADERS-NEXT: ) +; HEADERS-DAG: Resource type (int): 5 +; HEADERS-NEXT: Resource name (int): 27 +; 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: 44 +; HEADERS-NEXT: Data: ( +; HEADERS-NEXT: 0000: 0100FFFF 00000000 00000000 00008880 |................| +; HEADERS-NEXT: 0010: 00000500 05000500 05000000 46006F00 |............F.o.| +; HEADERS-NEXT: 0020: 6F006200 61007200 00000000 |o.b.a.r.....| +; HEADERS-NEXT: ) + +; HEADERS-DAG: Resource type (int): 5 +; HEADERS-NEXT: Resource name (int): 28 +; 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: 26 +; HEADERS-NEXT: Data: ( +; HEADERS-NEXT: 0000: 00008880 00000000 00000500 05000500 |................| +; HEADERS-NEXT: 0010: 05000000 FFFF2A00 0000 |......*...| +; 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 @@ -62,6 +62,7 @@ Error visitCaptionStmt(const CaptionStmt *) override; Error visitCharacteristicsStmt(const CharacteristicsStmt *) override; + Error visitClassStmt(const ClassStmt *) override; Error visitFontStmt(const FontStmt *) override; Error visitLanguageStmt(const LanguageResource *) override; Error visitStyleStmt(const StyleStmt *) override; @@ -88,8 +89,11 @@ uint32_t Charset; }; Optional Font; + IntOrString Class; - ObjectInfo() : LanguageInfo(0), Characteristics(0), VersionInfo(0) {} + ObjectInfo() + : LanguageInfo(0), Characteristics(0), VersionInfo(0), + Class(StringRef()) {} } ObjectData; struct StringTableInfo { Index: llvm/trunk/tools/llvm-rc/ResourceFileWriter.cpp =================================================================== --- llvm/trunk/tools/llvm-rc/ResourceFileWriter.cpp +++ llvm/trunk/tools/llvm-rc/ResourceFileWriter.cpp @@ -458,6 +458,11 @@ return Error::success(); } +Error ResourceFileWriter::visitClassStmt(const ClassStmt *Stmt) { + ObjectData.Class = Stmt->Value; + return Error::success(); +} + Error ResourceFileWriter::visitHTMLResource(const RCResource *Res) { return writeResource(Res, &ResourceFileWriter::writeHTMLBody); } @@ -1120,8 +1125,8 @@ // think there is no menu attached to the dialog. writeInt(0); - // Window CLASS field. Not kept here. - writeInt(0); + // Window CLASS field. + RETURN_IF_ERROR(writeIntOrString(ObjectData.Class)); // Window title or a single word equal to 0. RETURN_IF_ERROR(writeCString(ObjectData.Caption)); Index: llvm/trunk/tools/llvm-rc/ResourceScriptParser.h =================================================================== --- llvm/trunk/tools/llvm-rc/ResourceScriptParser.h +++ llvm/trunk/tools/llvm-rc/ResourceScriptParser.h @@ -171,6 +171,7 @@ ParseOptionType parseCharacteristicsStmt(); ParseOptionType parseVersionStmt(); ParseOptionType parseCaptionStmt(); + ParseOptionType parseClassStmt(); 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 @@ -386,6 +386,8 @@ if (StmtsType != OptStmtType::BasicStmt) { if (TypeToken->equals_lower("CAPTION")) return parseCaptionStmt(); + if (TypeToken->equals_lower("CLASS")) + return parseClassStmt(); if (TypeToken->equals_lower("FONT")) return parseFontStmt(StmtsType); if (TypeToken->equals_lower("STYLE")) @@ -779,6 +781,11 @@ return llvm::make_unique(*Arg); } +RCParser::ParseOptionType RCParser::parseClassStmt() { + ASSIGN_OR_RETURN(Arg, readIntOrString()); + return llvm::make_unique(*Arg); +} + RCParser::ParseOptionType RCParser::parseFontStmt(OptStmtType DialogType) { assert(DialogType != OptStmtType::BasicStmt); 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); } }; +// CLASS optional statement. +// +// Ref: msdn.microsoft.com/en-us/library/windows/desktop/aa380883(v=vs.85).aspx +class ClassStmt : public OptionalStmt { +public: + IntOrString Value; + + ClassStmt(IntOrString Class) : Value(Class) {} + raw_ostream &log(raw_ostream &) const override; + Twine getResourceTypeName() const override { return "CLASS"; } + Error visit(Visitor *V) const override { return V->visitClassStmt(this); } +}; + } // namespace rc } // namespace llvm Index: llvm/trunk/tools/llvm-rc/ResourceScriptStmt.cpp =================================================================== --- llvm/trunk/tools/llvm-rc/ResourceScriptStmt.cpp +++ llvm/trunk/tools/llvm-rc/ResourceScriptStmt.cpp @@ -267,6 +267,10 @@ return OS << "Caption: " << Value << "\n"; } +raw_ostream &ClassStmt::log(raw_ostream &OS) const { + return OS << "Class: " << Value << "\n"; +} + raw_ostream &FontStmt::log(raw_ostream &OS) const { OS << "Font: size = " << Size << ", face = " << Name << ", weight = " << Weight; Index: llvm/trunk/tools/llvm-rc/ResourceVisitor.h =================================================================== --- llvm/trunk/tools/llvm-rc/ResourceVisitor.h +++ llvm/trunk/tools/llvm-rc/ResourceVisitor.h @@ -22,6 +22,7 @@ class RCResource; class CaptionStmt; +class ClassStmt; class CharacteristicsStmt; class FontStmt; class LanguageResource; @@ -43,6 +44,7 @@ virtual Error visitVersionInfoResource(const RCResource *) = 0; virtual Error visitCaptionStmt(const CaptionStmt *) = 0; + virtual Error visitClassStmt(const ClassStmt *) = 0; virtual Error visitCharacteristicsStmt(const CharacteristicsStmt *) = 0; virtual Error visitFontStmt(const FontStmt *) = 0; virtual Error visitLanguageStmt(const LanguageResource *) = 0;