[clang] e2d4174 - Ensure that InheritedAttrs are properly inherited along a redeclaration
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 12 19:22:41 PDT 2020
Author: Richard Smith
Date: 2020-10-12T19:22:31-07:00
New Revision: e2d4174e9c66251d1b408234b53f53d0903c0285
URL: https://github.com/llvm/llvm-project/commit/e2d4174e9c66251d1b408234b53f53d0903c0285
DIFF: https://github.com/llvm/llvm-project/commit/e2d4174e9c66251d1b408234b53f53d0903c0285.diff
LOG: Ensure that InheritedAttrs are properly inherited along a redeclaration
chain for ObjCInterfaceDecls.
Only one such declaration can actually have attributes (the definition,
if any), but generally we assume that we can look for InheritedAttrs on
the most recent declaration.
Added:
Modified:
clang/lib/Sema/SemaDeclObjC.cpp
clang/test/CodeGenObjC/attr-availability.m
Removed:
################################################################################
diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp
index 6ef6fd1d8c1c..733a50e7da5a 100644
--- a/clang/lib/Sema/SemaDeclObjC.cpp
+++ b/clang/lib/Sema/SemaDeclObjC.cpp
@@ -1066,6 +1066,11 @@ Decl *Sema::ActOnStartClassInterface(
ProcessDeclAttributeList(TUScope, IDecl, AttrList);
AddPragmaAttributes(TUScope, IDecl);
+
+ // Merge attributes from previous declarations.
+ if (PrevIDecl)
+ mergeDeclAttributes(IDecl, PrevIDecl);
+
PushOnScopeChains(IDecl, TUScope);
// Start the definition of this class. If we're in a redefinition case, there
@@ -3125,6 +3130,9 @@ Sema::ActOnForwardClassDeclaration(SourceLocation AtClassLoc,
IdentLocs[i]);
IDecl->setAtEndRange(IdentLocs[i]);
+ if (PrevIDecl)
+ mergeDeclAttributes(IDecl, PrevIDecl);
+
PushOnScopeChains(IDecl, TUScope);
CheckObjCDeclScope(IDecl);
DeclsInGroup.push_back(IDecl);
diff --git a/clang/test/CodeGenObjC/attr-availability.m b/clang/test/CodeGenObjC/attr-availability.m
index 375a5be4fadd..9ed7678eafb9 100644
--- a/clang/test/CodeGenObjC/attr-availability.m
+++ b/clang/test/CodeGenObjC/attr-availability.m
@@ -22,3 +22,14 @@ @implementation WeakClass2(MyCategory) @end
@implementation WeakClass2(YourCategory) @end
+// CHECK-10_4: @"OBJC_CLASS_$_WeakClass3" = extern_weak global
+// CHECK-10_5: @"OBJC_CLASS_$_WeakClass3" = extern_weak global
+// CHECK-10_6: @"OBJC_CLASS_$_WeakClass3" = external global
+__attribute__((availability(macosx,introduced=10.6)))
+ at interface WeakClass3 @end
+ at class WeakClass3;
+
+ at implementation WeakClass3(MyCategory) @end
+
+ at implementation WeakClass3(YourCategory) @end
+
More information about the cfe-commits
mailing list