juliehockett created this revision. juliehockett added reviewers: leonardchan, jakehehrlich, lebedev.ri. juliehockett added a project: clang-tools-extra. Herald added subscribers: kadircet, arphaman.
Makes bitcode tests line up with what's actually called in the tool. Should fix the failing bot. Also fixes a warning that was being thrown about initialization braces. https://reviews.llvm.org/D53381 Files: clang-tools-extra/unittests/clang-doc/BitcodeTest.cpp clang-tools-extra/unittests/clang-doc/ClangDocTest.h Index: clang-tools-extra/unittests/clang-doc/ClangDocTest.h =================================================================== --- clang-tools-extra/unittests/clang-doc/ClangDocTest.h +++ clang-tools-extra/unittests/clang-doc/ClangDocTest.h @@ -22,7 +22,7 @@ static const SymbolID EmptySID = SymbolID(); static const SymbolID NonEmptySID = - SymbolID{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; + SymbolID{{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}}; NamespaceInfo *InfoAsNamespace(Info *I); RecordInfo *InfoAsRecord(Info *I); Index: clang-tools-extra/unittests/clang-doc/BitcodeTest.cpp =================================================================== --- clang-tools-extra/unittests/clang-doc/BitcodeTest.cpp +++ clang-tools-extra/unittests/clang-doc/BitcodeTest.cpp @@ -18,15 +18,29 @@ namespace clang { namespace doc { -std::string writeInfo(Info *I) { +template <typename T> static std::string writeInfo(T &I) { SmallString<2048> Buffer; llvm::BitstreamWriter Stream(Buffer); ClangDocBitcodeWriter Writer(Stream); - // Check that there was no error in the write. - assert(Writer.dispatchInfoForWrite(I) == false); + Writer.emitBlock(I); return Buffer.str().str(); } +std::string writeInfo(Info *I) { + switch (I->IT) { + case InfoType::IT_namespace: + return writeInfo(*static_cast<NamespaceInfo *>(I)); + case InfoType::IT_record: + return writeInfo(*static_cast<RecordInfo *>(I)); + case InfoType::IT_enum: + return writeInfo(*static_cast<EnumInfo *>(I)); + case InfoType::IT_function: + return writeInfo(*static_cast<FunctionInfo *>(I)); + default: + return ""; + } +} + std::vector<std::unique_ptr<Info>> readInfo(StringRef Bitcode, size_t NumInfos) { llvm::BitstreamCursor Stream(Bitcode);
Index: clang-tools-extra/unittests/clang-doc/ClangDocTest.h =================================================================== --- clang-tools-extra/unittests/clang-doc/ClangDocTest.h +++ clang-tools-extra/unittests/clang-doc/ClangDocTest.h @@ -22,7 +22,7 @@ static const SymbolID EmptySID = SymbolID(); static const SymbolID NonEmptySID = - SymbolID{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; + SymbolID{{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}}; NamespaceInfo *InfoAsNamespace(Info *I); RecordInfo *InfoAsRecord(Info *I); Index: clang-tools-extra/unittests/clang-doc/BitcodeTest.cpp =================================================================== --- clang-tools-extra/unittests/clang-doc/BitcodeTest.cpp +++ clang-tools-extra/unittests/clang-doc/BitcodeTest.cpp @@ -18,15 +18,29 @@ namespace clang { namespace doc { -std::string writeInfo(Info *I) { +template <typename T> static std::string writeInfo(T &I) { SmallString<2048> Buffer; llvm::BitstreamWriter Stream(Buffer); ClangDocBitcodeWriter Writer(Stream); - // Check that there was no error in the write. - assert(Writer.dispatchInfoForWrite(I) == false); + Writer.emitBlock(I); return Buffer.str().str(); } +std::string writeInfo(Info *I) { + switch (I->IT) { + case InfoType::IT_namespace: + return writeInfo(*static_cast<NamespaceInfo *>(I)); + case InfoType::IT_record: + return writeInfo(*static_cast<RecordInfo *>(I)); + case InfoType::IT_enum: + return writeInfo(*static_cast<EnumInfo *>(I)); + case InfoType::IT_function: + return writeInfo(*static_cast<FunctionInfo *>(I)); + default: + return ""; + } +} + std::vector<std::unique_ptr<Info>> readInfo(StringRef Bitcode, size_t NumInfos) { llvm::BitstreamCursor Stream(Bitcode);
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits