PBHDK wrote:
> Yes, you can just submit new PR, reference this one.
Done! Here it is: https://github.com/llvm/llvm-project/pull/95220
https://github.com/llvm/llvm-project/pull/90043
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
carlosgalvezp wrote:
> I don't think it is a good solution.
Can you elaborate?
As I wrote above, the C++ Core Guidelines do not require using `at()`.
Therefore the check would be doing something different than what the guidelines
require. The reason they don't require it is that there's
HerrCai0907 wrote:
> To be clear and reiterate my previous comment: this check should NOT require
> users to use at(). That behavior should be opt-in. It should only warn about
> using operator[]. It's up to the users to figure out what the best
> replacement is.
I don't think it is a good
carlosgalvezp wrote:
To be clear and reiterate my previous comment: this check should NOT require
users to use at(). That behavior should be opt-in. It should only warn about
using operator[]. It's up to the users to figure out what the best replacement
is.
https://github.com/HerrCai0907 requested changes to this pull request.
`at` and `operator[]` in `std::map` have different meanings. `operator[]` will
insert value if key does not exist but `at` won't. Please limit this check only
for index containers instead of key-value containers.
PiotrZSL wrote:
Yes, you can just submit new PR, reference this one.
https://github.com/llvm/llvm-project/pull/90043
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
PBHDK wrote:
> Check if you can commit to sebwolf-de:avoid-bounds-error-check
Unfortunately, we can't. We do not have access to Sebastian's LLVM fork.
Since Sebastian is out of office right now - this is one of the reasons we're
involved - would you be ok with us submitting a new PR with our
PiotrZSL wrote:
Check if you can commit to sebwolf-de:avoid-bounds-error-check
https://github.com/llvm/llvm-project/pull/90043
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
PBHDK wrote:
> > > I am adding @leunam99 and @PBHDK to the PR, who will contribute in the
> > > next few weeks.
> >
> >
> > Since we cannot push to this PR, we will be submitting a new PR with
> > @sebwolf-de's + our work, correct, @EugeneZelenko, @PiotrZSL, @HerrCai0907?
>
> Could you
EugeneZelenko wrote:
> > I am adding @leunam99 and @PBHDK to the PR, who will contribute in the next
> > few weeks.
>
> Since we cannot push to this PR, we will be submitting a new PR with
> @sebwolf-de's + our work, correct, @EugeneZelenko, @PiotrZSL, @HerrCai0907?
Could you please resolve
@@ -0,0 +1,66 @@
+namespace std {
+ template
+ struct array {
+T operator[](unsigned i) {
+ return T{1};
+}
+T at(unsigned i) {
+ return T{1};
+}
+ };
+
+ template
+ struct unique_ptr {
+T operator[](unsigned i) {
+ return T{1};
+}
+
@@ -0,0 +1,81 @@
+//===--- AvoidBoundsErrorsCheck.cpp - clang-tidy
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier:
PBHDK wrote:
> I am adding @leunam99 and @PBHDK to the PR, who will contribute in the next
> few weeks.
Since we cannot push to this PR, we will be submitting a new PR with
@sebwolf-de's + our work, correct, @EugeneZelenko, @PiotrZSL, @HerrCai0907?
https://github.com/sebwolf-de updated
https://github.com/llvm/llvm-project/pull/90043
>From 8eb5863305e8f9a1311a540faf35f24fc6f55c6c Mon Sep 17 00:00:00 2001
From: Sebastian Wolf
Date: Wed, 17 Apr 2024 16:16:35 +0200
Subject: [PATCH 1/3] Enforce SL.con.3: Add check to replace operator[] with
@@ -0,0 +1,81 @@
+//===--- AvoidBoundsErrorsCheck.cpp - clang-tidy
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier:
@@ -0,0 +1,66 @@
+namespace std {
+ template
+ struct array {
+T operator[](unsigned i) {
+ return T{1};
+}
+T at(unsigned i) {
+ return T{1};
+}
+ };
+
+ template
+ struct unique_ptr {
+T operator[](unsigned i) {
+ return T{1};
+}
+
@@ -57,6 +58,8 @@ namespace cppcoreguidelines {
class CppCoreGuidelinesModule : public ClangTidyModule {
public:
void addCheckFactories(ClangTidyCheckFactories ) override {
+CheckFactories.registerCheck(
+"cppcoreguidelines-avoid-bounds-errors");
@@ -0,0 +1,81 @@
+//===--- AvoidBoundsErrorsCheck.cpp - clang-tidy
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier:
@@ -0,0 +1,20 @@
+.. title:: clang-tidy - cppcoreguidelines-avoid-bounds-errors
+
+cppcoreguidelines-avoid-bounds-errors
+=
+
+This check enforces the `SL.con.3
@@ -0,0 +1,81 @@
+//===--- AvoidBoundsErrorsCheck.cpp - clang-tidy
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier:
@@ -0,0 +1,81 @@
+//===--- AvoidBoundsErrorsCheck.cpp - clang-tidy
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier:
@@ -0,0 +1,81 @@
+//===--- AvoidBoundsErrorsCheck.cpp - clang-tidy
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier:
@@ -0,0 +1,81 @@
+//===--- AvoidBoundsErrorsCheck.cpp - clang-tidy
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier:
@@ -0,0 +1,81 @@
+//===--- AvoidBoundsErrorsCheck.cpp - clang-tidy
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier:
@@ -0,0 +1,20 @@
+.. title:: clang-tidy - cppcoreguidelines-avoid-bounds-errors
+
+cppcoreguidelines-avoid-bounds-errors
+=
+
+This check enforces the `SL.con.3
https://github.com/PiotrZSL edited
https://github.com/llvm/llvm-project/pull/90043
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -0,0 +1,32 @@
+//===--- AvoidBoundsErrorsCheck.h - clang-tidy --*- C++
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier:
@@ -0,0 +1,81 @@
+//===--- AvoidBoundsErrorsCheck.cpp - clang-tidy
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier:
https://github.com/PiotrZSL requested changes to this pull request.
Idea is fine, implementation is lacking critical parts.
Please check comments, fix them.
If you will have some questions, just ask.
https://github.com/llvm/llvm-project/pull/90043
___
cor3ntin wrote:
> Please note: the guidelines do not require one to replace [] with at(),
> that's just one of the possible solutions. Actually at() is banned in many
> codebases where exceptions are banned.
>
> It would be good to make this fix-it opt-in, configurable via option, so the
>
carlosgalvezp wrote:
Please note: the guidelines do not require one to replace [] with at(), that's
just one of the possible solutions. Actually at() is banned in many codebases
where exceptions are banned.
It would be good to make this fix-it opt-in, configurable via option, so the
check
@@ -0,0 +1,20 @@
+.. title:: clang-tidy - cppcoreguidelines-avoid-bounds-errors
+
+cppcoreguidelines-avoid-bounds-errors
+=
+
+This check enforces the `SL.con.3
@@ -131,6 +131,11 @@ New checks
to reading out-of-bounds data due to inadequate or incorrect string null
termination.
+- New :doc:`cppcoreguidelines-avoid-bounds-errors
+ ` check.
+
+ Flags the unsafe `operator[]` and replaces it with `at()`.
@@ -0,0 +1,81 @@
+//===--- AvoidBoundsErrorsCheck.cpp - clang-tidy
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier:
@@ -0,0 +1,32 @@
+//===--- AvoidBoundsErrorsCheck.h - clang-tidy --*- C++
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier:
@@ -0,0 +1,81 @@
+//===--- AvoidBoundsErrorsCheck.cpp - clang-tidy
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier:
@@ -0,0 +1,81 @@
+//===--- AvoidBoundsErrorsCheck.cpp - clang-tidy
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier:
@@ -0,0 +1,81 @@
+//===--- AvoidBoundsErrorsCheck.cpp - clang-tidy
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier:
llvmbot wrote:
@llvm/pr-subscribers-clang-tidy
Author: Sebastian Wolf (sebwolf-de)
Changes
The string based test to find out whether the check is applicable on the class
is not ideal, but I did not find a more elegant way, yet. If there is more
clang-query magic available, that I'm not
llvmbot wrote:
@llvm/pr-subscribers-clang-tools-extra
Author: Sebastian Wolf (sebwolf-de)
Changes
The string based test to find out whether the check is applicable on the class
is not ideal, but I did not find a more elegant way, yet. If there is more
clang-query magic available, that
github-actions[bot] wrote:
Thank you for submitting a Pull Request (PR) to the LLVM Project!
This PR will be automatically labeled and the relevant teams will be
notified.
If you wish to, you can add reviewers by using the "Reviewers" section on this
page.
If this is not working for you,
https://github.com/sebwolf-de created
https://github.com/llvm/llvm-project/pull/90043
The string based test to find out whether the check is applicable on the class
is not ideal, but I did not find a more elegant way, yet. If there is more
clang-query magic available, that I'm not aware of,
42 matches
Mail list logo