Author: mren Date: Thu Nov 17 12:41:18 2016 New Revision: 287244 URL: http://llvm.org/viewvc/llvm-project?rev=287244&view=rev Log: ObjC Module: try to make objc module deterministic.
Make sure that comparing selectors in DeclarationName does its job. rdar://problem/28988750 Added: cfe/trunk/test/Modules/stress-objc.m Modified: cfe/trunk/lib/AST/DeclarationName.cpp Modified: cfe/trunk/lib/AST/DeclarationName.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclarationName.cpp?rev=287244&r1=287243&r2=287244&view=diff ============================================================================== --- cfe/trunk/lib/AST/DeclarationName.cpp (original) +++ cfe/trunk/lib/AST/DeclarationName.cpp Thu Nov 17 12:41:18 2016 @@ -95,12 +95,18 @@ int DeclarationName::compare(Declaration case DeclarationName::ObjCMultiArgSelector: { Selector LHSSelector = LHS.getObjCSelector(); Selector RHSSelector = RHS.getObjCSelector(); + // getNumArgs for ZeroArgSelector returns 0, but we still need to compare. + if (LHS.getNameKind() == DeclarationName::ObjCZeroArgSelector && + RHS.getNameKind() == DeclarationName::ObjCZeroArgSelector) { + return LHSSelector.getAsIdentifierInfo()->getName().compare( + RHSSelector.getAsIdentifierInfo()->getName()); + } unsigned LN = LHSSelector.getNumArgs(), RN = RHSSelector.getNumArgs(); for (unsigned I = 0, N = std::min(LN, RN); I != N; ++I) { switch (LHSSelector.getNameForSlot(I).compare( RHSSelector.getNameForSlot(I))) { - case -1: return true; - case 1: return false; + case -1: return -1; + case 1: return 1; default: break; } } Added: cfe/trunk/test/Modules/stress-objc.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/stress-objc.m?rev=287244&view=auto ============================================================================== --- cfe/trunk/test/Modules/stress-objc.m (added) +++ cfe/trunk/test/Modules/stress-objc.m Thu Nov 17 12:41:18 2016 @@ -0,0 +1,22 @@ +// RUN: cd %S + +// RUN: %clang_cc1 -emit-pch -x objective-c-header %s -o %t_c00.pch -fno-pch-timestamp +// RUN: %clang_cc1 -emit-pch -x objective-c-header %s -o %t_c00_1.pch -fno-pch-timestamp +// RUN: diff %t_c00.pch %t_c00_1.pch + +// RUN: %clang_cc1 -emit-pch -x objective-c-header %s -o %t_c00_2.pch -fno-pch-timestamp +// RUN: diff %t_c00.pch %t_c00_2.pch + +// RUN: %clang_cc1 -emit-pch -x objective-c-header %s -o %t_c00_3.pch -fno-pch-timestamp +// RUN: diff %t_c00.pch %t_c00_3.pch + +// RUN: %clang_cc1 -emit-pch -x objective-c-header %s -o %t_c00_4.pch -fno-pch-timestamp +// RUN: diff %t_c00.pch %t_c00_4.pch + +// RUN: %clang_cc1 -emit-pch -x objective-c-header %s -o %t_c00_5.pch -fno-pch-timestamp +// RUN: diff %t_c00.pch %t_c00_5.pch + +@protocol NSObject +- (void)doesNotRecognizeSelector:(SEL)aSelector; +- (id)forwardingTargetForSelector:(SEL)aSelector; +@end _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits