Skip to content

Commit 5220b7b

Browse files
committed
[clang][Interp] Handle objc strings
1 parent 70d6e7c commit 5220b7b

File tree

4 files changed

+13
-1
lines changed

4 files changed

+13
-1
lines changed

clang/lib/AST/Interp/ByteCodeExprGen.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1637,6 +1637,12 @@ bool ByteCodeExprGen<Emitter>::VisitStringLiteral(const StringLiteral *E) {
16371637
return true;
16381638
}
16391639

1640+
template <class Emitter>
1641+
bool ByteCodeExprGen<Emitter>::VisitObjCStringLiteral(
1642+
const ObjCStringLiteral *E) {
1643+
return this->delegate(E->getString());
1644+
}
1645+
16401646
template <class Emitter>
16411647
bool ByteCodeExprGen<Emitter>::VisitSYCLUniqueStableNameExpr(
16421648
const SYCLUniqueStableNameExpr *E) {

clang/lib/AST/Interp/ByteCodeExprGen.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ class ByteCodeExprGen : public ConstStmtVisitor<ByteCodeExprGen<Emitter>, bool>,
9090
bool VisitOpaqueValueExpr(const OpaqueValueExpr *E);
9191
bool VisitAbstractConditionalOperator(const AbstractConditionalOperator *E);
9292
bool VisitStringLiteral(const StringLiteral *E);
93+
bool VisitObjCStringLiteral(const ObjCStringLiteral *E);
9394
bool VisitSYCLUniqueStableNameExpr(const SYCLUniqueStableNameExpr *E);
9495
bool VisitCharacterLiteral(const CharacterLiteral *E);
9596
bool VisitCompoundAssignOperator(const CompoundAssignOperator *E);

clang/lib/AST/Interp/Context.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ std::optional<PrimType> Context::classify(QualType T) const {
164164
T->isFunctionType() || T->isSpecificBuiltinType(BuiltinType::BoundMember))
165165
return PT_FnPtr;
166166

167-
if (T->isReferenceType() || T->isPointerType())
167+
if (T->isReferenceType() || T->isPointerType() ||
168+
T->isObjCObjectPointerType())
168169
return PT_Ptr;
169170

170171
if (const auto *AT = T->getAs<AtomicType>())

clang/test/AST/Interp/objc.mm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,7 @@ @interface A {
66
static_assert(a, ""); // both-error {{static assertion expression is not an integral constant expression}}
77
}
88
@end
9+
10+
@interface NSString
11+
@end
12+
constexpr NSString *t0 = @"abc";

0 commit comments

Comments
 (0)