diff options
author | Corentin Jabot <corentin.jabot@gmail.com> | 2022-02-08 12:09:03 -0500 |
---|---|---|
committer | Aaron Ballman <aaron@aaronballman.com> | 2022-02-08 12:10:47 -0500 |
commit | c1512250960bd247519a9f959ad4af202402dcc4 (patch) | |
tree | 777da02df015fac62ce35deab5ab0c6250d6904f /clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp | |
parent | caf7f05c1c7320fe29c2ec4ebecac91a5c970633 (diff) | |
download | llvm-c1512250960bd247519a9f959ad4af202402dcc4.zip llvm-c1512250960bd247519a9f959ad4af202402dcc4.tar.gz llvm-c1512250960bd247519a9f959ad4af202402dcc4.tar.bz2 |
[C++2b] Implement multidimentional subscript operator
Implement P2128R6 in C++23 mode.
Unlike GCC's implementation, this doesn't try to recover when a user
meant to use a comma expression.
Because the syntax changes meaning in C++23, the patch is *NOT*
implemented as an extension. Instead, declaring an array with not
exactly 1 parameter is an error in older languages modes. There is an
off-by-default extension warning in C++23 mode.
Unlike the standard, we supports default arguments;
Ie, we assume, based on conversations in WG21, that the proposed
resolution to CWG2507 will be accepted.
We allow arrays OpenMP sections and C++23 multidimensional array to
coexist:
[a , b] multi dimensional array
[a : b] open mp section
[a, b: c] // error
The rest of the patch is relatively straight forward: we take care to
support an arbitrary number of arguments everywhere.
Diffstat (limited to 'clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp')
-rw-r--r-- | clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp b/clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp index d29e631..5d4f3b8 100644 --- a/clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp +++ b/clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp @@ -398,8 +398,8 @@ static bool isAliasDecl(ASTContext *Context, const Decl *TheDecl, if (OpCall->getOperator() == OO_Star) return isDereferenceOfOpCall(OpCall, IndexVar); if (OpCall->getOperator() == OO_Subscript) { - assert(OpCall->getNumArgs() == 2); - return isIndexInSubscriptExpr(OpCall->getArg(1), IndexVar); + return OpCall->getNumArgs() == 2 && + isIndexInSubscriptExpr(OpCall->getArg(1), IndexVar); } break; } |