[PATCH] D145906: [clang-tidy] Correctly handle evaluation order of designated initializers.
Piotr Zegar via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 13 10:21:37 PDT 2023
PiotrZSL added inline comments.
================
Comment at: clang-tools-extra/clang-tidy/utils/ExprSequence.cpp:67
+llvm::SmallVector<const InitListExpr *>
+allInitListExprForms(const InitListExpr *InitList) {
+ llvm::SmallVector<const InitListExpr *> result = {InitList};
----------------
maybe some other name instead of allInitListExprForms, like getAllInitForms
================
Comment at: clang-tools-extra/clang-tidy/utils/ExprSequence.cpp:69-72
+ if (InitList->isSemanticForm() && InitList->getSyntacticForm())
+ result.push_back(InitList->getSyntacticForm());
+ if (InitList->isSyntacticForm() && InitList->getSemanticForm())
+ result.push_back(InitList->getSemanticForm());
----------------
this looks like typo... but it isn't, it's just unnecessary.
``InitList->isSemanticForm() && InitList->getSyntacticForm()`` is equal to:
``AltForm.getInt() && AltForm.getPointer()``
``InitList->isSyntacticForm() && InitList->getSemanticForm()`` is equal to:
``(!AltForm.getInt() || !AltForm.getPointer()) && (!AltForm.getInt()) && AltForm.getPointer()``
Why we coudn't have "getAnyForm".
any code could just look like this:
``if (const InitListExpr * Form = InitList->getSyntacticForm())``
`` result.push_back(Form);``
``if (const InitListExpr * Form = InitList->getSemanticForm())``
`` result.push_back(Form);``
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D145906/new/
https://reviews.llvm.org/D145906
More information about the cfe-commits
mailing list