@@ -158,6 +158,7 @@ Non-comprehensive list of changes in this release
- Support parsing the `cc` operand modifier and alias it to the `c` modifier
(#GH127719).
- Added `__builtin_elementwise_exp10`.
+- Added `__builtin_is_modifiable_lvalue` to identify assignable arguments in
kees wrote:
Thanks for all the feedback! I'll continue working on this next week (I'm OoO
this week).
https://github.com/llvm/llvm-project/pull/132524
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listi
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -std=c99 -fsyntax-only -verify %s
pinskia wrote:
> This feels like a pretty bare bones set of tests, I think we can do better.
>
> For example, it has been discussed that there should not be side effects,
> let's verify that
@@ -12985,6 +12985,16 @@ bool IntExprEvaluator::VisitBuiltinCallExpr(const
CallExpr *E,
assert(Src.isInt());
return Success((Src.getInt() & (Alignment - 1)) == 0 ? 1 : 0, E);
}
+ case Builtin::BI__builtin_is_modifiable_lvalue: {
+const Expr *Arg = E->getArg(0);
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -std=c99 -fsyntax-only -verify %s
+
Sirraide wrote:
> Edit: Perhaps it's wanted to make this intrinsic accept VLA (and report
> `false`) and variably-modified types without evaluating the non-constant
> array size.
That sho
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm < %s| FileCheck %s
+
+void report(int value);
Sirraide wrote:
Yeah, all of these should just be sema tests using `static_assert`; maybe 1 or
2 codegen tests just to make sure we can emit
tbaederr wrote:
> > It looks like this is similar to `__builtin_constant_p` - what is the
> > proposed behavior wrt. side effects in the evaluated expression? gcc and
> > clang disagree about this a lot currently: https://godbolt.org/z/rbneznT9z
>
> IIUC this intrinsic shouldn't be similar to
https://github.com/frederick-vs-ja edited
https://github.com/llvm/llvm-project/pull/132524
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/frederick-vs-ja edited
https://github.com/llvm/llvm-project/pull/132524
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
frederick-vs-ja wrote:
> It looks like this is similar to `__builtin_constant_p` - what is the
> proposed behavior wrt. side effects in the evaluated expression? gcc and
> clang disagree about this a lot currently: https://godbolt.org/z/rbneznT9z
IIUC this intrinsic shouldn't be similar to `__
https://github.com/frederick-vs-ja edited
https://github.com/llvm/llvm-project/pull/132524
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -12985,6 +12985,16 @@ bool IntExprEvaluator::VisitBuiltinCallExpr(const
CallExpr *E,
assert(Src.isInt());
return Success((Src.getInt() & (Alignment - 1)) == 0 ? 1 : 0, E);
}
+ case Builtin::BI__builtin_is_modifiable_lvalue: {
+const Expr *Arg = E->getArg(0);
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -std=c99 -fsyntax-only -verify %s
+
frederick-vs-ja wrote:
Would it make more sense to use
`_Static_assert(__builtin_is_modifiable_lvalue(...), "")`?
Also, I think it would be valuable to cover more types.
N1570 6.3.2.1/1,
pinskia wrote:
Note the GCC implementtion of __builtin_is_modifiable_lvalue that I have
implemented (unlike __builtin_constant_p which in some but not all cases)
throws away the full expression that is inside __builtin_is_modifiable_lvalue
since it is fully implemented in the parser rather tha
kees wrote:
> It looks like this is similar to `__builtin_constant_p` - what is the
> proposed behavior wrt. side effects in the evaluated expression? gcc and
> clang disagree about this a lot currently: https://godbolt.org/z/rbneznT9z
It is intended to have no side-effects. I followed the sam
tbaederr wrote:
> > It looks like this is similar to `__builtin_constant_p` - what is the
> > proposed behavior wrt. side effects in the evaluated expression? gcc and
> > clang disagree about this a lot currently: https://godbolt.org/z/rbneznT9z
>
> It is intended to have no side-effects. I fo
tbaederr wrote:
It looks like this is similar to `__builtin_constant_p` - what is the proposed
behavior wrt. side effects in the evaluated expression? gcc and clang disagree
about this a lot currently: https://godbolt.org/z/rbneznT9z
https://github.com/llvm/llvm-project/pull/132524
___
https://github.com/tbaederr deleted
https://github.com/llvm/llvm-project/pull/132524
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
llvmbot wrote:
@llvm/pr-subscribers-clang
Author: Kees Cook (kees)
Changes
Provide a way to introspect expressions to see if they are assignable, which
becomes very useful in macros that want to perform additional work on arguments
that are lvalues. GCC is adding this builtin as well:
h
@@ -964,6 +964,13 @@ def IsConstantEvaluated : LangBuiltin<"CXX_LANG"> {
let Prototype = "bool()";
}
+def IsLValue : Builtin {
+ let Spellings = ["__builtin_is_modifiable_lvalue"];
+ let Attributes = [NoThrow, CustomTypeChecking, UnevaluatedArguments,
+
https://github.com/kees created https://github.com/llvm/llvm-project/pull/132524
Provide a way to introspect expressions to see if they are assignable, which
becomes very useful in macros that want to perform additional work on arguments
that are lvalues. GCC is adding this builtin as well:
ht
21 matches
Mail list logo