Skip to content
This repository was archived by the owner on Feb 21, 2026. It is now read-only.

[CIR] Make nothrow explicit function attribute - #2028

Draft
xlauko wants to merge 1 commit into
graphite-base/2028from
users/xlauko/make-nothrow-explicit-attr
Draft

[CIR] Make nothrow explicit function attribute#2028
xlauko wants to merge 1 commit into
graphite-base/2028from
users/xlauko/make-nothrow-explicit-attr

Conversation

@xlauko

@xlauko xlauko commented Nov 26, 2025

Copy link
Copy Markdown
Collaborator

No description provided.

@xlauko

xlauko commented Nov 26, 2025

Copy link
Copy Markdown
Collaborator Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@xlauko xlauko changed the title XXX [CIR] Make nothrow explicit function attribute Nov 26, 2025
@github-actions

github-actions Bot commented Nov 26, 2025

Copy link
Copy Markdown

鈿狅笍 C/C++ code formatter, clang-format found issues in your code. 鈿狅笍

You can test this locally with the following command:
git-clang-format --diff origin/main HEAD --extensions cl,cpp,c -- clang/lib/CIR/CodeGen/CIRGenCall.cpp clang/lib/CIR/CodeGen/CIRGenFunction.cpp clang/lib/CIR/CodeGen/CIRGenModule.cpp clang/lib/CIR/Dialect/IR/CIRDialect.cpp clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVMIR.cpp clang/test/CIR/CodeGen/OpenCL/nothrow.cl clang/test/CIR/CodeGen/call-extra-attrs.cpp clang/test/CIR/CodeGen/conditional-cleanup.cpp clang/test/CIR/CodeGen/coro-task.cpp clang/test/CIR/CodeGen/default-methods.cpp clang/test/CIR/CodeGen/function-attrs.cpp clang/test/CIR/CodeGen/hello.c clang/test/CIR/CodeGen/lambda.cpp clang/test/CIR/CodeGen/null-arithmatic-expression.c clang/test/CIR/CodeGen/optnone.cpp clang/test/CIR/CodeGen/temporaries.cpp --diff_from_common_commit

鈿狅笍
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.
鈿狅笍

View the diff from clang-format here.
diff --git a/clang/lib/CIR/CodeGen/CIRGenCall.cpp b/clang/lib/CIR/CodeGen/CIRGenCall.cpp
index d1701c638..48bea18dc 100644
--- a/clang/lib/CIR/CodeGen/CIRGenCall.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenCall.cpp
@@ -407,8 +407,8 @@ emitCallLikeOp(CIRGenFunction &CGF, mlir::Location callLoc,
         callLoc, indirectFuncVal, indirectFuncTy, CIRCallArgs,
         cir::CallingConv::C, sideEffect, extraFnAttrs);
   } else {
-    callOp = builder.createCallOp(callLoc, directFuncOp, CIRCallArgs, callingConv,
-                                   sideEffect, extraFnAttrs);
+    callOp = builder.createCallOp(callLoc, directFuncOp, CIRCallArgs,
+                                  callingConv, sideEffect, extraFnAttrs);
   }
   if (cannotThrow)
     callOp->setAttr("nothrow", builder.getUnitAttr());
@@ -652,9 +652,10 @@ RValue CIRGenFunction::emitCall(const CIRGenFunctionInfo &CallInfo,
     auto extraFnAttrs = cir::ExtraFuncAttributesAttr::get(
         Attrs.getDictionary(&getMLIRContext()));
 
-    cir::CIRCallOpInterface callLikeOp = emitCallLikeOp(
-        *this, callLoc, indirectFuncTy, indirectFuncVal, directFuncOp,
-        CIRCallArgs, isInvoke, callingConv, sideEffect, extraFnAttrs, CannotThrow);
+    cir::CIRCallOpInterface callLikeOp =
+        emitCallLikeOp(*this, callLoc, indirectFuncTy, indirectFuncVal,
+                       directFuncOp, CIRCallArgs, isInvoke, callingConv,
+                       sideEffect, extraFnAttrs, CannotThrow);
 
     if (E)
       callLikeOp->setAttr("ast",
diff --git a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp
index 5aaf6af13..c16497b15 100644
--- a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp
+++ b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp
@@ -2937,14 +2937,26 @@ void cir::FuncOp::print(OpAsmPrinter &p) {
   function_interface_impl::printFunctionAttributes(
       p, *this,
       // These are all omitted since they are custom printed already.
-      {getAliaseeAttrName(), getBuiltinAttrName(), getCoroutineAttrName(),
-       getDsoLocalAttrName(), getNothrowAttrName(), getExtraAttrsAttrName(),
-       getFunctionTypeAttrName(), getGlobalCtorPriorityAttrName(),
-       getGlobalDtorPriorityAttrName(), getLambdaAttrName(),
-       getLinkageAttrName(), getCallingConvAttrName(), getNoProtoAttrName(),
-       getSymVisibilityAttrName(), getArgAttrsAttrName(), getResAttrsAttrName(),
-       getComdatAttrName(), getGlobalVisibilityAttrName(),
-       getAnnotationsAttrName(), getCxxSpecialMemberAttrName()});
+      {getAliaseeAttrName(),
+       getBuiltinAttrName(),
+       getCoroutineAttrName(),
+       getDsoLocalAttrName(),
+       getNothrowAttrName(),
+       getExtraAttrsAttrName(),
+       getFunctionTypeAttrName(),
+       getGlobalCtorPriorityAttrName(),
+       getGlobalDtorPriorityAttrName(),
+       getLambdaAttrName(),
+       getLinkageAttrName(),
+       getCallingConvAttrName(),
+       getNoProtoAttrName(),
+       getSymVisibilityAttrName(),
+       getArgAttrsAttrName(),
+       getResAttrsAttrName(),
+       getComdatAttrName(),
+       getGlobalVisibilityAttrName(),
+       getAnnotationsAttrName(),
+       getCxxSpecialMemberAttrName()});
 
   if (auto aliaseeName = getAliasee()) {
     p << " alias(";

@xlauko
xlauko force-pushed the users/xlauko/make-nothrow-explicit-attr branch from 5805186 to 418da21 Compare November 26, 2025 21:07
@xlauko
xlauko force-pushed the users/xlauko/simplify-function-attribute-checks branch from 9e47299 to b292185 Compare November 26, 2025 21:07

@bcardosolopes bcardosolopes left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this approach, LGTM when it comes out of draft + fixed failures

@xlauko
xlauko changed the base branch from users/xlauko/simplify-function-attribute-checks to graphite-base/2028 November 28, 2025 07:57
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants