Skip to content

Conversation

@kparzysz
Copy link
Contributor

The gcc/clang implementation uses __PRETTY_FUNCTION__ to generate the full function name, and then extracts the type name from it. GCC emits the type name in the form of
[with T = <type-name>...]
whereas clang uses
[T = <type-name>...]
The current code looked for "with T =" to get the location of the type name, which did not work in clang-generated code.

The gcc/clang implementation uses __PRETTY_FUNCTION__ to generate a
full function name, and then extracts the type name from it.
GCC emits the type name in the form of
  [with T = <type-name>...]
whereas clang uses
  [T = <type-name>...]
The current code looked for "with T =" to get the location of the
type name, which did not work in clang-generated code.
@kparzysz kparzysz requested a review from jeanPerier October 20, 2025 13:49
@llvmbot llvmbot added flang Flang issues not falling into any other category flang:semantics labels Oct 20, 2025
@llvmbot
Copy link
Member

llvmbot commented Oct 20, 2025

@llvm/pr-subscribers-flang-semantics

Author: Krzysztof Parzyszek (kparzysz)

Changes

The gcc/clang implementation uses __PRETTY_FUNCTION__ to generate the full function name, and then extracts the type name from it. GCC emits the type name in the form of
[with T = &lt;type-name&gt;...]
whereas clang uses
[T = &lt;type-name&gt;...]
The current code looked for "with T =" to get the location of the type name, which did not work in clang-generated code.


Full diff: https://github.com/llvm/llvm-project/pull/164256.diff

1 Files Affected:

  • (modified) flang/include/flang/Semantics/dump-expr.h (+5-2)
diff --git a/flang/include/flang/Semantics/dump-expr.h b/flang/include/flang/Semantics/dump-expr.h
index 9cc52b4da487d..2dbd4cb60be59 100644
--- a/flang/include/flang/Semantics/dump-expr.h
+++ b/flang/include/flang/Semantics/dump-expr.h
@@ -46,7 +46,11 @@ class DumpEvaluateExpr {
       std::string_view v(__PRETTY_FUNCTION__);
       // Extract the "xyz" from the "pretty function" string:
       // "... [with T = xyz; std::string_view = ...]"
-      std::string_view front("with T = ");
+#ifdef __clang__
+      std::string_view front("[T = ");
+#else
+      std::string_view front("[with T = ");
+#endif
       std::string_view back("; std::string_view =");
 
 #elif defined(_MSC_VER)
@@ -69,7 +73,6 @@ class DumpEvaluateExpr {
         }
       }
 #endif
-
       return "";
     }
 

@kparzysz kparzysz merged commit be2c6c1 into main Oct 21, 2025
16 of 17 checks passed
@kparzysz kparzysz deleted the users/kparzysz/dump-expr-clang branch October 21, 2025 11:29
Lukacma pushed a commit to Lukacma/llvm-project that referenced this pull request Oct 29, 2025
The gcc/clang implementation uses __PRETTY_FUNCTION__ to generate
the full function name, and then extracts the type name from it. GCC
emits the type name in the form of
  [with T = <type-name>...]
whereas clang uses
  [T = <type-name>...]
The current code looked for "with T =" to get the location of the type
name, which did not work in clang-generated code.
aokblast pushed a commit to aokblast/llvm-project that referenced this pull request Oct 30, 2025
The gcc/clang implementation uses __PRETTY_FUNCTION__ to generate
the full function name, and then extracts the type name from it. GCC
emits the type name in the form of
  [with T = <type-name>...]
whereas clang uses
  [T = <type-name>...]
The current code looked for "with T =" to get the location of the type
name, which did not work in clang-generated code.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

flang:semantics flang Flang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants