@@ -5209,6 +5209,14 @@ class SpellingList {
52095209 Other.Spellings [Kind].end ());
52105210 }
52115211 }
5212+
5213+ bool hasSpelling () const {
5214+ for (size_t Kind = 0 ; Kind < NumSpellingKinds; ++Kind) {
5215+ if (Spellings[Kind].size () > 0 )
5216+ return true ;
5217+ }
5218+ return false ;
5219+ }
52125220};
52135221
52145222class DocumentationData {
@@ -5246,6 +5254,16 @@ GetAttributeHeadingAndSpellings(const Record &Documentation,
52465254 // documentation. This may not be a limiting factor since the spellings
52475255 // should generally be consistently applied across the category.
52485256
5257+ if (Cat == " HLSL Semantics" ) {
5258+ if (!Attribute.getName ().starts_with (" HLSL" ))
5259+ PrintFatalError (Attribute.getLoc (),
5260+ " HLSL semantic attribute name must start with HLSL" );
5261+
5262+ assert (Attribute.getName ().size () > 4 );
5263+ std::string Name = Attribute.getName ().substr (4 ).str ();
5264+ return std::make_pair (std::move (Name), SpellingList ());
5265+ }
5266+
52495267 std::vector<FlattenedSpelling> Spellings = GetFlattenedSpellings (Attribute);
52505268 if (Spellings.empty ())
52515269 PrintFatalError (Attribute.getLoc (),
@@ -5296,37 +5314,39 @@ static void WriteDocumentation(const RecordKeeper &Records,
52965314 OS << " .. _" << Label << " :\n\n " ;
52975315 OS << Doc.Heading << " \n " << std::string (Doc.Heading .length (), ' -' ) << " \n " ;
52985316
5299- // List what spelling syntaxes the attribute supports.
5300- // Note: "#pragma clang attribute" is handled outside the spelling kinds loop
5301- // so it must be last.
5302- OS << " .. csv-table:: Supported Syntaxes\n " ;
5303- OS << " :header: \" GNU\" , \" C++11\" , \" C23\" , \" ``__declspec``\" ," ;
5304- OS << " \" Keyword\" , \" ``#pragma``\" , \" HLSL Annotation\" , \" ``#pragma "
5305- " clang " ;
5306- OS << " attribute``\"\n\n \" " ;
5307- for (size_t Kind = 0 ; Kind != NumSpellingKinds; ++Kind) {
5308- SpellingKind K = (SpellingKind)Kind;
5309- // TODO: List Microsoft (IDL-style attribute) spellings once we fully
5310- // support them.
5311- if (K == SpellingKind::Microsoft)
5312- continue ;
5317+ if (Doc.SupportedSpellings .hasSpelling ()) {
5318+ // List what spelling syntaxes the attribute supports.
5319+ // Note: "#pragma clang attribute" is handled outside the spelling kinds
5320+ // loop so it must be last.
5321+ OS << " .. csv-table:: Supported Syntaxes\n " ;
5322+ OS << " :header: \" GNU\" , \" C++11\" , \" C23\" , \" ``__declspec``\" ," ;
5323+ OS << " \" Keyword\" , \" ``#pragma``\" , \" HLSL Annotation\" , \" ``#pragma "
5324+ " clang " ;
5325+ OS << " attribute``\"\n\n \" " ;
5326+ for (size_t Kind = 0 ; Kind != NumSpellingKinds; ++Kind) {
5327+ SpellingKind K = (SpellingKind)Kind;
5328+ // TODO: List Microsoft (IDL-style attribute) spellings once we fully
5329+ // support them.
5330+ if (K == SpellingKind::Microsoft)
5331+ continue ;
53135332
5314- bool PrintedAny = false ;
5315- for (StringRef Spelling : Doc.SupportedSpellings [K]) {
5316- if (PrintedAny)
5317- OS << " |br| " ;
5318- OS << " ``" << Spelling << " ``" ;
5319- PrintedAny = true ;
5333+ bool PrintedAny = false ;
5334+ for (StringRef Spelling : Doc.SupportedSpellings [K]) {
5335+ if (PrintedAny)
5336+ OS << " |br| " ;
5337+ OS << " ``" << Spelling << " ``" ;
5338+ PrintedAny = true ;
5339+ }
5340+
5341+ OS << " \" ,\" " ;
53205342 }
53215343
5322- OS << " \" ,\" " ;
5344+ if (getPragmaAttributeSupport (Records).isAttributedSupported (
5345+ *Doc.Attribute ))
5346+ OS << " Yes" ;
5347+ OS << " \"\n\n " ;
53235348 }
53245349
5325- if (getPragmaAttributeSupport (Records).isAttributedSupported (
5326- *Doc.Attribute ))
5327- OS << " Yes" ;
5328- OS << " \"\n\n " ;
5329-
53305350 // If the attribute is deprecated, print a message about it, and possibly
53315351 // provide a replacement attribute.
53325352 if (!Doc.Documentation ->isValueUnset (" Deprecated" )) {
0 commit comments