[clang] [clang][index] Fix processing of CompoundAssignOperator at setting up reference roles (PR #69370)

Aleksandr Platonov via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 19 00:36:47 PDT 2023


================
@@ -77,9 +77,15 @@ class BodyIndexer : public RecursiveASTVisitor<BodyIndexer> {
     const Stmt *Parent = *It;
 
     if (auto BO = dyn_cast<BinaryOperator>(Parent)) {
-      if (BO->getOpcode() == BO_Assign && BO->getLHS()->IgnoreParenCasts() == E)
-        Roles |= (unsigned)SymbolRole::Write;
-
+      if (BO->getOpcode() == BO_Assign) {
+        if (BO->getLHS()->IgnoreParenCasts() == E)
----------------
ArcsinX wrote:

I split this `if` to avoid this check `else if (auto CA = dyn_cast<CompoundAssignOperator>(Parent))`  if `BO->getOpcode() == BO_Assign && BO->getLHS()->IgnoreParenCasts() != E`

I.e. if `BO->getOpcode() == BO_Assign` then `Parent` is not a  `CompoundAssignOperator` and we don't need to check this

https://github.com/llvm/llvm-project/pull/69370


More information about the cfe-commits mailing list