Skip to content

Commit 91b38c6

Browse files
committed
Revert "[clang-doc] Add template support."
Causes a build failure in YAML specializations. This reverts commit 0f6dbb5.
1 parent f1fd5c9 commit 91b38c6

File tree

13 files changed

+80
-587
lines changed

13 files changed

+80
-587
lines changed

clang-tools-extra/clang-doc/BitcodeReader.cpp

Lines changed: 0 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,6 @@ llvm::Error parseRecord(const Record &R, unsigned ID, llvm::StringRef Blob,
351351
return decodeRecord(R, I->USR, Blob);
352352
case REFERENCE_NAME:
353353
return decodeRecord(R, I->Name, Blob);
354-
case REFERENCE_QUAL_NAME:
355-
return decodeRecord(R, I->QualName, Blob);
356354
case REFERENCE_TYPE:
357355
return decodeRecord(R, I->RefType, Blob);
358356
case REFERENCE_PATH:
@@ -365,29 +363,6 @@ llvm::Error parseRecord(const Record &R, unsigned ID, llvm::StringRef Blob,
365363
}
366364
}
367365

368-
llvm::Error parseRecord(const Record &R, unsigned ID, llvm::StringRef Blob,
369-
TemplateInfo *I) {
370-
// Currently there are no child records of TemplateInfo (only child blocks).
371-
return llvm::createStringError(llvm::inconvertibleErrorCode(),
372-
"invalid field for TemplateParamInfo");
373-
}
374-
375-
llvm::Error parseRecord(const Record &R, unsigned ID, llvm::StringRef Blob,
376-
TemplateSpecializationInfo *I) {
377-
if (ID == TEMPLATE_SPECIALIZATION_OF)
378-
return decodeRecord(R, I->SpecializationOf, Blob);
379-
return llvm::createStringError(llvm::inconvertibleErrorCode(),
380-
"invalid field for TemplateParamInfo");
381-
}
382-
383-
llvm::Error parseRecord(const Record &R, unsigned ID, llvm::StringRef Blob,
384-
TemplateParamInfo *I) {
385-
if (ID == TEMPLATE_PARAM_CONTENTS)
386-
return decodeRecord(R, I->Contents, Blob);
387-
return llvm::createStringError(llvm::inconvertibleErrorCode(),
388-
"invalid field for TemplateParamInfo");
389-
}
390-
391366
template <typename T> llvm::Expected<CommentInfo *> getCommentInfo(T I) {
392367
return llvm::createStringError(llvm::inconvertibleErrorCode(),
393368
"invalid type cannot contain CommentInfo");
@@ -620,45 +595,6 @@ template <> void addChild(BaseRecordInfo *I, FunctionInfo &&R) {
620595
I->Children.Functions.emplace_back(std::move(R));
621596
}
622597

623-
// TemplateParam children. These go into either a TemplateInfo (for template
624-
// parameters) or TemplateSpecializationInfo (for the specialization's
625-
// parameters).
626-
template <typename T> void addTemplateParam(T I, TemplateParamInfo &&P) {
627-
llvm::errs() << "invalid container for template parameter";
628-
exit(1);
629-
}
630-
template <> void addTemplateParam(TemplateInfo *I, TemplateParamInfo &&P) {
631-
I->Params.emplace_back(std::move(P));
632-
}
633-
template <>
634-
void addTemplateParam(TemplateSpecializationInfo *I, TemplateParamInfo &&P) {
635-
I->Params.emplace_back(std::move(P));
636-
}
637-
638-
// Template info. These apply to either records or functions.
639-
template <typename T> void addTemplate(T I, TemplateInfo &&P) {
640-
llvm::errs() << "invalid container for template info";
641-
exit(1);
642-
}
643-
template <> void addTemplate(RecordInfo *I, TemplateInfo &&P) {
644-
I->Template.emplace(std::move(P));
645-
}
646-
template <> void addTemplate(FunctionInfo *I, TemplateInfo &&P) {
647-
I->Template.emplace(std::move(P));
648-
}
649-
650-
// Template specializations go only into template records.
651-
template <typename T>
652-
void addTemplateSpecialization(T I, TemplateSpecializationInfo &&TSI) {
653-
llvm::errs() << "invalid container for template specialization info";
654-
exit(1);
655-
}
656-
template <>
657-
void addTemplateSpecialization(TemplateInfo *I,
658-
TemplateSpecializationInfo &&TSI) {
659-
I->Specialization.emplace(std::move(TSI));
660-
}
661-
662598
// Read records from bitcode into a given info.
663599
template <typename T>
664600
llvm::Error ClangDocBitcodeReader::readRecord(unsigned ID, T I) {
@@ -783,27 +719,6 @@ llvm::Error ClangDocBitcodeReader::readSubBlock(unsigned ID, T I) {
783719
addChild(I, std::move(EV));
784720
return llvm::Error::success();
785721
}
786-
case BI_TEMPLATE_BLOCK_ID: {
787-
TemplateInfo TI;
788-
if (auto Err = readBlock(ID, &TI))
789-
return Err;
790-
addTemplate(I, std::move(TI));
791-
return llvm::Error::success();
792-
}
793-
case BI_TEMPLATE_SPECIALIZATION_BLOCK_ID: {
794-
TemplateSpecializationInfo TSI;
795-
if (auto Err = readBlock(ID, &TSI))
796-
return Err;
797-
addTemplateSpecialization(I, std::move(TSI));
798-
return llvm::Error::success();
799-
}
800-
case BI_TEMPLATE_PARAM_BLOCK_ID: {
801-
TemplateParamInfo TPI;
802-
if (auto Err = readBlock(ID, &TPI))
803-
return Err;
804-
addTemplateParam(I, std::move(TPI));
805-
return llvm::Error::success();
806-
}
807722
case BI_TYPEDEF_BLOCK_ID: {
808723
TypedefInfo TI;
809724
if (auto Err = readBlock(ID, &TI))

clang-tools-extra/clang-doc/BitcodeWriter.cpp

Lines changed: 3 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,7 @@ static const llvm::IndexedMap<llvm::StringRef, BlockIdToIndexFunctor>
121121
{BI_BASE_RECORD_BLOCK_ID, "BaseRecordBlock"},
122122
{BI_FUNCTION_BLOCK_ID, "FunctionBlock"},
123123
{BI_COMMENT_BLOCK_ID, "CommentBlock"},
124-
{BI_REFERENCE_BLOCK_ID, "ReferenceBlock"},
125-
{BI_TEMPLATE_BLOCK_ID, "TemplateBlock"},
126-
{BI_TEMPLATE_SPECIALIZATION_BLOCK_ID, "TemplateSpecializationBlock"},
127-
{BI_TEMPLATE_PARAM_BLOCK_ID, "TemplateParamBlock"}};
124+
{BI_REFERENCE_BLOCK_ID, "ReferenceBlock"}};
128125
assert(Inits.size() == BlockIdCount);
129126
for (const auto &Init : Inits)
130127
BlockIdNameMap[Init.first] = Init.second;
@@ -189,12 +186,9 @@ static const llvm::IndexedMap<RecordIdDsc, RecordIdToIndexFunctor>
189186
{FUNCTION_IS_METHOD, {"IsMethod", &BoolAbbrev}},
190187
{REFERENCE_USR, {"USR", &SymbolIDAbbrev}},
191188
{REFERENCE_NAME, {"Name", &StringAbbrev}},
192-
{REFERENCE_QUAL_NAME, {"QualName", &StringAbbrev}},
193189
{REFERENCE_TYPE, {"RefType", &IntAbbrev}},
194190
{REFERENCE_PATH, {"Path", &StringAbbrev}},
195191
{REFERENCE_FIELD, {"Field", &IntAbbrev}},
196-
{TEMPLATE_PARAM_CONTENTS, {"Contents", &StringAbbrev}},
197-
{TEMPLATE_SPECIALIZATION_OF, {"SpecializationOf", &SymbolIDAbbrev}},
198192
{TYPEDEF_USR, {"USR", &SymbolIDAbbrev}},
199193
{TYPEDEF_NAME, {"Name", &StringAbbrev}},
200194
{TYPEDEF_DEFLOCATION, {"DefLocation", &LocationAbbrev}},
@@ -250,12 +244,8 @@ static const std::vector<std::pair<BlockId, std::vector<RecordId>>>
250244
FUNCTION_ACCESS, FUNCTION_IS_METHOD}},
251245
// Reference Block
252246
{BI_REFERENCE_BLOCK_ID,
253-
{REFERENCE_USR, REFERENCE_NAME, REFERENCE_QUAL_NAME, REFERENCE_TYPE,
254-
REFERENCE_PATH, REFERENCE_FIELD}},
255-
// Template Blocks.
256-
{BI_TEMPLATE_BLOCK_ID, {}},
257-
{BI_TEMPLATE_PARAM_BLOCK_ID, {TEMPLATE_PARAM_CONTENTS}},
258-
{BI_TEMPLATE_SPECIALIZATION_BLOCK_ID, {TEMPLATE_SPECIALIZATION_OF}}};
247+
{REFERENCE_USR, REFERENCE_NAME, REFERENCE_TYPE, REFERENCE_PATH,
248+
REFERENCE_FIELD}}};
259249

260250
// AbbreviationMap
261251

@@ -388,8 +378,6 @@ void ClangDocBitcodeWriter::emitRecord(unsigned Val, RecordId ID) {
388378
Stream.EmitRecordWithAbbrev(Abbrevs.get(ID), Record);
389379
}
390380

391-
void ClangDocBitcodeWriter::emitRecord(const TemplateInfo &Templ) {}
392-
393381
bool ClangDocBitcodeWriter::prepRecordData(RecordId ID, bool ShouldEmit) {
394382
assert(RecordIdNameMap[ID] && "Unknown RecordId.");
395383
if (!ShouldEmit)
@@ -428,7 +416,6 @@ void ClangDocBitcodeWriter::emitBlock(const Reference &R, FieldId Field) {
428416
StreamSubBlockGuard Block(Stream, BI_REFERENCE_BLOCK_ID);
429417
emitRecord(R.USR, REFERENCE_USR);
430418
emitRecord(R.Name, REFERENCE_NAME);
431-
emitRecord(R.QualName, REFERENCE_QUAL_NAME);
432419
emitRecord((unsigned)R.RefType, REFERENCE_TYPE);
433420
emitRecord(R.Path, REFERENCE_PATH);
434421
emitRecord((unsigned)Field, REFERENCE_FIELD);
@@ -569,8 +556,6 @@ void ClangDocBitcodeWriter::emitBlock(const RecordInfo &I) {
569556
emitBlock(C);
570557
for (const auto &C : I.Children.Typedefs)
571558
emitBlock(C);
572-
if (I.Template)
573-
emitBlock(*I.Template);
574559
}
575560

576561
void ClangDocBitcodeWriter::emitBlock(const BaseRecordInfo &I) {
@@ -606,28 +591,6 @@ void ClangDocBitcodeWriter::emitBlock(const FunctionInfo &I) {
606591
emitBlock(I.ReturnType);
607592
for (const auto &N : I.Params)
608593
emitBlock(N);
609-
if (I.Template)
610-
emitBlock(*I.Template);
611-
}
612-
613-
void ClangDocBitcodeWriter::emitBlock(const TemplateInfo &T) {
614-
StreamSubBlockGuard Block(Stream, BI_TEMPLATE_BLOCK_ID);
615-
for (const auto &P : T.Params)
616-
emitBlock(P);
617-
if (T.Specialization)
618-
emitBlock(*T.Specialization);
619-
}
620-
621-
void ClangDocBitcodeWriter::emitBlock(const TemplateSpecializationInfo &T) {
622-
StreamSubBlockGuard Block(Stream, BI_TEMPLATE_SPECIALIZATION_BLOCK_ID);
623-
emitRecord(T.SpecializationOf, TEMPLATE_SPECIALIZATION_OF);
624-
for (const auto &P : T.Params)
625-
emitBlock(P);
626-
}
627-
628-
void ClangDocBitcodeWriter::emitBlock(const TemplateParamInfo &T) {
629-
StreamSubBlockGuard Block(Stream, BI_TEMPLATE_PARAM_BLOCK_ID);
630-
emitRecord(T.Contents, TEMPLATE_PARAM_CONTENTS);
631594
}
632595

633596
bool ClangDocBitcodeWriter::dispatchInfoForWrite(Info *I) {

clang-tools-extra/clang-doc/BitcodeWriter.h

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
#include "Representation.h"
1919
#include "clang/AST/AST.h"
20+
#include "llvm/ADT/APSInt.h"
2021
#include "llvm/ADT/DenseMap.h"
2122
#include "llvm/ADT/SmallVector.h"
2223
#include "llvm/ADT/StringRef.h"
@@ -63,9 +64,6 @@ enum BlockId {
6364
BI_FUNCTION_BLOCK_ID,
6465
BI_COMMENT_BLOCK_ID,
6566
BI_REFERENCE_BLOCK_ID,
66-
BI_TEMPLATE_BLOCK_ID,
67-
BI_TEMPLATE_SPECIALIZATION_BLOCK_ID,
68-
BI_TEMPLATE_PARAM_BLOCK_ID,
6967
BI_TYPEDEF_BLOCK_ID,
7068
BI_LAST,
7169
BI_FIRST = BI_VERSION_BLOCK_ID
@@ -123,12 +121,9 @@ enum RecordId {
123121
BASE_RECORD_IS_PARENT,
124122
REFERENCE_USR,
125123
REFERENCE_NAME,
126-
REFERENCE_QUAL_NAME,
127124
REFERENCE_TYPE,
128125
REFERENCE_PATH,
129126
REFERENCE_FIELD,
130-
TEMPLATE_PARAM_CONTENTS,
131-
TEMPLATE_SPECIALIZATION_OF,
132127
TYPEDEF_USR,
133128
TYPEDEF_NAME,
134129
TYPEDEF_DEFLOCATION,
@@ -174,9 +169,6 @@ class ClangDocBitcodeWriter {
174169
void emitBlock(const FieldTypeInfo &B);
175170
void emitBlock(const MemberTypeInfo &T);
176171
void emitBlock(const CommentInfo &B);
177-
void emitBlock(const TemplateInfo &T);
178-
void emitBlock(const TemplateSpecializationInfo &T);
179-
void emitBlock(const TemplateParamInfo &T);
180172
void emitBlock(const Reference &B, FieldId F);
181173

182174
private:
@@ -223,7 +215,7 @@ class ClangDocBitcodeWriter {
223215
void emitRecord(bool Value, RecordId ID);
224216
void emitRecord(int Value, RecordId ID);
225217
void emitRecord(unsigned Value, RecordId ID);
226-
void emitRecord(const TemplateInfo &Templ);
218+
void emitRecord(llvm::APSInt Value, RecordId ID);
227219
bool prepRecordData(RecordId ID, bool ShouldEmit = true);
228220

229221
// Emission of appropriate abbreviation type.

clang-tools-extra/clang-doc/Representation.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,6 @@ void RecordInfo::merge(RecordInfo &&Other) {
250250
reduceChildren(Children.Enums, std::move(Other.Children.Enums));
251251
reduceChildren(Children.Typedefs, std::move(Other.Children.Typedefs));
252252
SymbolInfo::merge(std::move(Other));
253-
if (!Template)
254-
Template = Other.Template;
255253
}
256254

257255
void EnumInfo::merge(EnumInfo &&Other) {
@@ -276,8 +274,6 @@ void FunctionInfo::merge(FunctionInfo &&Other) {
276274
if (Params.empty())
277275
Params = std::move(Other.Params);
278276
SymbolInfo::merge(std::move(Other));
279-
if (!Template)
280-
Template = Other.Template;
281277
}
282278

283279
void TypedefInfo::merge(TypedefInfo &&Other) {

0 commit comments

Comments
 (0)