[clang] [clang][Interp] Ignore ObjCBoxedExpr subexpr... (PR #102136)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 6 06:06:16 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Timm Baeder (tbaederr)
<details>
<summary>Changes</summary>
... if it can't be expressed as a constant initializer.
---
Full diff: https://github.com/llvm/llvm-project/pull/102136.diff
2 Files Affected:
- (modified) clang/lib/AST/Interp/Compiler.cpp (+3-2)
- (modified) clang/test/AST/Interp/objc.mm (+25)
``````````diff
diff --git a/clang/lib/AST/Interp/Compiler.cpp b/clang/lib/AST/Interp/Compiler.cpp
index 02cbe38f5fb1f..95f4fe9bd0bec 100644
--- a/clang/lib/AST/Interp/Compiler.cpp
+++ b/clang/lib/AST/Interp/Compiler.cpp
@@ -3161,10 +3161,11 @@ bool Compiler<Emitter>::VisitExtVectorElementExpr(
template <class Emitter>
bool Compiler<Emitter>::VisitObjCBoxedExpr(const ObjCBoxedExpr *E) {
+ const Expr *SubExpr = E->getSubExpr();
if (!E->isExpressibleAsConstantInitializer())
- return this->emitInvalid(E);
+ return this->discard(SubExpr) && this->emitInvalid(E);
- return this->delegate(E->getSubExpr());
+ return this->delegate(SubExpr);
}
template <class Emitter>
diff --git a/clang/test/AST/Interp/objc.mm b/clang/test/AST/Interp/objc.mm
index 6402c8ae098fd..f6c4ba12dc5d1 100644
--- a/clang/test/AST/Interp/objc.mm
+++ b/clang/test/AST/Interp/objc.mm
@@ -11,3 +11,28 @@ @interface NSString
@end
constexpr NSString *t0 = @"abc";
constexpr NSString *t1 = @("abc");
+
+
+#if __LP64__
+typedef unsigned long NSUInteger;
+typedef long NSInteger;
+#else
+typedef unsigned int NSUInteger;
+typedef int NSInteger;
+#endif
+
+
+ at class NSNumber;
+
+
+ at interface NSObject
++ (NSObject*)nsobject;
+ at end
+
+ at interface NSNumber : NSObject
++ (NSNumber *)numberWithInt:(int)value;
+ at end
+
+int main(void) {
+ NSNumber *bv = @(1391126400 * 1000); // both-warning {{overflow in expression; result is -443'003'904 with type 'int'}}
+}
``````````
</details>
https://github.com/llvm/llvm-project/pull/102136
More information about the cfe-commits
mailing list