aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Sema/SemaChecking.cpp
diff options
context:
space:
mode:
authorManuelJBrito <manuel.brito@tecnico.ulisboa.pt>2023-02-02 17:42:31 +0000
committerManuelJBrito <manuel.brito@tecnico.ulisboa.pt>2023-02-03 09:47:46 +0000
commit450a4612c39cc150879a0f0ffffe692adfc1d0d9 (patch)
treedc86628a240e86e6f69f062337817ceae47a3004 /clang/lib/Sema/SemaChecking.cpp
parent2adcf1b25d03402278892f88d467c667a6fdd938 (diff)
downloadllvm-450a4612c39cc150879a0f0ffffe692adfc1d0d9.zip
llvm-450a4612c39cc150879a0f0ffffe692adfc1d0d9.tar.gz
llvm-450a4612c39cc150879a0f0ffffe692adfc1d0d9.tar.bz2
[Clang] Add builtin_nondeterministic_value
Differential Revision: https://reviews.llvm.org/D142388
Diffstat (limited to 'clang/lib/Sema/SemaChecking.cpp')
-rw-r--r--clang/lib/Sema/SemaChecking.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index f1c4aab..efba0a8 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -2584,6 +2584,12 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID,
break;
}
+ case Builtin::BI__builtin_nondeterministic_value: {
+ if (SemaBuiltinNonDeterministicValue(TheCall))
+ return ExprError();
+ break;
+ }
+
// __builtin_elementwise_abs restricts the element type to signed integers or
// floating point types only.
case Builtin::BI__builtin_elementwise_abs: {
@@ -17858,6 +17864,21 @@ bool Sema::PrepareBuiltinReduceMathOneArgCall(CallExpr *TheCall) {
return false;
}
+bool Sema::SemaBuiltinNonDeterministicValue(CallExpr *TheCall) {
+ if (checkArgCount(*this, TheCall, 1))
+ return true;
+
+ ExprResult Arg = TheCall->getArg(0);
+ QualType TyArg = Arg.get()->getType();
+
+ if (!TyArg->isBuiltinType() && !TyArg->isVectorType())
+ return Diag(TheCall->getArg(0)->getBeginLoc(), diag::err_builtin_invalid_arg_type)
+ << 1 << /*vector, integer or floating point ty*/ 0 << TyArg;
+
+ TheCall->setType(TyArg);
+ return false;
+}
+
ExprResult Sema::SemaBuiltinMatrixTranspose(CallExpr *TheCall,
ExprResult CallResult) {
if (checkArgCount(*this, TheCall, 1))