-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Closed
Closed
Copy link
Labels
clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"good first issuehttps://github.com/llvm/llvm-project/contributehttps://github.com/llvm/llvm-project/contribute
Description
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
llvm-project/clang/lib/Sema/TreeTransform.h
Line 13659 in 5492199
| ExprChanged = ExprChanged || Init.get() != E->getArrayIndex(D); |
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 true. In contrast, later in the same function
llvm-project/clang/lib/Sema/TreeTransform.h
Line 13685 in 5492199
| Init.get() == E->getInit() && |
The old initializer and the initializer after transform are compared.
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.
Metadata
Metadata
Assignees
Labels
clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"good first issuehttps://github.com/llvm/llvm-project/contributehttps://github.com/llvm/llvm-project/contribute