diff --git a/llvm/include/llvm/Demangle/ItaniumDemangle.h b/llvm/include/llvm/Demangle/ItaniumDemangle.h --- a/llvm/include/llvm/Demangle/ItaniumDemangle.h +++ b/llvm/include/llvm/Demangle/ItaniumDemangle.h @@ -3880,6 +3880,17 @@ case 'f': First += 2; return make("decimal32"); + // ::= DF _ + // # ISO/IEC TS 18661 binary floating point type _FloatN (N bits) + case 'F': { + First += 2; + StringView N = parseNumber(false /*disallow negatives*/); + if (N.size() == 0 || look() != '_') + return nullptr; + assert((N == "16") && "Unknown FP type"); + First += 1; // consume '_' + return make("_Float16"); // use FE-supoprted spelling + } // ::= Dh # IEEE 754r half-precision floating point (16 bits) case 'h': First += 2; diff --git a/llvm/unittests/Demangle/ItaniumDemangleTest.cpp b/llvm/unittests/Demangle/ItaniumDemangleTest.cpp --- a/llvm/unittests/Demangle/ItaniumDemangleTest.cpp +++ b/llvm/unittests/Demangle/ItaniumDemangleTest.cpp @@ -51,3 +51,24 @@ ASSERT_NE(nullptr, Parser.parse()); EXPECT_THAT(Parser.Types, testing::ElementsAre('i', 'j', 'l')); } + +TEST(ItaniumDemangle, HalfType) { + struct TestParser : AbstractManglingParser { + std::vector Types; + + TestParser(const char *Str) + : AbstractManglingParser(Str, Str + strlen(Str)) {} + + Node *parseType() { + Node *N = AbstractManglingParser::parseType(); + StringView Name = N->getBaseName(); + Types.push_back(std::string(Name.begin(), Name.end())); + 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")); +}