Skip to content

Commit f29be61

Browse files
committed
Fix for MSVC
1 parent 8babecf commit f29be61

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

flang/include/flang/Semantics/dump-expr.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,27 @@ class DumpEvaluateExpr {
4141
private:
4242
template <typename T> struct TypeOf {
4343
static constexpr std::string_view get() {
44+
#if defined(__GNUC__)
4445
std::string_view v(__PRETTY_FUNCTION__);
4546
// Extract the "xyz" from the "pretty function" string:
4647
// "... [with T = xyz; std::string_view = ...]"
4748
std::string_view front("with T = ");
4849
std::string_view back("; std::string_view =");
4950

51+
#elif defined(_MSC_VER)
52+
std::string_view v(__FUNCSIG__);
53+
// Extract the "xyz" from the "pretty function" string:
54+
// "... TypeOf<xyz>::get(void)"
55+
std::string_view front(" TypeOf<");
56+
std::string_view back(">::get(void)");
57+
58+
#else
59+
return "";
60+
#endif
61+
5062
if (auto fpos{v.find(front)}; fpos != v.npos) {
51-
// Strip the part "... [with T = "
5263
v.remove_prefix(fpos + front.size());
5364
if (auto bpos{v.find(back)}; bpos != v.npos) {
54-
// Strip the ending "; std::string_view = ...]"
5565
v.remove_suffix(v.size() - bpos);
5666
return v;
5767
}

0 commit comments

Comments
 (0)