[PATCH] D63789: [ODRHash] Fix null pointer dereference for ObjC selectors with empty slots.

Volodymyr Sapsai via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 28 10:44:08 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL364664: [ODRHash] Fix null pointer dereference for ObjC selectors with empty slots. (authored by vsapsai, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D63789?vs=206992&id=207099#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63789/new/

https://reviews.llvm.org/D63789

Files:
  cfe/trunk/lib/AST/ODRHash.cpp
  cfe/trunk/test/Modules/odr_hash.mm


Index: cfe/trunk/test/Modules/odr_hash.mm
===================================================================
--- cfe/trunk/test/Modules/odr_hash.mm
+++ cfe/trunk/test/Modules/odr_hash.mm
@@ -57,6 +57,14 @@
 @interface Interface3 <T : I1 *>
 @end
 
+ at interface EmptySelectorSlot
+- (void)method:(int)arg;
+- (void)method:(int)arg :(int)empty;
+
+- (void)multiple:(int)arg1 args:(int)arg2 :(int)arg3;
+- (void)multiple:(int)arg1 :(int)arg2 args:(int)arg3;
+ at end
+
 #endif
 
 #if defined(FIRST)
@@ -289,6 +297,29 @@
 }  // namespace ObjCTypeParam
 }  // namespace Types
 
+namespace CallMethods {
+#if defined(FIRST)
+void invalid1(EmptySelectorSlot *obj) {
+  [obj method:0];
+}
+void invalid2(EmptySelectorSlot *obj) {
+  [obj multiple:0 args:0 :0];
+}
+#elif defined(SECOND)
+void invalid1(EmptySelectorSlot *obj) {
+  [obj method:0 :0];
+}
+void invalid2(EmptySelectorSlot *obj) {
+  [obj multiple:0 :0 args:0];
+}
+#endif
+// expected-error at second.h:* {{'CallMethods::invalid1' has different definitions in different modules; definition in module 'SecondModule' first difference is function body}}
+// expected-note at first.h:* {{but in 'FirstModule' found a different body}}
+
+// expected-error at second.h:* {{'CallMethods::invalid2' has different definitions in different modules; definition in module 'SecondModule' first difference is function body}}
+// expected-note at first.h:* {{but in 'FirstModule' found a different body}}
+}  // namespace CallMethods
+
 // Keep macros contained to one file.
 #ifdef FIRST
 #undef FIRST
Index: cfe/trunk/lib/AST/ODRHash.cpp
===================================================================
--- cfe/trunk/lib/AST/ODRHash.cpp
+++ cfe/trunk/lib/AST/ODRHash.cpp
@@ -71,8 +71,13 @@
     AddBoolean(S.isKeywordSelector());
     AddBoolean(S.isUnarySelector());
     unsigned NumArgs = S.getNumArgs();
+    ID.AddInteger(NumArgs);
     for (unsigned i = 0; i < NumArgs; ++i) {
-      AddIdentifierInfo(S.getIdentifierInfoForSlot(i));
+      const IdentifierInfo *II = S.getIdentifierInfoForSlot(i);
+      AddBoolean(II);
+      if (II) {
+        AddIdentifierInfo(II);
+      }
     }
     break;
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63789.207099.patch
Type: text/x-patch
Size: 2141 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190628/555ad15a/attachment.bin>


More information about the cfe-commits mailing list