[clang] [APINotes] Upstream the remaining API Notes fixes and tests (PR #84773)

2024-03-27 Thread Egor Zhdan via cfe-commits

https://github.com/egorzhdan closed 
https://github.com/llvm/llvm-project/pull/84773
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [APINotes] Upstream the remaining API Notes fixes and tests (PR #84773)

2024-03-27 Thread Egor Zhdan via cfe-commits

egorzhdan wrote:

I'm going to land this patch now to unblock other work on APINotes, but I'm 
happy to address more review feedback post-merge.

https://github.com/llvm/llvm-project/pull/84773
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [APINotes] Upstream the remaining API Notes fixes and tests (PR #84773)

2024-03-25 Thread Egor Zhdan via cfe-commits

egorzhdan wrote:

@compnerd I think I addressed all of your comments, let me know if this is good 
to go!

https://github.com/llvm/llvm-project/pull/84773
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [APINotes] Upstream the remaining API Notes fixes and tests (PR #84773)

2024-03-20 Thread Egor Zhdan via cfe-commits


@@ -52,49 +52,54 @@ static void applyNullability(Sema , Decl *D, 
NullabilityKind Nullability,
   if (!Metadata.IsActive)
 return;
 
-  auto IsModified = [&](Decl *D, QualType QT,
-NullabilityKind Nullability) -> bool {
+  auto GetModified =
+  [&](Decl *D, QualType QT,
+  NullabilityKind Nullability) -> std::optional {
 QualType Original = QT;
 S.CheckImplicitNullabilityTypeSpecifier(QT, Nullability, D->getLocation(),
 isa(D),
 /*OverrideExisting=*/true);
-return QT.getTypePtr() != Original.getTypePtr();
+return (QT.getTypePtr() != Original.getTypePtr()) ? std::optional(QT)
+  : std::nullopt;
   };
 
   if (auto Function = dyn_cast(D)) {
-if (IsModified(D, Function->getReturnType(), Nullability)) {
-  QualType FnType = Function->getType();
-  Function->setType(FnType);
+if (auto Modified =
+GetModified(D, Function->getReturnType(), Nullability)) {
+  const FunctionType *FnType = Function->getType()->castAs();
+  if (const FunctionProtoType *proto = dyn_cast(FnType))
+Function->setType(S.Context.getFunctionType(
+*Modified, proto->getParamTypes(), proto->getExtProtoInfo()));
+  else
+Function->setType(
+S.Context.getFunctionNoProtoType(*Modified, FnType->getExtInfo()));
 }
   } else if (auto Method = dyn_cast(D)) {
-QualType Type = Method->getReturnType();
-if (IsModified(D, Type, Nullability)) {
-  Method->setReturnType(Type);
+if (auto Modified = GetModified(D, Method->getReturnType(), Nullability)) {
+  Method->setReturnType(*Modified);
 
   // Make it a context-sensitive keyword if we can.
-  if (!isIndirectPointerType(Type))
+  if (!isIndirectPointerType(*Modified))
 Method->setObjCDeclQualifier(Decl::ObjCDeclQualifier(
 Method->getObjCDeclQualifier() | Decl::OBJC_TQ_CSNullability));
 }
   } else if (auto Value = dyn_cast(D)) {
-QualType Type = Value->getType();
-if (IsModified(D, Type, Nullability)) {
-  Value->setType(Type);
+if (auto Modified = GetModified(D, Value->getType(), Nullability)) {
+  Value->setType(*Modified);
 
   // Make it a context-sensitive keyword if we can.
   if (auto Parm = dyn_cast(D)) {
-if (Parm->isObjCMethodParameter() && !isIndirectPointerType(Type))
+if (Parm->isObjCMethodParameter() && !isIndirectPointerType(*Modified))
   Parm->setObjCDeclQualifier(Decl::ObjCDeclQualifier(
   Parm->getObjCDeclQualifier() | Decl::OBJC_TQ_CSNullability));
   }
 }
   } else if (auto Property = dyn_cast(D)) {
-QualType Type = Property->getType();
-if (IsModified(D, Type, Nullability)) {
-  Property->setType(Type, Property->getTypeSourceInfo());
+if (auto Modified = GetModified(D, Property->getType(), Nullability)) {
+  Property->setType(*Modified, Property->getTypeSourceInfo());
 
   // Make it a property attribute if we can.
-  if (!isIndirectPointerType(Type))
+  if (!isIndirectPointerType(*Modified))
 Property->setPropertyAttributes(
 ObjCPropertyAttribute::kind_null_resettable);
 }

egorzhdan wrote:

Good point, we don't have a test for this, let me add one

https://github.com/llvm/llvm-project/pull/84773
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [APINotes] Upstream the remaining API Notes fixes and tests (PR #84773)

2024-03-20 Thread Egor Zhdan via cfe-commits


@@ -0,0 +1,44 @@
+// RUN: rm -rf %t && mkdir -p %t
+// RUN: %clang_cc1 -fmodules  -fimplicit-module-maps 
-fmodules-cache-path=%t/ModulesCache -fapinotes-modules -Wno-private-module 
-fsyntax-only -I %S/Inputs/Headers -F %S/Inputs/Frameworks %s -verify
+
+// Test with Swift version 3.0. This should only affect the few APIs that have 
an entry in the 3.0 tables.

egorzhdan wrote:

Yes, in a sense that API Notes that apply attributes specific to Swift version 
3.0 still exist in the SDK, and can be read by the compiler.

https://github.com/llvm/llvm-project/pull/84773
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [APINotes] Upstream the remaining API Notes fixes and tests (PR #84773)

2024-03-20 Thread Egor Zhdan via cfe-commits


@@ -0,0 +1,4 @@
+Name: SomeBrokenLib
+Functions:
+  - Name: do_something_with_pointers
+Nu llabilityOfRet: O

egorzhdan wrote:

Alright, I added a comment

https://github.com/llvm/llvm-project/pull/84773
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [APINotes] Upstream the remaining API Notes fixes and tests (PR #84773)

2024-03-20 Thread Egor Zhdan via cfe-commits


@@ -638,15 +638,15 @@ ObjCPropertyDecl *Sema::CreatePropertyDecl(Scope *S,
 PDecl->setInvalidDecl();
   }
 
-  ProcessDeclAttributes(S, PDecl, FD.D);
-
   // Regardless of setter/getter attribute, we save the default getter/setter
   // selector names in anticipation of declaration of setter/getter methods.
   PDecl->setGetterName(GetterSel, GetterNameLoc);
   PDecl->setSetterName(SetterSel, SetterNameLoc);
   PDecl->setPropertyAttributesAsWritten(
   
makePropertyAttributesAsWritten(AttributesAsWritten));
 
+  ProcessDeclAttributes(S, PDecl, FD.D);
+
   if (Attributes & ObjCPropertyAttribute::kind_readonly)
 PDecl->setPropertyAttributes(ObjCPropertyAttribute::kind_readonly);
 

egorzhdan wrote:

We have a test for this in this PR, `properties.m` – that's how I discovered 
this :)

https://github.com/llvm/llvm-project/pull/84773
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [APINotes] Upstream the remaining API Notes fixes and tests (PR #84773)

2024-03-19 Thread Saleem Abdulrasool via cfe-commits


@@ -0,0 +1,6 @@
+// RUN: rm -rf %t
+// RUN: not %clang_cc1 -fsyntax-only -fapinotes  %s -I 
%S/Inputs/BrokenHeaders2 2>&1 | FileCheck %s

compnerd wrote:

Extra space after `-fapinotes`

https://github.com/llvm/llvm-project/pull/84773
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [APINotes] Upstream the remaining API Notes fixes and tests (PR #84773)

2024-03-19 Thread Saleem Abdulrasool via cfe-commits


@@ -0,0 +1 @@
+extern int TopLevelPrivateKit_Public;

compnerd wrote:

Missing newline

https://github.com/llvm/llvm-project/pull/84773
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [APINotes] Upstream the remaining API Notes fixes and tests (PR #84773)

2024-03-19 Thread Saleem Abdulrasool via cfe-commits


@@ -0,0 +1,2 @@
+#include 
+extern int FrameworkWithActualPrivateModule_Private;

compnerd wrote:

Missing newline

https://github.com/llvm/llvm-project/pull/84773
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [APINotes] Upstream the remaining API Notes fixes and tests (PR #84773)

2024-03-19 Thread Saleem Abdulrasool via cfe-commits


@@ -0,0 +1 @@
+extern int FrameworkWithWrongCase;

compnerd wrote:

Missing newline

https://github.com/llvm/llvm-project/pull/84773
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [APINotes] Upstream the remaining API Notes fixes and tests (PR #84773)

2024-03-19 Thread Saleem Abdulrasool via cfe-commits


@@ -0,0 +1,55 @@
+#ifndef SOMEKIT_H
+#define SOMEKIT_H
+
+#define ROOT_CLASS __attribute__((objc_root_class))
+
+ROOT_CLASS
+@interface A
+-(A*)transform:(A*)input;
+-(A*)transform:(A*)input integer:(int)integer;
+
+@property (nonatomic, readonly, retain) A* someA;
+@property (nonatomic, retain) A* someOtherA;
+
+@property (nonatomic) int intValue;
+@end
+
+@interface B : A
+@end
+
+@interface C : A
+- (instancetype)init;
+- (instancetype)initWithA:(A*)a;
+@end
+
+
+@interface MyClass : A
+- Inst;
++ Clas;
+@end
+
+struct CGRect {
+  float origin;
+  float size;
+};
+typedef struct CGRect NSRect;
+
+@interface I
+- (void) Meth : (NSRect[4])exposedRects;
+- (void) Meth1 : (const  I*)exposedRects;
+- (void) Meth2 : (const I*)exposedRects;
+- (void) Meth3 : (I*)exposedRects;
+- (const I*) Meth4;
+- (const I*) Meth5 : (int) Arg1 : (const I*)Arg2 : (double)Arg3 :   (const I*) 
Arg4 :(const  volatile id) Arg5;
+- (volatile const I*) Meth6 : (const char *)Arg1 : (const char *)Arg2 : 
(double)Arg3 :   (const I*) Arg4 :(const  volatile id) Arg5;
+@end
+
+@class NSURL,  NSArray, NSError;

compnerd wrote:

Extra space after the initial comma.

https://github.com/llvm/llvm-project/pull/84773
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [APINotes] Upstream the remaining API Notes fixes and tests (PR #84773)

2024-03-19 Thread Saleem Abdulrasool via cfe-commits


@@ -0,0 +1,187 @@
+// RUN: rm -rf %t && mkdir -p %t
+
+// Build and check the unversioned module file.
+// RUN: %clang_cc1 -fmodules -fblocks -fimplicit-module-maps 
-fmodules-cache-path=%t/ModulesCache/Unversioned -fdisable-module-hash 
-fapinotes-modules  -fsyntax-only -I %S/Inputs/Headers -F %S/Inputs/Frameworks 
%s
+// RUN: %clang_cc1 -ast-print %t/ModulesCache/Unversioned/VersionedKit.pcm | 
FileCheck -check-prefix=CHECK-UNVERSIONED %s
+// RUN: %clang_cc1 -fmodules -fblocks -fimplicit-module-maps 
-fmodules-cache-path=%t/ModulesCache/Unversioned -fdisable-module-hash 
-fapinotes-modules  -fsyntax-only -I %S/Inputs/Headers -F %S/Inputs/Frameworks 
%s -ast-dump -ast-dump-filter 'DUMP' | FileCheck -check-prefix=CHECK-DUMP 
-check-prefix=CHECK-UNVERSIONED-DUMP %s
+
+// Build and check the versioned module file.
+// RUN: %clang_cc1 -fmodules -fblocks -fimplicit-module-maps 
-fmodules-cache-path=%t/ModulesCache/Versioned -fdisable-module-hash 
-fapinotes-modules  -fapinotes-swift-version=3 -fsyntax-only -I 
%S/Inputs/Headers -F %S/Inputs/Frameworks %s
+// RUN: %clang_cc1 -ast-print %t/ModulesCache/Versioned/VersionedKit.pcm | 
FileCheck -check-prefix=CHECK-VERSIONED %s
+// RUN: %clang_cc1 -fmodules -fblocks -fimplicit-module-maps 
-fmodules-cache-path=%t/ModulesCache/Versioned -fdisable-module-hash 
-fapinotes-modules  -fapinotes-swift-version=3 -fsyntax-only -I 
%S/Inputs/Headers -F %S/Inputs/Frameworks %s -ast-dump -ast-dump-filter 'DUMP' 
| FileCheck -check-prefix=CHECK-DUMP -check-prefix=CHECK-VERSIONED-DUMP %s

compnerd wrote:

And here

https://github.com/llvm/llvm-project/pull/84773
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [APINotes] Upstream the remaining API Notes fixes and tests (PR #84773)

2024-03-19 Thread Saleem Abdulrasool via cfe-commits


@@ -0,0 +1,37 @@
+Name: HeaderLib
+SwiftInferImportAsMember: true
+Functions:
+  - Name: custom_realloc
+NullabilityOfRet: N
+Nullability: [ N, S ]
+  - Name: unavailable_function
+Availability: none
+AvailabilityMsg: "I beg you not to use this"
+  - Name: do_something_with_pointers
+NullabilityOfRet: O
+Nullability: [ N, O ]
+  - Name: do_something_with_arrays
+Parameters:
+  - Position: 0
+Nullability: N
+  - Position: 1
+Nullability: N
+  - Name: take_pointer_and_int
+Parameters:
+  - Position: 0
+Nullability: N
+NoEscape: true
+  - Position: 1
+NoEscape: true
+Globals:
+  - Name: global_int
+Nullability: N
+  - Name: unavailable_global_int
+Availability: none
+Tags:
+  - Name: unavailable_struct
+Availability: none
+
+Typedefs:
+  - Name: unavailable_typedef
+Availability: none

compnerd wrote:

Missing newline

https://github.com/llvm/llvm-project/pull/84773
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [APINotes] Upstream the remaining API Notes fixes and tests (PR #84773)

2024-03-19 Thread Saleem Abdulrasool via cfe-commits


@@ -0,0 +1 @@
+garbage here because this file shouldn't get read

compnerd wrote:

Missing newline

https://github.com/llvm/llvm-project/pull/84773
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [APINotes] Upstream the remaining API Notes fixes and tests (PR #84773)

2024-03-19 Thread Saleem Abdulrasool via cfe-commits


@@ -0,0 +1 @@
+extern int PrivateLib;

compnerd wrote:

Missing newline

https://github.com/llvm/llvm-project/pull/84773
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [APINotes] Upstream the remaining API Notes fixes and tests (PR #84773)

2024-03-19 Thread Saleem Abdulrasool via cfe-commits


@@ -0,0 +1,44 @@
+// RUN: rm -rf %t && mkdir -p %t
+// RUN: %clang_cc1 -fmodules  -fimplicit-module-maps 
-fmodules-cache-path=%t/ModulesCache -fapinotes-modules -Wno-private-module 
-fsyntax-only -I %S/Inputs/Headers -F %S/Inputs/Frameworks %s -verify
+
+// Test with Swift version 3.0. This should only affect the few APIs that have 
an entry in the 3.0 tables.

compnerd wrote:

Hmm, do we still support Swift 3 in the Swift compiler even?

https://github.com/llvm/llvm-project/pull/84773
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [APINotes] Upstream the remaining API Notes fixes and tests (PR #84773)

2024-03-19 Thread Saleem Abdulrasool via cfe-commits


@@ -0,0 +1 @@
+garbage here because this file shouldn't get read

compnerd wrote:

Missing newline

https://github.com/llvm/llvm-project/pull/84773
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [APINotes] Upstream the remaining API Notes fixes and tests (PR #84773)

2024-03-19 Thread Saleem Abdulrasool via cfe-commits


@@ -0,0 +1 @@
+extern int FrameworkWithActualPrivateModule;

compnerd wrote:

Missing newline

https://github.com/llvm/llvm-project/pull/84773
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [APINotes] Upstream the remaining API Notes fixes and tests (PR #84773)

2024-03-19 Thread Saleem Abdulrasool via cfe-commits


@@ -0,0 +1,187 @@
+// RUN: rm -rf %t && mkdir -p %t
+
+// Build and check the unversioned module file.
+// RUN: %clang_cc1 -fmodules -fblocks -fimplicit-module-maps 
-fmodules-cache-path=%t/ModulesCache/Unversioned -fdisable-module-hash 
-fapinotes-modules  -fsyntax-only -I %S/Inputs/Headers -F %S/Inputs/Frameworks 
%s
+// RUN: %clang_cc1 -ast-print %t/ModulesCache/Unversioned/VersionedKit.pcm | 
FileCheck -check-prefix=CHECK-UNVERSIONED %s
+// RUN: %clang_cc1 -fmodules -fblocks -fimplicit-module-maps 
-fmodules-cache-path=%t/ModulesCache/Unversioned -fdisable-module-hash 
-fapinotes-modules  -fsyntax-only -I %S/Inputs/Headers -F %S/Inputs/Frameworks 
%s -ast-dump -ast-dump-filter 'DUMP' | FileCheck -check-prefix=CHECK-DUMP 
-check-prefix=CHECK-UNVERSIONED-DUMP %s

compnerd wrote:

Likewise

https://github.com/llvm/llvm-project/pull/84773
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [APINotes] Upstream the remaining API Notes fixes and tests (PR #84773)

2024-03-19 Thread Saleem Abdulrasool via cfe-commits


@@ -52,49 +52,54 @@ static void applyNullability(Sema , Decl *D, 
NullabilityKind Nullability,
   if (!Metadata.IsActive)
 return;
 
-  auto IsModified = [&](Decl *D, QualType QT,
-NullabilityKind Nullability) -> bool {
+  auto GetModified =
+  [&](Decl *D, QualType QT,
+  NullabilityKind Nullability) -> std::optional {
 QualType Original = QT;
 S.CheckImplicitNullabilityTypeSpecifier(QT, Nullability, D->getLocation(),
 isa(D),
 /*OverrideExisting=*/true);
-return QT.getTypePtr() != Original.getTypePtr();
+return (QT.getTypePtr() != Original.getTypePtr()) ? std::optional(QT)
+  : std::nullopt;
   };
 
   if (auto Function = dyn_cast(D)) {
-if (IsModified(D, Function->getReturnType(), Nullability)) {
-  QualType FnType = Function->getType();
-  Function->setType(FnType);
+if (auto Modified =
+GetModified(D, Function->getReturnType(), Nullability)) {
+  const FunctionType *FnType = Function->getType()->castAs();
+  if (const FunctionProtoType *proto = dyn_cast(FnType))
+Function->setType(S.Context.getFunctionType(
+*Modified, proto->getParamTypes(), proto->getExtProtoInfo()));
+  else
+Function->setType(
+S.Context.getFunctionNoProtoType(*Modified, FnType->getExtInfo()));
 }
   } else if (auto Method = dyn_cast(D)) {
-QualType Type = Method->getReturnType();
-if (IsModified(D, Type, Nullability)) {
-  Method->setReturnType(Type);
+if (auto Modified = GetModified(D, Method->getReturnType(), Nullability)) {
+  Method->setReturnType(*Modified);
 
   // Make it a context-sensitive keyword if we can.
-  if (!isIndirectPointerType(Type))
+  if (!isIndirectPointerType(*Modified))
 Method->setObjCDeclQualifier(Decl::ObjCDeclQualifier(
 Method->getObjCDeclQualifier() | Decl::OBJC_TQ_CSNullability));
 }
   } else if (auto Value = dyn_cast(D)) {
-QualType Type = Value->getType();
-if (IsModified(D, Type, Nullability)) {
-  Value->setType(Type);
+if (auto Modified = GetModified(D, Value->getType(), Nullability)) {
+  Value->setType(*Modified);
 
   // Make it a context-sensitive keyword if we can.
   if (auto Parm = dyn_cast(D)) {
-if (Parm->isObjCMethodParameter() && !isIndirectPointerType(Type))
+if (Parm->isObjCMethodParameter() && !isIndirectPointerType(*Modified))
   Parm->setObjCDeclQualifier(Decl::ObjCDeclQualifier(
   Parm->getObjCDeclQualifier() | Decl::OBJC_TQ_CSNullability));
   }
 }
   } else if (auto Property = dyn_cast(D)) {
-QualType Type = Property->getType();
-if (IsModified(D, Type, Nullability)) {
-  Property->setType(Type, Property->getTypeSourceInfo());
+if (auto Modified = GetModified(D, Property->getType(), Nullability)) {
+  Property->setType(*Modified, Property->getTypeSourceInfo());
 
   // Make it a property attribute if we can.
-  if (!isIndirectPointerType(Type))
+  if (!isIndirectPointerType(*Modified))
 Property->setPropertyAttributes(
 ObjCPropertyAttribute::kind_null_resettable);
 }

compnerd wrote:

Could we add a test to ensure that the modified type is applied?

https://github.com/llvm/llvm-project/pull/84773
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [APINotes] Upstream the remaining API Notes fixes and tests (PR #84773)

2024-03-19 Thread Saleem Abdulrasool via cfe-commits


@@ -0,0 +1,4 @@
+Name: SomeBrokenLib
+Functions:
+  - Name: do_something_with_pointers
+Nu llabilityOfRet: O

compnerd wrote:

Is it possible to comment that the space here is intentional? Particularly with 
this diff, it was difficult to verify until you get to the end.

https://github.com/llvm/llvm-project/pull/84773
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [APINotes] Upstream the remaining API Notes fixes and tests (PR #84773)

2024-03-19 Thread Saleem Abdulrasool via cfe-commits


@@ -638,15 +638,15 @@ ObjCPropertyDecl *Sema::CreatePropertyDecl(Scope *S,
 PDecl->setInvalidDecl();
   }
 
-  ProcessDeclAttributes(S, PDecl, FD.D);
-
   // Regardless of setter/getter attribute, we save the default getter/setter
   // selector names in anticipation of declaration of setter/getter methods.
   PDecl->setGetterName(GetterSel, GetterNameLoc);
   PDecl->setSetterName(SetterSel, SetterNameLoc);
   PDecl->setPropertyAttributesAsWritten(
   
makePropertyAttributesAsWritten(AttributesAsWritten));
 
+  ProcessDeclAttributes(S, PDecl, FD.D);
+
   if (Attributes & ObjCPropertyAttribute::kind_readonly)
 PDecl->setPropertyAttributes(ObjCPropertyAttribute::kind_readonly);
 

compnerd wrote:

Could we add a test to ensure that the attributes are applied properly?

https://github.com/llvm/llvm-project/pull/84773
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [APINotes] Upstream the remaining API Notes fixes and tests (PR #84773)

2024-03-11 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Egor Zhdan (egorzhdan)


Changes

This upstreams the last bits of Clang API Notes functionality that is currently 
implemented in the Apple fork: 
https://github.com/apple/llvm-project/tree/next/clang/lib/APINotes

---

Patch is 113.92 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/84773.diff


96 Files Affected:

- (modified) clang/lib/Sema/SemaAPINotes.cpp (+23-18) 
- (modified) clang/lib/Sema/SemaObjCProperty.cpp (+2-2) 
- (added) clang/test/APINotes/Inputs/APINotes/SomeOtherKit.apinotes (+8) 
- (added) clang/test/APINotes/Inputs/BrokenHeaders/APINotes.apinotes (+4) 
- (added) clang/test/APINotes/Inputs/BrokenHeaders/SomeBrokenLib.h (+6) 
- (added) clang/test/APINotes/Inputs/BrokenHeaders2/APINotes.apinotes (+7) 
- (added) clang/test/APINotes/Inputs/BrokenHeaders2/SomeBrokenLib.h (+6) 
- (added) 
clang/test/APINotes/Inputs/Frameworks/FrameworkWithActualPrivateModule.framework/Headers/FrameworkWithActualPrivateModule.h
 (+1) 
- (added) 
clang/test/APINotes/Inputs/Frameworks/FrameworkWithActualPrivateModule.framework/Modules/module.modulemap
 (+5) 
- (added) 
clang/test/APINotes/Inputs/Frameworks/FrameworkWithActualPrivateModule.framework/Modules/module.private.modulemap
 (+5) 
- (added) 
clang/test/APINotes/Inputs/Frameworks/FrameworkWithActualPrivateModule.framework/PrivateHeaders/FrameworkWithActualPrivateModule_Private.apinotes
 (+1) 
- (added) 
clang/test/APINotes/Inputs/Frameworks/FrameworkWithActualPrivateModule.framework/PrivateHeaders/FrameworkWithActualPrivateModule_Private.h
 (+2) 
- (added) 
clang/test/APINotes/Inputs/Frameworks/FrameworkWithWrongCase.framework/Headers/FrameworkWithWrongCase.h
 (+1) 
- (added) 
clang/test/APINotes/Inputs/Frameworks/FrameworkWithWrongCase.framework/Modules/module.modulemap
 (+5) 
- (added) 
clang/test/APINotes/Inputs/Frameworks/FrameworkWithWrongCase.framework/PrivateHeaders/FrameworkWithWrongCase_Private.apinotes
 (+1) 
- (added) 
clang/test/APINotes/Inputs/Frameworks/FrameworkWithWrongCasePrivate.framework/Headers/FrameworkWithWrongCasePrivate.h
 (+1) 
- (added) 
clang/test/APINotes/Inputs/Frameworks/FrameworkWithWrongCasePrivate.framework/Modules/module.modulemap
 (+5) 
- (added) 
clang/test/APINotes/Inputs/Frameworks/FrameworkWithWrongCasePrivate.framework/Modules/module.private.modulemap
 (+1) 
- (added) 
clang/test/APINotes/Inputs/Frameworks/FrameworkWithWrongCasePrivate.framework/PrivateHeaders/FrameworkWithWrongCasePrivate_Private.apinotes
 (+1) 
- (added) 
clang/test/APINotes/Inputs/Frameworks/LayeredKit.framework/Headers/LayeredKit.h 
(+11) 
- (added) 
clang/test/APINotes/Inputs/Frameworks/LayeredKit.framework/Modules/module.modulemap
 (+5) 
- (added) 
clang/test/APINotes/Inputs/Frameworks/LayeredKitImpl.framework/Headers/LayeredKitImpl.apinotes
 (+9) 
- (added) 
clang/test/APINotes/Inputs/Frameworks/LayeredKitImpl.framework/Headers/LayeredKitImpl.h
 (+7) 
- (added) 
clang/test/APINotes/Inputs/Frameworks/LayeredKitImpl.framework/Modules/module.modulemap
 (+5) 
- (added) 
clang/test/APINotes/Inputs/Frameworks/SimpleKit.framework/Modules/module.modulemap
 (+5) 
- (added) 
clang/test/APINotes/Inputs/Frameworks/SomeKit.framework/APINotes/SomeKit.apinotes
 (+74) 
- (added) 
clang/test/APINotes/Inputs/Frameworks/SomeKit.framework/APINotes/SomeKit_private.apinotes
 (+15) 
- (added) 
clang/test/APINotes/Inputs/Frameworks/SomeKit.framework/Headers/SomeKitForNullAnnotation.h
 (+55) 
- (added) 
clang/test/APINotes/Inputs/Frameworks/SomeKit.framework/Modules/module.modulemap
 (+5) 
- (added) 
clang/test/APINotes/Inputs/Frameworks/SomeKit.framework/Modules/module.private.modulemap
 (+8) 
- (added) 
clang/test/APINotes/Inputs/Frameworks/SomeKit.framework/Modules/module_private.modulemap
 (+8) 
- (added) 
clang/test/APINotes/Inputs/Frameworks/SomeKit.framework/PrivateHeaders/SomeKit_Private.h
 (+16) 
- (added) 
clang/test/APINotes/Inputs/Frameworks/SomeKit.framework/PrivateHeaders/SomeKit_PrivateForNullAnnotation.h
 (+17) 
- (added) 
clang/test/APINotes/Inputs/Frameworks/SomeKit.framework/PrivateHeaders/SomeKit_private.apinotes
 (+15) 
- (added) 
clang/test/APINotes/Inputs/Frameworks/SomeOtherKit.framework/APINotes/SomeOtherKit.apinotes
 (+8) 
- (added) 
clang/test/APINotes/Inputs/Frameworks/SomeOtherKit.framework/Headers/SomeOtherKit.apinotes
 (+8) 
- (added) 
clang/test/APINotes/Inputs/Frameworks/SomeOtherKit.framework/Headers/SomeOtherKit.h
 (+9) 
- (added) 
clang/test/APINotes/Inputs/Frameworks/SomeOtherKit.framework/Modules/module.modulemap
 (+5) 
- (added) 
clang/test/APINotes/Inputs/Frameworks/TopLevelPrivateKit.framework/Headers/TopLevelPrivateKit.h
 (+1) 
- (added) 
clang/test/APINotes/Inputs/Frameworks/TopLevelPrivateKit.framework/Headers/TopLevelPrivateKit_Private.apinotes
 (+1) 
- (added) 
clang/test/APINotes/Inputs/Frameworks/TopLevelPrivateKit.framework/Modules/module.modulemap
 (+5) 
- (added) 

[clang] [APINotes] Upstream the remaining API Notes fixes and tests (PR #84773)

2024-03-11 Thread Egor Zhdan via cfe-commits

egorzhdan wrote:

This depends on https://github.com/llvm/llvm-project/pull/84772.

https://github.com/llvm/llvm-project/pull/84773
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits