[clang] [Clang][CodeGen] Automatically resolve MSVC _hypotf and dllimport for… (PR #207135)

via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 2 00:47:50 PDT 2026


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 cpp,c -- clang/test/CodeGen/msvc-builtin-hypotf.c clang/lib/CodeGen/CGBuiltin.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/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index ebe9f7049..2877294d6 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -251,17 +251,18 @@ llvm::Constant *CodeGenModule::getBuiltinLibFunction(const FunctionDecl *FD,
   // code calling builtins directly without headers), perform automatic
   // resolution of MSVC CRT symbol names and DLL import attributes.
   bool IsNoHeader = (D == GlobalDecl(FD));
-  if (IsNoHeader && getTriple().isWindowsMSVCEnvironment() && Name == "hypotf") {
+  if (IsNoHeader && getTriple().isWindowsMSVCEnvironment() &&
+      Name == "hypotf") {
     // Map C99 float math functions to their MSVC CRT prefixed names on Windows.
-    // (Only hypotf needs mapping as it is not exported without prefix in UCRT on both x86 and x64).
+    // (Only hypotf needs mapping as it is not exported without prefix in UCRT
+    // on both x86 and x64).
     Name = "_hypotf";
   }
 
   llvm::FunctionType *Ty =
     cast<llvm::FunctionType>(getTypes().ConvertType(FD->getType()));
 
-  llvm::Constant *C =
-      GetOrCreateLLVMFunction(Name, Ty, D, /*ForVTable=*/false);
+  llvm::Constant *C = GetOrCreateLLVMFunction(Name, Ty, D, /*ForVTable=*/false);
 
   // When compiling under dynamic CRT (/MD or -D_DLL), standard CRT library
   // functions reside in dynamic runtime DLLs. Automatically attach dllimport

``````````

</details>


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


More information about the cfe-commits mailing list