[clang] [APINotes] Upstream Sema logic to apply API Notes to decls (PR #73017)

Saleem Abdulrasool via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 12 10:18:27 PST 2024


================
@@ -15139,6 +15139,37 @@ void Sema::DiagnoseSizeOfParametersAndReturnValue(
   }
 }
 
+QualType Sema::AdjustParameterTypeForObjCAutoRefCount(QualType T,
+                                                      SourceLocation NameLoc,
+                                                      TypeSourceInfo *TSInfo) {
+  // In ARC, infer a lifetime qualifier for appropriate parameter types.
+  if (getLangOpts().ObjCAutoRefCount &&
+      T.getObjCLifetime() == Qualifiers::OCL_None && T->isObjCLifetimeType()) {
+
+    Qualifiers::ObjCLifetime Lifetime;
+
+    // Special cases for arrays:
+    //   - if it's const, use __unsafe_unretained
+    //   - otherwise, it's an error
+    if (T->isArrayType()) {
----------------
compnerd wrote:

I wonder if this is valuable to sink into `QualType`.

https://github.com/llvm/llvm-project/pull/73017


More information about the cfe-commits mailing list