From bf445b87debde573f476cf32df4b3288227d5ea3 Mon Sep 17 00:00:00 2001 From: Julie Hockett Date: Wed, 17 Oct 2018 20:16:05 +0000 Subject: [PATCH] [clang-doc] Bringing bitcode tests in line 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. Differential Revision: https://reviews.llvm.org/D53381 llvm-svn: 344707 --- .../unittests/clang-doc/BitcodeTest.cpp | 20 +++++++++++++++++--- clang-tools-extra/unittests/clang-doc/ClangDocTest.h | 2 +- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/clang-tools-extra/unittests/clang-doc/BitcodeTest.cpp b/clang-tools-extra/unittests/clang-doc/BitcodeTest.cpp index 3543029..26bdf9e 100644 --- a/clang-tools-extra/unittests/clang-doc/BitcodeTest.cpp +++ b/clang-tools-extra/unittests/clang-doc/BitcodeTest.cpp @@ -18,15 +18,29 @@ namespace clang { namespace doc { -std::string writeInfo(Info *I) { +template 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(I)); + case InfoType::IT_record: + return writeInfo(*static_cast(I)); + case InfoType::IT_enum: + return writeInfo(*static_cast(I)); + case InfoType::IT_function: + return writeInfo(*static_cast(I)); + default: + return ""; + } +} + std::vector> readInfo(StringRef Bitcode, size_t NumInfos) { llvm::BitstreamCursor Stream(Bitcode); diff --git a/clang-tools-extra/unittests/clang-doc/ClangDocTest.h b/clang-tools-extra/unittests/clang-doc/ClangDocTest.h index 26c0b72..1cc0619 100644 --- a/clang-tools-extra/unittests/clang-doc/ClangDocTest.h +++ b/clang-tools-extra/unittests/clang-doc/ClangDocTest.h @@ -22,7 +22,7 @@ using EmittedInfoList = std::vector>; 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); -- 2.7.4