Skip to content

Commit e805b77

Browse files
committed
[clang][Interp] Support ObjCEncodeExprs
1 parent 32add24 commit e805b77

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

clang/lib/AST/Interp/ByteCodeExprGen.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1688,6 +1688,17 @@ bool ByteCodeExprGen<Emitter>::VisitObjCStringLiteral(
16881688
return this->delegate(E->getString());
16891689
}
16901690

1691+
template <class Emitter>
1692+
bool ByteCodeExprGen<Emitter>::VisitObjCEncodeExpr(const ObjCEncodeExpr *E) {
1693+
auto &A = Ctx.getASTContext();
1694+
std::string Str;
1695+
A.getObjCEncodingForType(E->getEncodedType(), Str);
1696+
StringLiteral *SL =
1697+
StringLiteral::Create(A, Str, StringLiteralKind::Ordinary,
1698+
/*Pascal=*/false, E->getType(), E->getAtLoc());
1699+
return this->delegate(SL);
1700+
}
1701+
16911702
template <class Emitter>
16921703
bool ByteCodeExprGen<Emitter>::VisitSYCLUniqueStableNameExpr(
16931704
const SYCLUniqueStableNameExpr *E) {

clang/lib/AST/Interp/ByteCodeExprGen.h

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

clang/test/CodeGenObjC/encode-test-3.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// RUN: %clang_cc1 -triple=i686-apple-darwin9 -emit-llvm -o - %s | FileCheck %s
2+
// RUN: %clang_cc1 -triple=i686-apple-darwin9 -emit-llvm -o - %s -fexperimental-new-constant-interpreter | FileCheck %s
23

34
int main(void) {
45
int n;

0 commit comments

Comments
 (0)