[clang] [llvm] [Clang][WebAssembly] Add wasm_global declaration attribute (PR #221909)

via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 8 00:49:49 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 h,cpp -- clang/test/CodeGen/WebAssembly/wasm-global-attribute.cpp clang/include/clang/Sema/SemaWasm.h clang/lib/CodeGen/Targets/WebAssembly.cpp clang/lib/Sema/SemaDeclAttr.cpp clang/lib/Sema/SemaWasm.cpp llvm/lib/Target/WebAssembly/Utils/WebAssemblyTypeUtilities.h llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp llvm/lib/Target/WebAssembly/WebAssemblyRefTypeMem2Local.cpp llvm/include/llvm/Support/WasmAddressSpaces.h --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/Targets/WebAssembly.cpp b/clang/lib/CodeGen/Targets/WebAssembly.cpp
index f51edfc62..05f2391dc 100644
--- a/clang/lib/CodeGen/Targets/WebAssembly.cpp
+++ b/clang/lib/CodeGen/Targets/WebAssembly.cpp
@@ -59,8 +59,7 @@ public:
   LangAS getGlobalVarAddressSpace(CodeGenModule &CGM,
                                   const VarDecl *D) const override {
     if (D && D->hasAttr<WebAssemblyGlobalAttr>())
-      return getLangASFromTargetAS(
-          llvm::WebAssembly::WASM_ADDRESS_SPACE_VAR);
+      return getLangASFromTargetAS(llvm::WebAssembly::WASM_ADDRESS_SPACE_VAR);
     return TargetCodeGenInfo::getGlobalVarAddressSpace(CGM, D);
   }
 
diff --git a/clang/lib/Sema/SemaWasm.cpp b/clang/lib/Sema/SemaWasm.cpp
index d0fae91fa..42c895758 100644
--- a/clang/lib/Sema/SemaWasm.cpp
+++ b/clang/lib/Sema/SemaWasm.cpp
@@ -462,8 +462,8 @@ void SemaWasm::handleWebAssemblyGlobalAttr(Decl *D, const ParsedAttr &AL) {
   ASTContext &Context = getASTContext();
   auto *VD = cast<VarDecl>(D);
   VD->setType(Context.getAddrSpaceQualType(
-      VD->getType(), getLangASFromTargetAS(
-                         llvm::WebAssembly::WASM_ADDRESS_SPACE_VAR)));
+      VD->getType(),
+      getLangASFromTargetAS(llvm::WebAssembly::WASM_ADDRESS_SPACE_VAR)));
   D->addAttr(::new (Context) WebAssemblyGlobalAttr(Context, AL));
 }
 
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp
index 075330081..3eea32411 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp
@@ -32,10 +32,10 @@
 #include "llvm/IR/Function.h"
 #include "llvm/IR/GetElementPtrTypeIterator.h"
 #include "llvm/IR/GlobalVariable.h"
-#include "llvm/Support/WasmAddressSpaces.h"
 #include "llvm/IR/Instructions.h"
 #include "llvm/IR/IntrinsicsWebAssembly.h"
 #include "llvm/IR/Operator.h"
+#include "llvm/Support/WasmAddressSpaces.h"
 
 using namespace llvm;
 

``````````

</details>


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


More information about the cfe-commits mailing list