diff options
author | Julie Hockett <juliehockett@google.com> | 2018-10-17 20:16:05 +0000 |
---|---|---|
committer | Julie Hockett <juliehockett@google.com> | 2018-10-17 20:16:05 +0000 |
commit | bf445b87debde573f476cf32df4b3288227d5ea3 (patch) | |
tree | f0291b5d210bef4f9e104266d345fd62d3a3ada4 /clang-tools-extra/unittests/clang-doc/BitcodeTest.cpp | |
parent | d2d73ba99531e7dedf2918eba616eb875f40d01b (diff) | |
download | bcm5719-llvm-bf445b87debde573f476cf32df4b3288227d5ea3.tar.gz bcm5719-llvm-bf445b87debde573f476cf32df4b3288227d5ea3.zip |
[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
Diffstat (limited to 'clang-tools-extra/unittests/clang-doc/BitcodeTest.cpp')
-rw-r--r-- | clang-tools-extra/unittests/clang-doc/BitcodeTest.cpp | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/clang-tools-extra/unittests/clang-doc/BitcodeTest.cpp b/clang-tools-extra/unittests/clang-doc/BitcodeTest.cpp index 3543029bec2..26bdf9ec6b9 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 <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); |