Index: test/tools/llvm-rc/Inputs/tag-dialog-headers.rc =================================================================== --- test/tools/llvm-rc/Inputs/tag-dialog-headers.rc +++ 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 "Foobar" {} + Index: test/tools/llvm-rc/tag-dialog.test =================================================================== --- test/tools/llvm-rc/tag-dialog.test +++ test/tools/llvm-rc/tag-dialog.test @@ -550,6 +550,36 @@ ; 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: 36 +; HEADERS-NEXT: Data: ( +; HEADERS-NEXT: 0000: 00008880 00000000 00000500 05000500 |................| +; HEADERS-NEXT: 0010: 05000000 46006F00 6F006200 61007200 |....F.o.o.b.a.r.| +; HEADERS-NEXT: 0020: 00000000 |....| +; HEADERS-NEXT: ) + ; RUN: not llvm-rc /FO %t %p/Inputs/tag-dialog-large-coord.rc 2>&1 | FileCheck %s --check-prefix COORD1 Index: tools/llvm-rc/ResourceFileWriter.h =================================================================== --- tools/llvm-rc/ResourceFileWriter.h +++ 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,6 +89,7 @@ uint32_t Charset; }; Optional Font; + StringRef Class; ObjectInfo() : LanguageInfo(0), Characteristics(0), VersionInfo(0) {} } ObjectData; Index: tools/llvm-rc/ResourceFileWriter.cpp =================================================================== --- tools/llvm-rc/ResourceFileWriter.cpp +++ 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(writeCString(ObjectData.Class)); // Window title or a single word equal to 0. RETURN_IF_ERROR(writeCString(ObjectData.Caption)); Index: tools/llvm-rc/ResourceScriptParser.h =================================================================== --- tools/llvm-rc/ResourceScriptParser.h +++ tools/llvm-rc/ResourceScriptParser.h @@ -171,6 +171,7 @@ ParseOptionType parseCharacteristicsStmt(); ParseOptionType parseVersionStmt(); ParseOptionType parseCaptionStmt(); + ParseOptionType parseClassStmt(); ParseOptionType parseFontStmt(OptStmtType DialogType); ParseOptionType parseStyleStmt(); Index: tools/llvm-rc/ResourceScriptParser.cpp =================================================================== --- tools/llvm-rc/ResourceScriptParser.cpp +++ tools/llvm-rc/ResourceScriptParser.cpp @@ -389,6 +389,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")) @@ -782,6 +784,11 @@ return llvm::make_unique(*Arg); } +RCParser::ParseOptionType RCParser::parseClassStmt() { + ASSIGN_OR_RETURN(Arg, readString()); + return llvm::make_unique(*Arg); +} + RCParser::ParseOptionType RCParser::parseFontStmt(OptStmtType DialogType) { assert(DialogType != OptStmtType::BasicStmt); Index: tools/llvm-rc/ResourceScriptStmt.h =================================================================== --- tools/llvm-rc/ResourceScriptStmt.h +++ tools/llvm-rc/ResourceScriptStmt.h @@ -869,6 +869,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: + StringRef Value; + + ClassStmt(StringRef 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: tools/llvm-rc/ResourceScriptStmt.cpp =================================================================== --- tools/llvm-rc/ResourceScriptStmt.cpp +++ 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: tools/llvm-rc/ResourceVisitor.h =================================================================== --- tools/llvm-rc/ResourceVisitor.h +++ 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;