23
23
namespace clang {
24
24
namespace interp {
25
25
26
+ static bool isNoopBuiltin (unsigned ID) {
27
+ switch (ID) {
28
+ case Builtin::BIas_const:
29
+ case Builtin::BIforward:
30
+ case Builtin::BIforward_like:
31
+ case Builtin::BImove:
32
+ case Builtin::BImove_if_noexcept:
33
+ case Builtin::BIaddressof:
34
+ case Builtin::BI__addressof:
35
+ case Builtin::BI__builtin_addressof:
36
+ case Builtin::BI__builtin_launder:
37
+ return true ;
38
+ default :
39
+ return false ;
40
+ }
41
+ return false ;
42
+ }
43
+
26
44
static unsigned callArgSize (const InterpState &S, const CallExpr *C) {
27
45
unsigned O = 0 ;
28
46
@@ -100,6 +118,8 @@ static bool retBI(InterpState &S, const CallExpr *Call, unsigned BuiltinID) {
100
118
static bool retPrimValue (InterpState &S, CodePtr OpPC,
101
119
std::optional<PrimType> &T, const CallExpr *Call,
102
120
unsigned BuiltinID) {
121
+ if (isNoopBuiltin (BuiltinID))
122
+ return true ;
103
123
104
124
if (!T) {
105
125
if (!Context::isUnevaluatedBuiltin (BuiltinID)) {
@@ -745,24 +765,14 @@ static bool interp__builtin_addressof(InterpState &S, CodePtr OpPC,
745
765
const CallExpr *Call) {
746
766
assert (Call->getArg (0 )->isLValue ());
747
767
PrimType PtrT = S.getContext ().classify (Call->getArg (0 )).value_or (PT_Ptr);
748
-
749
- if (PtrT == PT_Ptr) {
750
- const Pointer &Arg = S.Stk .peek <Pointer>();
751
- S.Stk .push <Pointer>(Arg);
752
- } else {
753
- assert (false && " Unsupported pointer type passed to __builtin_addressof()" );
754
- }
768
+ assert (PtrT == PT_Ptr &&
769
+ " Unsupported pointer type passed to __builtin_addressof()" );
755
770
return true ;
756
771
}
757
772
758
773
static bool interp__builtin_move (InterpState &S, CodePtr OpPC,
759
774
const InterpFrame *Frame,
760
775
const CallExpr *Call) {
761
-
762
- PrimType ArgT = S.getContext ().classify (Call->getArg (0 )).value_or (PT_Ptr);
763
-
764
- TYPE_SWITCH (ArgT, const T &Arg = S.Stk .peek <T>(); S.Stk .push <T>(Arg););
765
-
766
776
return Call->getDirectCallee ()->isConstexpr ();
767
777
}
768
778
@@ -778,13 +788,6 @@ static bool interp__builtin_eh_return_data_regno(InterpState &S, CodePtr OpPC,
778
788
return true ;
779
789
}
780
790
781
- // / Just takes the first Argument to the call and puts it on the stack.
782
- static bool noopPointer (InterpState &S) {
783
- const Pointer &Arg = S.Stk .peek <Pointer>();
784
- S.Stk .push <Pointer>(Arg);
785
- return true ;
786
- }
787
-
788
791
// Two integral values followed by a pointer (lhs, rhs, resultOut)
789
792
static bool interp__builtin_overflowop (InterpState &S, CodePtr OpPC,
790
793
const CallExpr *Call,
@@ -2507,6 +2510,7 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const CallExpr *Call,
2507
2510
case Builtin::BIaddressof:
2508
2511
case Builtin::BI__addressof:
2509
2512
case Builtin::BI__builtin_addressof:
2513
+ assert (isNoopBuiltin (BuiltinID));
2510
2514
if (!interp__builtin_addressof (S, OpPC, Frame, Call))
2511
2515
return false ;
2512
2516
break ;
@@ -2516,6 +2520,7 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const CallExpr *Call,
2516
2520
case Builtin::BIforward_like:
2517
2521
case Builtin::BImove:
2518
2522
case Builtin::BImove_if_noexcept:
2523
+ assert (isNoopBuiltin (BuiltinID));
2519
2524
if (!interp__builtin_move (S, OpPC, Frame, Call))
2520
2525
return false ;
2521
2526
break ;
@@ -2526,8 +2531,7 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const CallExpr *Call,
2526
2531
break ;
2527
2532
2528
2533
case Builtin::BI__builtin_launder:
2529
- if (!noopPointer (S))
2530
- return false ;
2534
+ assert (isNoopBuiltin (BuiltinID));
2531
2535
break ;
2532
2536
2533
2537
case Builtin::BI__builtin_add_overflow:
0 commit comments