Skip to content

Conversation

@xlauko
Copy link
Collaborator

@xlauko xlauko commented Nov 26, 2025

No description provided.

@xlauko
Copy link
Collaborator Author

xlauko commented Nov 26, 2025

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

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
Copy link

github-actions bot commented Nov 26, 2025

⚠️ 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
Copy link
Member

@bcardosolopes bcardosolopes left a comment

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 join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants