[llvm] 92ac146 - [demangle] Add a unittest for _Float16 demangling. NFC
via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 4 07:05:23 PDT 2021
Author: Wang, Pengfei
Date: 2021-10-04T22:05:08+08:00
New Revision: 92ac146bb99ca035a0410e8966249072a31c334c
URL: https://github.com/llvm/llvm-project/commit/92ac146bb99ca035a0410e8966249072a31c334c
DIFF: https://github.com/llvm/llvm-project/commit/92ac146bb99ca035a0410e8966249072a31c334c.diff
LOG: [demangle] Add a unittest for _Float16 demangling. NFC
Added:
Modified:
llvm/unittests/Demangle/ItaniumDemangleTest.cpp
Removed:
################################################################################
diff --git a/llvm/unittests/Demangle/ItaniumDemangleTest.cpp b/llvm/unittests/Demangle/ItaniumDemangleTest.cpp
index 11bb78429a0a9..6d4a9bcb1cfb7 100644
--- a/llvm/unittests/Demangle/ItaniumDemangleTest.cpp
+++ b/llvm/unittests/Demangle/ItaniumDemangleTest.cpp
@@ -51,3 +51,34 @@ TEST(ItaniumDemangle, MethodOverride) {
ASSERT_NE(nullptr, Parser.parse());
EXPECT_THAT(Parser.Types, testing::ElementsAre('i', 'j', 'l'));
}
+
+static std::string toString(OutputStream &OS) {
+ return {OS.getBuffer(), OS.getCurrentPosition()};
+}
+
+TEST(ItaniumDemangle, HalfType) {
+ struct TestParser : AbstractManglingParser<TestParser, TestAllocator> {
+ std::vector<std::string> Types;
+
+ TestParser(const char *Str)
+ : AbstractManglingParser(Str, Str + strlen(Str)) {}
+
+ Node *parseType() {
+ OutputStream OS;
+ Node *N = AbstractManglingParser<TestParser, TestAllocator>::parseType();
+ N->printLeft(OS);
+ StringView Name = N->getBaseName();
+ if (!Name.empty())
+ Types.push_back(std::string(Name.begin(), Name.end()));
+ else
+ Types.push_back(toString(OS));
+ std::free(OS.getBuffer());
+ return N;
+ }
+ };
+
+ // void f(A<_Float16>, _Float16);
+ TestParser Parser("_Z1f1AIDF16_EDF16_");
+ ASSERT_NE(nullptr, Parser.parse());
+ EXPECT_THAT(Parser.Types, testing::ElementsAre("_Float16", "A", "_Float16"));
+}
More information about the llvm-commits
mailing list