[flang] [llvm] [flang] implement show_descriptor intrinsic, a non-standard extension (PR #169137)

via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 21 16:53:40 PST 2025


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions h,cpp -- flang-rt/include/flang-rt/runtime/descriptor.h flang-rt/lib/runtime/descriptor.cpp flang-rt/lib/runtime/extensions.cpp flang/include/flang/Optimizer/Builder/IntrinsicCall.h flang/include/flang/Optimizer/Builder/Runtime/Intrinsics.h flang/include/flang/Runtime/extensions.h flang/lib/Evaluate/intrinsics.cpp flang/lib/Optimizer/Builder/IntrinsicCall.cpp flang/lib/Optimizer/Builder/Runtime/Intrinsics.cpp --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/flang-rt/lib/runtime/descriptor.cpp b/flang-rt/lib/runtime/descriptor.cpp
index 5a35ea8e2..066e94232 100644
--- a/flang-rt/lib/runtime/descriptor.cpp
+++ b/flang-rt/lib/runtime/descriptor.cpp
@@ -294,60 +294,62 @@ RT_API_ATTRS void Descriptor::Check() const {
 
 static const char *GetTypeStr(ISO::CFI_type_t type, bool dumpRawType) {
   if (dumpRawType) {
-#define CASE(x) case (x): return #x;
-  switch (type) {
-  CASE(CFI_type_signed_char)
-  CASE(CFI_type_short)
-  CASE(CFI_type_int)
-  CASE(CFI_type_long)
-  CASE(CFI_type_long_long)
-  CASE(CFI_type_size_t)
-  CASE(CFI_type_int8_t)
-  CASE(CFI_type_int16_t)
-  CASE(CFI_type_int32_t)
-  CASE(CFI_type_int64_t)
-  CASE(CFI_type_int128_t)
-  CASE(CFI_type_int_least8_t)
-  CASE(CFI_type_int_least16_t)
-  CASE(CFI_type_int_least32_t)
-  CASE(CFI_type_int_least64_t)
-  CASE(CFI_type_int_least128_t)
-  CASE(CFI_type_int_fast8_t)
-  CASE(CFI_type_int_fast16_t)
-  CASE(CFI_type_int_fast32_t)
-  CASE(CFI_type_int_fast64_t)
-  CASE(CFI_type_int_fast128_t)
-  CASE(CFI_type_intmax_t)
-  CASE(CFI_type_intptr_t)
-  CASE(CFI_type_ptrdiff_t)
-  CASE(CFI_type_half_float)
-  CASE(CFI_type_bfloat)
-  CASE(CFI_type_float)
-  CASE(CFI_type_double)
-  CASE(CFI_type_extended_double)
-  CASE(CFI_type_long_double)
-  CASE(CFI_type_float128)
-  CASE(CFI_type_half_float_Complex)
-  CASE(CFI_type_bfloat_Complex)
-  CASE(CFI_type_float_Complex)
-  CASE(CFI_type_double_Complex)
-  CASE(CFI_type_extended_double_Complex)
-  CASE(CFI_type_long_double_Complex)
-  CASE(CFI_type_float128_Complex)
-  CASE(CFI_type_Bool)
-  CASE(CFI_type_char)
-  CASE(CFI_type_cptr)
-  CASE(CFI_type_struct)
-  CASE(CFI_type_char16_t)
-  CASE(CFI_type_char32_t)
-  CASE(CFI_type_uint8_t)
-  CASE(CFI_type_uint16_t)
-  CASE(CFI_type_uint32_t)
-  CASE(CFI_type_uint64_t)
-  CASE(CFI_type_uint128_t)
-  }
+#define CASE(x) \
+  case (x): \
+    return #x;
+    switch (type) {
+      CASE(CFI_type_signed_char)
+      CASE(CFI_type_short)
+      CASE(CFI_type_int)
+      CASE(CFI_type_long)
+      CASE(CFI_type_long_long)
+      CASE(CFI_type_size_t)
+      CASE(CFI_type_int8_t)
+      CASE(CFI_type_int16_t)
+      CASE(CFI_type_int32_t)
+      CASE(CFI_type_int64_t)
+      CASE(CFI_type_int128_t)
+      CASE(CFI_type_int_least8_t)
+      CASE(CFI_type_int_least16_t)
+      CASE(CFI_type_int_least32_t)
+      CASE(CFI_type_int_least64_t)
+      CASE(CFI_type_int_least128_t)
+      CASE(CFI_type_int_fast8_t)
+      CASE(CFI_type_int_fast16_t)
+      CASE(CFI_type_int_fast32_t)
+      CASE(CFI_type_int_fast64_t)
+      CASE(CFI_type_int_fast128_t)
+      CASE(CFI_type_intmax_t)
+      CASE(CFI_type_intptr_t)
+      CASE(CFI_type_ptrdiff_t)
+      CASE(CFI_type_half_float)
+      CASE(CFI_type_bfloat)
+      CASE(CFI_type_float)
+      CASE(CFI_type_double)
+      CASE(CFI_type_extended_double)
+      CASE(CFI_type_long_double)
+      CASE(CFI_type_float128)
+      CASE(CFI_type_half_float_Complex)
+      CASE(CFI_type_bfloat_Complex)
+      CASE(CFI_type_float_Complex)
+      CASE(CFI_type_double_Complex)
+      CASE(CFI_type_extended_double_Complex)
+      CASE(CFI_type_long_double_Complex)
+      CASE(CFI_type_float128_Complex)
+      CASE(CFI_type_Bool)
+      CASE(CFI_type_char)
+      CASE(CFI_type_cptr)
+      CASE(CFI_type_struct)
+      CASE(CFI_type_char16_t)
+      CASE(CFI_type_char32_t)
+      CASE(CFI_type_uint8_t)
+      CASE(CFI_type_uint16_t)
+      CASE(CFI_type_uint32_t)
+      CASE(CFI_type_uint64_t)
+      CASE(CFI_type_uint128_t)
+    }
 #undef CASE
-  return nullptr;
+    return nullptr;
   }
   TypeCode code{type};
 
diff --git a/flang/include/flang/Optimizer/Builder/Runtime/Intrinsics.h b/flang/include/flang/Optimizer/Builder/Runtime/Intrinsics.h
index b4bedc36c..ae02a4f46 100644
--- a/flang/include/flang/Optimizer/Builder/Runtime/Intrinsics.h
+++ b/flang/include/flang/Optimizer/Builder/Runtime/Intrinsics.h
@@ -111,7 +111,7 @@ mlir::Value genChdir(fir::FirOpBuilder &builder, mlir::Location loc,
 
 /// generate dump of a descriptor
 void genShowDescriptor(fir::FirOpBuilder &builder, mlir::Location loc,
-              mlir::Value descriptor);
+                       mlir::Value descriptor);
 } // namespace runtime
 } // namespace fir
 
diff --git a/flang/include/flang/Runtime/extensions.h b/flang/include/flang/Runtime/extensions.h
index 5788ea2aa..66a91e975 100644
--- a/flang/include/flang/Runtime/extensions.h
+++ b/flang/include/flang/Runtime/extensions.h
@@ -102,7 +102,7 @@ float FORTRAN_PROCEDURE_NAME(secnds)(float *refTime);
 float RTNAME(Secnds)(float *refTime, const char *sourceFile, int line);
 
 // Extension subroutine SHOW_DESCRIPTOR(D)
-void RTNAME(ShowDescriptor)(const char* descr);
+void RTNAME(ShowDescriptor)(const char *descr);
 
 } // extern "C"
 #endif // FORTRAN_RUNTIME_EXTENSIONS_H_
diff --git a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
index 660877bbf..0de27d43b 100644
--- a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
+++ b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp
@@ -7818,9 +7818,8 @@ mlir::Value IntrinsicLibrary::genShiftA(mlir::Type resultType,
   return result;
 }
 
-void
-IntrinsicLibrary::genShowDescriptor(
-                           llvm::ArrayRef<fir::ExtendedValue> args) {
+void IntrinsicLibrary::genShowDescriptor(
+    llvm::ArrayRef<fir::ExtendedValue> args) {
   assert(args.size() == 1);
   const mlir::Value descriptor = fir::getBase(args[0]);
 
diff --git a/flang/lib/Optimizer/Builder/Runtime/Intrinsics.cpp b/flang/lib/Optimizer/Builder/Runtime/Intrinsics.cpp
index 0317bc35c..737ee1718 100644
--- a/flang/lib/Optimizer/Builder/Runtime/Intrinsics.cpp
+++ b/flang/lib/Optimizer/Builder/Runtime/Intrinsics.cpp
@@ -462,8 +462,8 @@ mlir::Value fir::runtime::genChdir(fir::FirOpBuilder &builder,
   return fir::CallOp::create(builder, loc, func, args).getResult(0);
 }
 
-void fir::runtime::genShowDescriptor(fir::FirOpBuilder &builder, mlir::Location loc,
-                            mlir::Value descAddr) {
+void fir::runtime::genShowDescriptor(fir::FirOpBuilder &builder,
+                                     mlir::Location loc, mlir::Value descAddr) {
   mlir::func::FuncOp func{
       fir::runtime::getRuntimeFunc<mkRTKey(ShowDescriptor)>(loc, builder)};
   fir::CallOp::create(builder, loc, func, descAddr);

``````````

</details>


https://github.com/llvm/llvm-project/pull/169137


More information about the llvm-commits mailing list