Issue 126113
Summary [Clang FE] Possible logic issue in `TransformTypos::TransformDesignatedInitExpr`
Labels clang
Assignees
Reporter d367wang
    When running the tree-visitor `TransformTypos` on a `DesignatedInitExpr` node, it first tries to transform its initializer
```
// transform the initializer value
  ExprResult Init = getDerived().TransformExpr(E->getInit());
```
and later on decides whether the AST changes by
```
ExprChanged = ExprChanged || Init.get() != E->getArrayIndex(D);
```
at https://github.com/llvm/llvm-project/blob/5492199a9aa4b5d31c38e36928ac153570091d6d/clang/lib/Sema/TreeTransform.h#L13659

The logic in `Init.get() != E->getArrayIndex(D)` seems not correct as the initializer and the index of the designator are being compared, which is likely to always be false. 

Ran debugger on clang compiling a designator example
```
const char *str[] = {
    [some_typo] = "0"
};
```
and stepped in to the line, `Init.get()` is a StringLiteral and `E->getArrayIndex(D)` is a TypoExpr.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to