summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/unittests/clang-doc/BitcodeTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang-tools-extra/unittests/clang-doc/BitcodeTest.cpp')
-rw-r--r--clang-tools-extra/unittests/clang-doc/BitcodeTest.cpp20
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);
OpenPOWER on IntegriCloud