================
@@ -875,6 +948,24 @@ ExprResult SemaObjC::BuildObjCArrayLiteral(SourceRange SR,
   QualType ObjectsType = ArrayWithObjectsMethod->parameters()[0]->getType();
   QualType RequiredType = ObjectsType->castAs<PointerType>()->getPointeeType();
 
+  const LangOptions &LangOpts = getLangOpts();
+
+  bool ExpressibleAsConstantInitLiteral = LangOpts.ConstantNSArrayLiterals;
+
+  // ExpressibleAsConstantInitLiteral isn't meaningful for dependent literals.
+  if (ExpressibleAsConstantInitLiteral &&
+      llvm::any_of(Elements,
+                   [](Expr *Elem) { return Elem->isValueDependent(); }))
+    ExpressibleAsConstantInitLiteral = false;
+
+  // We can stil emit a constant empty array
+  if (LangOpts.ObjCConstantLiterals && Elements.size() == 0) {
+    assert(LangOpts.ObjCRuntime.hasConstantEmptyCollections() &&
+           "The current ABI doesn't support an empty constant NSArray "
+           "singleton!");
----------------
ojhunt wrote:

I haven't yet looked at all this files, but is it possible for a user to hit 
this with "correct" code but incorrect config? (e.g. should this be an error 
rather than an assert)

Or a warning and set ExpressibleAsConstantInitLiteral to false?

https://github.com/llvm/llvm-project/pull/185130
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to