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

Richard Trieu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 26 14:36:34 PDT 2019


rtrieu added inline comments.


================
Comment at: clang/lib/AST/ODRHash.cpp:73
     AddBoolean(S.isUnarySelector());
     unsigned NumArgs = S.getNumArgs();
     for (unsigned i = 0; i < NumArgs; ++i) {
----------------
vsapsai wrote:
> rtrieu wrote:
> > There's actually a second bug here as well.  When processing an arbitrary number of elements, the number of elements needs to placed before the list.  This line should be added before the for-loop:
> > 
> > ```
> > ID.AddInteger(NumArgs);
> > 
> > ```
> > This change isn't directly related to your original patch, so feel free to skip it.
> Thanks for the review, Richard. What would be the way to test the suggested changes? I was mostly thinking about making sure we treat as different
> * `-foo:` and `-foo::`
> * `-foo:bar::` and `-foo::bar:`
> 
> Does it sound reasonable? Maybe you have some test examples for C++ that I can adopt for Objective-C.
Yes, checking things close to each other sounds reasonable.   I did pretty much the same thing testing in C++, find things (usually types) that are close to others and making sure the ODRHash can tell them apart.  The ObjC testing is a little sparse since I was focusing on the C++ part.  Thanks for helping fill it out.


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

https://reviews.llvm.org/D63789





More information about the cfe-commits mailing list