forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 341
[-Wunsafe-buffer-usage] cherry-picks #7779
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jkorous-apple
merged 23 commits into
swiftlang:stable/20230725
from
jkorous-apple:cxx-safe-buffers-cherry-picks
Nov 13, 2023
Merged
[-Wunsafe-buffer-usage] cherry-picks #7779
jkorous-apple
merged 23 commits into
swiftlang:stable/20230725
from
jkorous-apple:cxx-safe-buffers-cherry-picks
Nov 13, 2023
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…r getFixits Differential Revision: https://reviews.llvm.org/D155526 (cherry picked from commit 070358e)
…xed at an earlier stage `FixableGadget`s are not always associated with variables that are unsafe (warned). For example, they could be associated with variables whose unsafe operations are suppressed or that are not used in any unsafe operation. Such `FixableGadget`s will not be fixed. Removing these `FixableGadget` as early as possible helps improve the performance and stability of the analysis. Reviewed by: NoQ (Artem Dergachev), t-rasmud (Rashmi Mudduluru) Differential revision: https://reviews.llvm.org/D155524 (cherry picked from commit cfcf76c)
Differential Revision: https://reviews.llvm.org/D154880 (cherry picked from commit a6ae740)
…n a value" warning. NFC. (cherry picked from commit 4cd7d8e)
(cherry picked from commit 38b648b)
Fix the linting problems which causes `clang/utils/ci/run-buildbot check-format` to return 1. Also make a correction for the email address of the author of 0fd4175: The correct email address is "[email protected]", not "[email protected]". Reviewed by: ziqingluo-90 (Ziqing Luo) Differential revision: https://reviews.llvm.org/D155814 (cherry picked from commit 82b94a9)
…ound Differential Revision: https://reviews.llvm.org/D157018 (cherry picked from commit cf1c64b)
- Factor out the code that will be shared by both parameter and local variable fix-its - Add a check to ensure that a TypeLoc::isNull is false before using the TypeLoc - Remove the special check for whether a fixing variable involves unnamed types. This check is unnecessary now. - Move tests for cv-qualified parameters and unnamed types out of the "...-unsupported.cpp" test file. Reviewed by: NoQ (Artem Dergachev) Differential revision: https://reviews.llvm.org/D156188 (cherry picked from commit 41279e8)
Differential Revision: https://reviews.llvm.org/D158112#inline-1530312 (cherry picked from commit 2afcda6)
Slightly refactor and optimize the code in preparation for implementing grouping parameters for a single fix-it. Reviewed by: NoQ (Artem Dergachev), t-rasmud (Rashmi Mudduluru) Differential revision: https://reviews.llvm.org/D156474 (cherry picked from commit 8437847)
…g/include clang/docs" fail (cherry picked from commit 630ba7d)
… generated Refactor the getFixIts function for better readability. Reviewed by: NoQ (Artem Dergachev), t-rasmud (Rashmi Mudduluru) Differential revision: https://reviews.llvm.org/D156762 (cherry picked from commit acc8a33)
This breaks the clang check-format on CI. + grep -rnI '[[:blank:]]$' clang/lib clang/include clang/docs clang/lib/Analysis/UnsafeBufferUsage.cpp:2277:#endif (cherry picked from commit 69a8636)
…rameter fix-its share common code Refactor the code for local variable fix-its so that it reuses the code for parameter fix-its, which is in general better. For example, cv-qualifiers are supported. Reviewed by: NoQ (Artem Dergachev), t-rasmud (Rashmi Mudduluru) Differential revision: https://reviews.llvm.org/D156189 (cherry picked from commit 3a67b91)
…e declarations with unsupported specifiers We have to give up on fixing a variable declaration if it has specifiers that are not supported yet. We could support these specifiers incrementally using the same approach as how we deal with cv-qualifiers. If a fixing variable declaration has a storage specifier, instead of trying to find out the source location of the specifier or to avoid touching it, we add the keyword to a canonicalized place in the fix-it text that replaces the whole declaration. Reviewed by: NoQ (Artem Dergachev), jkorous (Jan Korous) Differential revision: https://reviews.llvm.org/D156192 (cherry picked from commit b58e528)
(cherry picked from commit c81ff8b)
For a function `F` whose parameters need to be fixed, we group fix-its of F's parameters together so that either all of the parameters get fixed or none of them gets fixed. Reviewed by: NoQ (Artem Dergachev), t-rasmud (Rashmi Mudduluru), jkorous (Jan Korous) Differential revision: https://reviews.llvm.org/D153059 (cherry picked from commit 33f6161)
…parameter - Use Strategy to determine whether to fix a parameter - Fix the `Strategy` construction so that only variables on the graph are assigned the `std::span` strategy Reviewed by: t-rasmud (Rashmi Mudduluru), NoQ (Artem Dergachev) Differential revision: https://reviews.llvm.org/D157441 (cherry picked from commit 700baeb)
… with auto Reviewed By: tahonermann Differential Revision: https://reviews.llvm.org/D159474 (cherry picked from commit 06c9cc7)
…e header files Extract included parts in the following tests to separate header files: - SemaCXX/warn-unsafe-buffer-usage-fixits-parm-span-overload.cpp - SemaCXX/warn-unsafe-buffer-usage-fixits-parm-span.cpp Removed the included part in the following tests as it is not useful: - SemaCXX/warn-unsafe-buffer-usage-warning-unevaluated-context.cpp (cherry picked from commit de8b2f0)
… for analysis - For a better understand of what the unsupported cases are, we add more information to the debug note---a string of ancestor AST nodes of the unclaimed DRE. For example, an unclaimed DRE p in an expression `*(p++)` will result in a string starting with `DRE ==> UnaryOperator(++) ==> Paren ==> UnaryOperator(*)`. - To find out the most common patterns of those unsupported use cases, we add a simple script to build a prefix tree over those strings and count each prefix. The script reads input line by line, assumes a line is a list of words separated by `==>`s, and builds a prefix tree over those lists. Reviewed by: t-rasmud (Rashmi Mudduluru), NoQ (Artem Dergachev) Differential revision: https://reviews.llvm.org/D158561 (cherry picked from commit a432358)
@swift-ci please test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.