[PATCH] D151523: [ASTStructuralEquivalence] Fix crash when ObjCCategoryDecl doesn't have corresponding ObjCInterfaceDecl.

Volodymyr Sapsai via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 30 16:19:49 PDT 2023


vsapsai added inline comments.


================
Comment at: clang/lib/AST/ASTStructuralEquivalence.cpp:2062
+                          *Intf2 = D2->getClassInterface();
+  if ((Intf1 != nullptr) != (Intf2 != nullptr))
+    return false;
----------------
shafik wrote:
> I think this would be easier to read if you checked `Intf1 != Intf2` and then checked for `nullptr`
I am totally up to the style that is more readable and consistent. I was just trying to mimic the check for `Template1` and `Template2`. I agree that 1 (**one**) datapoint isn't representative, so I can check this file more thoroughly for the prevalent style. Do you have any other places in mind that are worth checking? I'll look for something more representative but it would help if you have something in mind already.


================
Comment at: clang/lib/AST/ASTStructuralEquivalence.cpp:2291-2294
   if ((Template1 != nullptr) != (Template2 != nullptr))
     return false;
   if (Template1 && !IsStructurallyEquivalent(*this, Template1, Template2))
     return false;
----------------
Another example of checking 2 elements for `nullptr`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151523



More information about the cfe-commits mailing list