[llvm-branch-commits] [clang] [Clang][NFC] Pass Builtin::Info as an argument to Sema::BuildAtomicExpr (PR #185406)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Mar 9 05:37:51 PDT 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Sameer Sahasrabuddhe (ssahasra)
<details>
<summary>Changes</summary>
Assisted-By: Claude Sonnet 4.5
---
Full diff: https://github.com/llvm/llvm-project/pull/185406.diff
4 Files Affected:
- (modified) clang/include/clang/Basic/Builtins.h (+2-2)
- (modified) clang/include/clang/Sema/Sema.h (+3-1)
- (modified) clang/lib/Sema/SemaChecking.cpp (+6-3)
- (modified) clang/lib/Sema/TreeTransform.h (+1-1)
``````````diff
diff --git a/clang/include/clang/Basic/Builtins.h b/clang/include/clang/Basic/Builtins.h
index 2e661419ac6dc..adb88684c7a1d 100644
--- a/clang/include/clang/Basic/Builtins.h
+++ b/clang/include/clang/Basic/Builtins.h
@@ -466,12 +466,12 @@ class Context {
return strchr(getAttributesString(ID), 'G') != nullptr;
}
+ const Info &getInfo(unsigned ID) const { return getShardAndInfo(ID).second; }
+
private:
std::pair<const InfosShard &, const Info &>
getShardAndInfo(unsigned ID) const;
- const Info &getInfo(unsigned ID) const { return getShardAndInfo(ID).second; }
-
/// Helper function for isPrintfLike and isScanfLike.
bool isLike(unsigned ID, unsigned &FormatIdx, bool &HasVAListArg,
const char *Fmt) const;
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 5917eb0ffbfe1..ed5744bcd6962 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -2738,6 +2738,7 @@ class Sema final : public SemaBase {
BuildAtomicExpr(SourceRange CallRange, SourceRange ExprRange,
SourceLocation RParenLoc, MultiExprArg Args,
AtomicExpr::AtomicOp Op,
+ const Builtin::Info *BuiltinInfo = nullptr,
AtomicArgumentOrder ArgOrder = AtomicArgumentOrder::API);
/// Check to see if a given expression could have '.c_str()' called on it.
@@ -3032,7 +3033,8 @@ class Sema final : public SemaBase {
/// builtins.
ExprResult BuiltinNontemporalOverloaded(ExprResult TheCallResult);
ExprResult AtomicOpsOverloaded(ExprResult TheCallResult,
- AtomicExpr::AtomicOp Op);
+ AtomicExpr::AtomicOp Op,
+ const Builtin::Info *BuiltinInfo);
/// \param FPOnly restricts the arguments to floating-point types.
bool BuiltinElementwiseMath(CallExpr *TheCall,
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 85aa21f2480fb..ba9890296ef96 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -3210,7 +3210,8 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID,
}
#define ATOMIC_BUILTIN(ID, TYPE, ATTRS, LANGS) \
case Builtin::BI##ID: \
- return AtomicOpsOverloaded(TheCallResult, AtomicExpr::AO##ID);
+ return AtomicOpsOverloaded(TheCallResult, AtomicExpr::AO##ID, \
+ &Context.BuiltinInfo.getInfo(Builtin::BI##ID));
#include "clang/Basic/Builtins.inc"
case Builtin::BI__annotation:
if (BuiltinMSVCAnnotation(*this, TheCall))
@@ -4558,18 +4559,20 @@ static bool isValidOrderingForOp(int64_t Ordering, AtomicExpr::AtomicOp Op) {
}
ExprResult Sema::AtomicOpsOverloaded(ExprResult TheCallResult,
- AtomicExpr::AtomicOp Op) {
+ AtomicExpr::AtomicOp Op,
+ const Builtin::Info *BuiltinInfo) {
CallExpr *TheCall = cast<CallExpr>(TheCallResult.get());
DeclRefExpr *DRE =cast<DeclRefExpr>(TheCall->getCallee()->IgnoreParenCasts());
MultiExprArg Args{TheCall->getArgs(), TheCall->getNumArgs()};
return BuildAtomicExpr({TheCall->getBeginLoc(), TheCall->getEndLoc()},
DRE->getSourceRange(), TheCall->getRParenLoc(), Args,
- Op);
+ Op, BuiltinInfo);
}
ExprResult Sema::BuildAtomicExpr(SourceRange CallRange, SourceRange ExprRange,
SourceLocation RParenLoc, MultiExprArg Args,
AtomicExpr::AtomicOp Op,
+ const Builtin::Info *BuiltinInfo,
AtomicArgumentOrder ArgOrder) {
// All the non-OpenCL operations take one of the following forms.
// The OpenCL operations take the __c11 forms with one extra argument for
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index b5272d262530c..9586df974b7ab 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -4163,7 +4163,7 @@ class TreeTransform {
// between the call and the expr at this point.
SourceRange Range{BuiltinLoc, RParenLoc};
return getSema().BuildAtomicExpr(Range, Range, RParenLoc, SubExprs, Op,
- Sema::AtomicArgumentOrder::AST);
+ nullptr, Sema::AtomicArgumentOrder::AST);
}
ExprResult RebuildRecoveryExpr(SourceLocation BeginLoc, SourceLocation EndLoc,
``````````
</details>
https://github.com/llvm/llvm-project/pull/185406
More information about the llvm-branch-commits
mailing list