@@ -1006,6 +1006,14 @@ inline bool CmpHelper<Pointer>(InterpState &S, CodePtr OpPC, CompareFn Fn) {
1006
1006
}
1007
1007
}
1008
1008
1009
+ static inline bool IsOpaqueConstantCall (const CallExpr *E) {
1010
+ unsigned Builtin = E->getBuiltinCallee ();
1011
+ return (Builtin == Builtin::BI__builtin___CFStringMakeConstantString ||
1012
+ Builtin == Builtin::BI__builtin___NSStringMakeConstantString ||
1013
+ Builtin == Builtin::BI__builtin_ptrauth_sign_constant ||
1014
+ Builtin == Builtin::BI__builtin_function_start);
1015
+ }
1016
+
1009
1017
template <>
1010
1018
inline bool CmpHelperEQ<Pointer>(InterpState &S, CodePtr OpPC, CompareFn Fn) {
1011
1019
using BoolT = PrimConv<PT_Bool>::T;
@@ -1065,11 +1073,19 @@ inline bool CmpHelperEQ<Pointer>(InterpState &S, CodePtr OpPC, CompareFn Fn) {
1065
1073
for (const auto &P : {LHS, RHS}) {
1066
1074
if (P.isZero ())
1067
1075
continue ;
1068
- if (BothNonNull && P.pointsToLiteral () &&
1069
- isa<StringLiteral>(P.getDeclDesc ()->asExpr ())) {
1070
- const SourceInfo &Loc = S.Current ->getSource (OpPC);
1071
- S.FFDiag (Loc, diag::note_constexpr_literal_comparison);
1072
- return false ;
1076
+ if (BothNonNull && P.pointsToLiteral ()) {
1077
+ const Expr *E = P.getDeclDesc ()->asExpr ();
1078
+ if (isa<StringLiteral>(E)) {
1079
+ const SourceInfo &Loc = S.Current ->getSource (OpPC);
1080
+ S.FFDiag (Loc, diag::note_constexpr_literal_comparison);
1081
+ return false ;
1082
+ } else if (const auto *CE = dyn_cast<CallExpr>(E);
1083
+ CE && IsOpaqueConstantCall (CE)) {
1084
+ const SourceInfo &Loc = S.Current ->getSource (OpPC);
1085
+ S.FFDiag (Loc, diag::note_constexpr_opaque_call_comparison)
1086
+ << P.toDiagnosticString (S.getASTContext ());
1087
+ return false ;
1088
+ }
1073
1089
}
1074
1090
}
1075
1091
0 commit comments