[PATCH] D156474: [-Wunsafe-buffer-usage][NFC] Slightly refactor and optimize the code

2023-07-27 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 added inline comments. Comment at: clang/include/clang/Analysis/Analyses/UnsafeBufferUsage.h:25 + +class VariableGroupsManager { +public: Use the `VariableGroupsManager` class as an interface to clients. It hides the details about how groups are im

[PATCH] D153059: [-Wunsafe-buffer-usage] Group parameter fix-its

2023-07-27 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 added a comment. Thanks for the suggestion of splitting this patch to smaller ones. I have one such smaller patch ready here: https://reviews.llvm.org/D156474. It does make it easier in describing and discussing about the changes. Comment at: clang/lib/Analysis/

[PATCH] D156188: [-Wunsafe-buffer-usage] Refactor and improve for parameter fix-its

2023-08-17 Thread Ziqing Luo via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. ziqingluo-90 marked 2 inline comments as done. Closed by commit rG41279e870fa5: [-Wunsafe-buffer-usage] Refactor and improve for parameter fix-its (authored by ziqinglu

[PATCH] D156474: [-Wunsafe-buffer-usage][NFC] Slightly refactor and optimize the code

2023-08-17 Thread Ziqing Luo via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG843784764ab5: [-Wunsafe-buffer-usage][NFC] Slightly refactor and optimize the code (authored by ziqingluo-90). Changed prior to commit: https://re

[PATCH] D156762: [-Wunsafe-buffer-usage][NFC] Refactor `getFixIts`---where fix-its are generated

2023-08-18 Thread Ziqing Luo via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rGacc8a33b257f: [-Wunsafe-buffer-usage][NFC] Refactor `getFixIts`---where fix-its are generated (authored by ziqingluo-90). Changed prior to commit:

[PATCH] D156189: [-Wunsafe-buffer-usage] Refactor to let local variable fix-its and parameter fix-its share common code

2023-08-21 Thread Ziqing Luo via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. ziqingluo-90 marked 4 inline comments as done. Closed by commit rG3a67b912386e: [-Wunsafe-buffer-usage] Refactor to let local variable fix-its and parameter… (authored

[PATCH] D156189: [-Wunsafe-buffer-usage] Refactor to let local variable fix-its and parameter fix-its share common code

2023-08-21 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 added a comment. Addressed comments and have landed this patch. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D156189/new/ https://reviews.llvm.org/D156189 ___ cfe-commits mailing list cfe-co

[PATCH] D156192: [-Wunsafe-buffer-usage] Stop generating incorrect fix-its for variable declarations with unsupported specifiers

2023-08-21 Thread Ziqing Luo via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. ziqingluo-90 marked an inline comment as done. Closed by commit rGb58e52889808: [-Wunsafe-buffer-usage] Stop generating incorrect fix-its for variable… (authored by ziq

[PATCH] D158561: [-Wunsafe-buffer-usage] Add AST info to the unclaimed DRE debug notes for analysis

2023-08-22 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 created this revision. ziqingluo-90 added reviewers: jkorous, NoQ, t-rasmud, malavikasamak. Herald added a project: All. ziqingluo-90 requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits. The debug note for an unclaimed DRE highlight

[PATCH] D156762: [-Wunsafe-buffer-usage][NFC] Refactor `getFixIts`---where fix-its are generated

2023-07-31 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 created this revision. ziqingluo-90 added reviewers: NoQ, jkorous, t-rasmud, malavikasamak. Herald added a project: All. ziqingluo-90 requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits. Refactor the `getFixIts` function for better

[PATCH] D153059: [-Wunsafe-buffer-usage] Group parameter fix-its

2023-07-31 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 updated this revision to Diff 545872. ziqingluo-90 marked 4 inline comments as done. ziqingluo-90 added a comment. Carved out NFC changes from the original diff. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D153059/new/ https://reviews.llvm.org/D153059 Files: clang/inclu

[PATCH] D153059: [-Wunsafe-buffer-usage] Group parameter fix-its

2023-07-31 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 added inline comments. Comment at: clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-multi-parm-span.cpp:37-39 +// CHECK: fix-it:{{.*}}:{[[@LINE+3]]:24-[[@LINE+3]]:30}:"std::span p" +// CHECK: fix-it:{{.*}}:{[[@LINE+2]]:32-[[@LINE+2]]:39}:"std::span q" +// CHECK: f

[PATCH] D156192: [-Wunsafe-buffer-usage] Stop generating incorrect fix-its for variable declarations with unsupported specifiers

2023-08-01 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 added a comment. > Note that your patch doesn't actually address //type// attributes, only > //declaration// attributes. It does not address type attribute. We can address it in a follow-up patch. > So it's likely that we have to give up on unsupported type attributes very > earl

[PATCH] D155814: Fix the linting problems which causes `clang/utils/ci/run-buildbot check-format` to return 1.

2023-08-01 Thread Ziqing Luo via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG82b94a9f7be9: Fix the linting problems in UnsafeBufferUsage.cpp (authored by AMP999, committed by ziqingluo-90). Changed prior to commit: https://

[PATCH] D155814: Fix the linting problems which causes `clang/utils/ci/run-buildbot check-format` to return 1.

2023-08-01 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 added a comment. Hi @AMP999 I have committed this patch on behalf of you. Unfortunately, I cannot amend an old commit for you as it will cause rewriting a bunch of the history. I made a correction message along with the commit. Repository: rG LLVM Github Monorepo CHANGES SINCE

[PATCH] D156474: [-Wunsafe-buffer-usage][NFC] Slightly refactor and optimize the code

2023-08-02 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 added inline comments. Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:2179 + if (FixItsForVariable.count(GrpMate)) +FinalFixItsForVariable[Var].insert(FinalFixItsForVariable[Var].end(), + FixItsForVariable[

[PATCH] D156762: [-Wunsafe-buffer-usage][NFC] Refactor `getFixIts`---where fix-its are generated

2023-08-03 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 added inline comments. Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:2219 + // cannot be fixed... + eraseVarsForUnfixableGroupMates(FixItsForVariable, VarGrpMgr); + // Now `FixItsForVariable` gets further reduced: a variable is in NoQ wrote

[PATCH] D156762: [-Wunsafe-buffer-usage][NFC] Refactor `getFixIts`---where fix-its are generated

2023-08-04 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 updated this revision to Diff 547405. ziqingluo-90 marked 6 inline comments as done. ziqingluo-90 added a comment. Address comments. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D156762/new/ https://reviews.llvm.org/D156762 Files: clang/lib/Analysis/UnsafeBufferUsage.cpp

[PATCH] D153059: [-Wunsafe-buffer-usage] Group parameter fix-its

2023-08-04 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 updated this revision to Diff 547422. ziqingluo-90 marked an inline comment as done. ziqingluo-90 added a comment. Address comments. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D153059/new/ https://reviews.llvm.org/D153059 Files: clang/include/clang/Analysis/Analyses/Un

[PATCH] D153059: [-Wunsafe-buffer-usage] Group parameter fix-its

2023-08-04 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 updated this revision to Diff 547425. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D153059/new/ https://reviews.llvm.org/D153059 Files: clang/include/clang/Analysis/Analyses/UnsafeBufferUsage.h clang/include/clang/Basic/DiagnosticSemaKinds.td clang/lib/Analysis/UnsafeB

[PATCH] D153059: [-Wunsafe-buffer-usage] Group parameter fix-its

2023-08-04 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 added inline comments. Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:1891-1892 + for (unsigned i = 0; i < NumParms; i++) { +if (!ParmsMask[i]) + continue; + NoQ wrote: > Speaking of [[ https://reviews.llvm.org/D156762#inline-1517322

[PATCH] D157441: [-Wunsafe-buffer-usage] Use `Strategy` to determine whether to fix a parameter

2023-08-08 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 created this revision. ziqingluo-90 added reviewers: t-rasmud, NoQ, jkorous, malavikasamak. Herald added a project: All. ziqingluo-90 requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits. - Use `Strategy` to determine whether to fix

[PATCH] D157441: [-Wunsafe-buffer-usage] Use `Strategy` to determine whether to fix a parameter

2023-08-08 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 added inline comments. Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:1624 // Inserts the [0] -std::optional EndOfOperand = -getEndCharLoc(BaseDeclRefExpr, SM, Ctx.getLangOpts()); -if (EndOfOperand) { +if (auto LocPastOperand = +

[PATCH] D156188: [-Wunsafe-buffer-usage] Refactor and improve for parameter fix-its

2023-08-09 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 added a comment. > Btw, how does this work with `int **`? Given that the pointee type `int *` > isn't a simple identifier. It does not require the pointee type to be a simple identifier. The (source range of) pointee type is obtained by analyzing the `TypeLoc` of a variable decl

[PATCH] D157441: [-Wunsafe-buffer-usage] Use `Strategy` to determine whether to fix a parameter

2023-08-09 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 added a comment. >> Extend PointerAssignmentGadget and PointerInitGadget to generate fix-its for >> cases where the left-hand side >> has won't fix strategy and the right-hand side has std::span strategy. > > Hmm, is this intertwined with other changes, or is this completely separat

[PATCH] D153059: [-Wunsafe-buffer-usage] Group parameter fix-its

2023-07-12 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 updated this revision to Diff 539720. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D153059/new/ https://reviews.llvm.org/D153059 Files: clang/include/clang/Analysis/Analyses/UnsafeBufferUsage.h clang/include/clang/Basic/DiagnosticSemaKinds.td clang/lib/Analysis/UnsafeB

[PATCH] D153059: [-Wunsafe-buffer-usage] Group parameter fix-its

2023-07-12 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 added a comment. - a major change to the patch: Parameters are now grouped after the grouping of all variables. The groups that contain parameters of the function will form a union group. - changes to the grouping algorithm: Groups will reside in the vector `Groups` and being ac

[PATCH] D150338: [-Wunsafe-buffer-usage] Improving insertion of the [[clang::unsafe_buffer_usage]] attribute

2023-07-14 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 updated this revision to Diff 540548. ziqingluo-90 added a comment. rebase CHANGES SINCE LAST ACTION https://reviews.llvm.org/D150338/new/ https://reviews.llvm.org/D150338 Files: clang/include/clang/Analysis/Analyses/UnsafeBufferUsage.h clang/lib/Analysis/UnsafeBufferUsage.c

[PATCH] D150338: [-Wunsafe-buffer-usage] Improving insertion of the [[clang::unsafe_buffer_usage]] attribute

2023-07-14 Thread Ziqing Luo via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG5b012bf5ab5f: [-Wunsafe-buffer-usage] Improving insertion of the [[clang… (authored by ziqingluo-90). Repository: rG LLVM Github Monorepo CHANGES

[PATCH] D150338: [-Wunsafe-buffer-usage] Improving insertion of the [[clang::unsafe_buffer_usage]] attribute

2023-07-15 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 added a comment. In D150338#4502885 , @chapuni wrote: > Excuse me, I have reverted this due to circular deps. > `clangAnalysis` should not depend on `clangSema`. Thank you @chapuni , I will fix it soon. Repository: rG LLVM Github Monore

[PATCH] D150338: [-Wunsafe-buffer-usage] Improving insertion of the [[clang::unsafe_buffer_usage]] attribute

2023-07-15 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 added a comment. Re-landed in `a07a6f6c74a03405eccdcd3832acb2187d8b9c21` Moved the use of `clang::Sema` from `UnsafeBufferAnalysis` to `AnalysisBasedWarnings`. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D150338/new/ https://reviews

[PATCH] D157441: [-Wunsafe-buffer-usage] Use `Strategy` to determine whether to fix a parameter

2023-08-24 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 updated this revision to Diff 553226. ziqingluo-90 marked an inline comment as done. ziqingluo-90 edited the summary of this revision. ziqingluo-90 added a comment. In our offline discussion, we realized that `p = q.data()` is not always a correct fix to `p = q` for cases where only

[PATCH] D157441: [-Wunsafe-buffer-usage] Use `Strategy` to determine whether to fix a parameter

2023-08-24 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 added inline comments. Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:2586 #endif it = FixablesForAllVars.byVar.erase(it); } else if (Tracker.hasUnclaimedUses(it->first)) { We cannot fix reference type variable declarations for

[PATCH] D153059: [-Wunsafe-buffer-usage] Group parameter fix-its

2023-08-24 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 updated this revision to Diff 553285. ziqingluo-90 marked 2 inline comments as done. ziqingluo-90 added a comment. Address comments CHANGES SINCE LAST ACTION https://reviews.llvm.org/D153059/new/ https://reviews.llvm.org/D153059 Files: clang/include/clang/Analysis/Analyses/Uns

[PATCH] D158561: [-Wunsafe-buffer-usage] Add AST info to the unclaimed DRE debug notes for analysis

2023-09-06 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 updated this revision to Diff 556070. ziqingluo-90 added a comment. Add a test CHANGES SINCE LAST ACTION https://reviews.llvm.org/D158561/new/ https://reviews.llvm.org/D158561 Files: clang/lib/Analysis/UnsafeBufferUsage.cpp clang/test/SemaCXX/warn-unsafe-buffer-usage-debug-u

[PATCH] D138318: [-Wunsafe-buffer-usage] Improve pointer match pattern

2022-11-18 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 created this revision. ziqingluo-90 added reviewers: NoQ, jkorous, t-rasmud, malavikasamak, aaron.ballman, gribozavr, xazax.hun. Herald added a subscriber: rnkovacs. Herald added a project: All. ziqingluo-90 requested review of this revision. Herald added a project: clang. Herald adde

[PATCH] D138321: [-Wunsafe-buffer-usage] Ignore array subscript on literal zero

2022-11-18 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 created this revision. ziqingluo-90 added reviewers: NoQ, jkorous, t-rasmud, malavikasamak, aaron.ballman, gribozavr, xazax.hun. Herald added a subscriber: rnkovacs. Herald added a project: All. ziqingluo-90 requested review of this revision. Herald added a project: clang. Herald adde

[PATCH] D138318: [-Wunsafe-buffer-usage] Improve pointer match pattern

2022-11-18 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 updated this revision to Diff 476578. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D138318/new/ https://reviews.llvm.org/D138318 Files: clang/lib/Analysis/UnsafeBufferUsage.cpp clang/test/SemaCXX/warn-unsafe-buffer-usage.cpp Index: clang/test/SemaCXX/warn-unsafe-buffer-

[PATCH] D138321: [-Wunsafe-buffer-usage] Ignore array subscript on literal zero

2022-11-18 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 updated this revision to Diff 476581. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D138321/new/ https://reviews.llvm.org/D138321 Files: clang/lib/Analysis/UnsafeBufferUsage.cpp clang/test/SemaCXX/warn-unsafe-buffer-usage.cpp Index: clang/test/SemaCXX/warn-unsafe-buffer

[PATCH] D138329: [-Wunsafe-buffer-usage] Add a new recursive matcher to replace `forEachDescendant` in unsafe buffer check

2022-11-18 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 created this revision. ziqingluo-90 added reviewers: NoQ, jkorous, t-rasmud, malavikasamak, aaron.ballman, xazax.hun, gribozavr. Herald added a subscriber: rnkovacs. Herald added a project: All. ziqingluo-90 requested review of this revision. Herald added a project: clang. Herald adde

[PATCH] D138329: [-Wunsafe-buffer-usage] Add a new recursive matcher to replace `forEachDescendant` in unsafe buffer check

2022-11-18 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 added a comment. In D138329#3938351 , @xazax.hun wrote: > Is the problem `forEachDescendant` matching statements inside blocks and > lambdas? I wonder if this behavior would surprise people, so I think it would > be better to: > > - Potenti

[PATCH] D138318: [-Wunsafe-buffer-usage] Improve pointer match pattern

2022-11-28 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 updated this revision to Diff 478341. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D138318/new/ https://reviews.llvm.org/D138318 Files: clang/lib/Analysis/UnsafeBufferUsage.cpp clang/test/SemaCXX/warn-unsafe-buffer-usage.cpp Index: clang/test/SemaCXX/warn-unsafe-buffer-

[PATCH] D137379: [-Wunsafe-buffer-usage] Add warnings for unsafe buffer accesses by array subscript operations

2022-11-28 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 added a comment. > One test case I'd like to see is: `sizeof(p[0])` -- should code in an > unevaluated context be warned? I think they should NOT be warned. We haven't addressed the issue of unevaluated context in our patches. I'm adding a test for code in unevaluated context so

[PATCH] D137379: [-Wunsafe-buffer-usage] Add warnings for unsafe buffer accesses by array subscript operations

2022-11-28 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 added inline comments. Comment at: clang/test/SemaCXX/warn-unsafe-buffer-usage.cpp:10-13 +void foo(...); + +void * bar(void); +char * baz(void); steakhal wrote: > I would expect this test file to grow quite a bit. > As such, I think we should have mo

[PATCH] D137379: [-Wunsafe-buffer-usage] Add warnings for unsafe buffer accesses by array subscript operations

2022-11-28 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 updated this revision to Diff 478356. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D137379/new/ https://reviews.llvm.org/D137379 Files: clang/include/clang/Analysis/Analyses/UnsafeBufferUsageGadgets.def clang/lib/Analysis/UnsafeBufferUsage.cpp clang/test/SemaCXX/warn-u

[PATCH] D137379: [-Wunsafe-buffer-usage] Add warnings for unsafe buffer accesses by array subscript operations

2022-11-28 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 added inline comments. Comment at: clang/test/SemaCXX/warn-unsafe-buffer-usage.cpp:10-13 +void foo(...); + +void * bar(void); +char * baz(void); steakhal wrote: > NoQ wrote: > > ziqingluo-90 wrote: > > > steakhal wrote: > > > > I would expect this te

[PATCH] D138318: [-Wunsafe-buffer-usage] Improve pointer match pattern

2022-11-28 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 added inline comments. Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:31-39 +hasType(pointerType()), +hasType(autoType( +hasDeducedType(hasUnqualifiedDesugaredType(pointerType(), +// DecayedType, e.g., array type in formal parameter

[PATCH] D138329: [-Wunsafe-buffer-usage] Add a new recursive matcher to replace `forEachDescendant` in unsafe buffer check

2022-11-29 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 added inline comments. Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:54-55 + bool TraverseDecl(Decl *Node) { +if (!Node) + return true; +if (!match(*Node)) steakhal wrote: > Can `Node` be ever null if the visitor is initiated onl

[PATCH] D137379: [-Wunsafe-buffer-usage] Add warnings for unsafe buffer accesses by array subscript operations

2022-12-01 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 added inline comments. Comment at: clang/test/SemaCXX/warn-unsafe-buffer-usage.cpp:10-13 +void foo(...); + +void * bar(void); +char * baz(void); jkorous wrote: > NoQ wrote: > > ziqingluo-90 wrote: > > > steakhal wrote: > > > > NoQ wrote: > > > > > zi

[PATCH] D138318: [-Wunsafe-buffer-usage] Improve pointer match pattern

2022-12-01 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 added inline comments. Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:30-39 + return anyOf( +hasType(pointerType()), +hasType(autoType( +hasDeducedType(hasUnqualifiedDesugaredType(pointerType(), +// DecayedType, e.g., array type in

[PATCH] D138329: [-Wunsafe-buffer-usage] Add a new recursive matcher to replace `forEachDescendant` in unsafe buffer check

2022-12-01 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 added inline comments. Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:54-55 + bool TraverseDecl(Decl *Node) { +if (!Node) + return true; +if (!match(*Node)) NoQ wrote: > ziqingluo-90 wrote: > > steakhal wrote: > > > Can `Node` be

[PATCH] D139233: [-Wunsafe-buffer-usage] Add an unsafe gadget for pointer-arithmetic operations

2022-12-02 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 created this revision. ziqingluo-90 added reviewers: aaron.ballman, xazax.hun, steakhal, gribozavr, jkorous, NoQ, malavikasamak, t-rasmud. Herald added a subscriber: rnkovacs. Herald added a project: All. ziqingluo-90 requested review of this revision. Herald added a project: clang. H

[PATCH] D146342: [WIP][-Wunsafe-buffer-usage] Move the whole analysis to the end of a translation unit

2023-03-17 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 created this revision. ziqingluo-90 added reviewers: NoQ, jkorous, t-rasmud, malavikasamak. Herald added a subscriber: ChuanqiXu. Herald added a project: All. ziqingluo-90 requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits. Our ana

[PATCH] D144064: [-Wunsafe-buffer-usage] Match unsafe pointers being casted to bool or participating in pointer subtractions

2023-03-20 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 updated this revision to Diff 506733. ziqingluo-90 marked 2 inline comments as done. ziqingluo-90 added a comment. Address comments CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144064/new/ https://reviews.llvm.org/D144064 Files: clang/lib/Analysis/UnsafeBufferUsage.cpp

[PATCH] D142795: [-Wunsafe-buffer-usage] Add Fixable for dereference of simple ptr arithmetic

2023-03-20 Thread Ziqing Luo via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG6a0f2e539b8e: [-Wunsafe-buffer-usage] Add Fixable for dereference of simple ptr arithmetic (authored by ziqingluo-90). Herald added a project: clang.

[PATCH] D146342: [WIP][-Wunsafe-buffer-usage] Move the whole analysis to the end of a translation unit

2023-03-21 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 added a comment. >> Current tests are mostly fine except that some notes with message "in >> instantiation of ... " are missing. Although these notes are not emitted by >> our analysis, we better understand why things change. > > This sounds familiar, I think @usama54321 ran into a

[PATCH] D146342: [WIP][-Wunsafe-buffer-usage] Move the whole analysis to the end of a translation unit

2023-03-22 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 added a comment. The template specialization information is still available but we may need to print it by ourselves. I will add a FIXME there and we will deal with it in a follow-up patch. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.or

[PATCH] D146669: [-Wunsafe-buffer-usage] Hide fixits/suggestions behind an extra flag, -fsafe-buffer-usage-suggestions.

2023-03-23 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 added inline comments. Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:1139 UnsafeBufferUsageHandler &Handler, + bool EmitSuggestions, bool EmitFixits) { --

[PATCH] D146669: [-Wunsafe-buffer-usage] Hide fixits/suggestions behind an extra flag, -fsafe-buffer-usage-suggestions.

2023-03-23 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 added inline comments. Comment at: clang/lib/Sema/AnalysisBasedWarnings.cpp:2203 +if (IsRelatedToDecl) { + assert(!SuggestSuggestions && + "Variables blamed for unsafe buffer usage without suggestions!"); nitpick: I was a bit co

[PATCH] D146342: [WIP][-Wunsafe-buffer-usage] Move the whole analysis to the end of a translation unit

2023-03-24 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 updated this revision to Diff 508249. ziqingluo-90 added a comment. Address comments. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D146342/new/ https://reviews.llvm.org/D146342 Files: clang/include/clang/Analysis/Analyses/UnsafeBufferUsage.h clang/include/clang/Sema/An

[PATCH] D137379: [-Wunsafe-buffer-usage] Add warnings for unsafe buffer accesses by array subscript operations

2023-03-27 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 added a comment. In D137379#4225000 , @manojgupta wrote: > This is firing even in checked length codes, is that expected? Yes, it is expected. The unsafe buffer analysis is syntax-based. The analysis warns operations that do not follow t

[PATCH] D143128: [-Wunsafe-buffer-usage] Fix-Its transforming `&DRE[any]` to `(DRE.data() + any)`

2023-03-07 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 updated this revision to Diff 503193. ziqingluo-90 added a comment. Thanks for the valuable discussion about the philosophy on the ideal forms of fix-its. In this case, I think `&DRE.data()[any]` and `(DRE.data() + any)` are both straightforward enough for the user to tell what has

[PATCH] D144304: [-Wunsafe-buffer-usage] Add a Fixable for pointer pre-increment

2023-03-07 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 added inline comments. Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:663 +return stmt(isInUnspecifiedPointerContext(expr( + ignoringImpCasts(unaryOperator(isPreInc()).bind(UPCPreIncrementTag); + } NoQ wrote: > You're not check

[PATCH] D144304: [-Wunsafe-buffer-usage] Add a Fixable for pointer pre-increment

2023-03-09 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 updated this revision to Diff 503928. ziqingluo-90 added a comment. Rebased and addressed comments. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144304/new/ https://reviews.llvm.org/D144304 Files: clang/include/clang/Analysis/Analyses/UnsafeBufferUsageGadgets.def clan

[PATCH] D145993: [-Wunsafe-buffer-usage] Reducing non-determinism in diagnostics output stream

2023-03-13 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 created this revision. ziqingluo-90 added reviewers: jkorous, NoQ, malavikasamak, t-rasmud, xazax.hun, ymandel, gribozavr, aaron.ballman. Herald added subscribers: mgrang, rnkovacs. Herald added a project: All. ziqingluo-90 requested review of this revision. Herald added a project: cl

[PATCH] D145993: [-Wunsafe-buffer-usage] Reducing non-determinism in diagnostics output stream

2023-03-13 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 added inline comments. Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:1073 : FixItList{}); for (const auto &G : WarningGadgets) { Handler.handleUnsafeOperation(G->getBaseStmt(), /*IsRelatedToDecl=*/true);

[PATCH] D145993: [-Wunsafe-buffer-usage] Reducing non-determinism in diagnostics output stream

2023-03-13 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 updated this revision to Diff 504896. ziqingluo-90 added a comment. Address comments CHANGES SINCE LAST ACTION https://reviews.llvm.org/D145993/new/ https://reviews.llvm.org/D145993 Files: clang/lib/Analysis/UnsafeBufferUsage.cpp clang/test/SemaCXX/warn-unsafe-buffer-usage-f

[PATCH] D145993: [-Wunsafe-buffer-usage] Reducing non-determinism in diagnostics output stream

2023-03-13 Thread Ziqing Luo via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG148dc8a2a80f: [-Wunsafe-buffer-usage] Reducing non-determinism in diagnostics output stream (authored by ziqingluo-90). Changed prior to commit: h

[PATCH] D153059: [-Wunsafe-buffer-usage] Group parameter fix-its

2023-06-21 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 added inline comments. Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:2077 + for (const auto &[VD, Fixables] : FixablesForUnsafeVars.byVar) { FixItsForVariable[VD] = NoQ wrote: > There's a bug in variable naming: `FixablesForUnsafeVars`

[PATCH] D153059: [-Wunsafe-buffer-usage] Group parameter fix-its

2023-06-22 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 added inline comments. Comment at: clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-multi-parm-span.cpp:13-15 + expected-note{{change type of 'p' to 'std::span' to preserve bounds information, and change 'q' and 'a' to 'std::span' to propagate bounds informati

[PATCH] D153059: [-Wunsafe-buffer-usage] Group parameter fix-its

2023-06-22 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 added inline comments. Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:2293 +// search of connected components. +if (!ParmsNeedFix.empty()) { + auto First = ParmsNeedFix.begin(), Last = First; NoQ wrote: > ziqingluo-90 wrote: >

[PATCH] D153059: [-Wunsafe-buffer-usage] Group parameter fix-its

2023-06-23 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 added inline comments. Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:2293 +// search of connected components. +if (!ParmsNeedFix.empty()) { + auto First = ParmsNeedFix.begin(), Last = First; NoQ wrote: > ziqingluo-90 wrote: >

cfe-commits@lists.llvm.org

2023-04-04 Thread Ziqing Luo via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG87b5807d3802: [-Wunsafe-buffer-usage] Fix-Its transforming `&DRE[any]` to `&DRE.data()[any]` (authored by ziqingluo-90). Changed prior to commit:

[PATCH] D144304: [-Wunsafe-buffer-usage] Add a Fixable for pointer pre-increment

2023-04-04 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 marked an inline comment as done. ziqingluo-90 added inline comments. Comment at: clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-addressof-arraysubscript.cpp:19 bool a = (bool) &p[5]; - // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:19-[[@LINE-1]]:24}:"(p.data() + 5

cfe-commits@lists.llvm.org

2023-04-05 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 added a comment. In D143128#4245112 , @DavidSpickett wrote: > I've reverted this, please try to fix the test then reland. > > The full test output can be downloaded from the buildbot page, if you need > any more information let me know. Th

[PATCH] D143680: [-Wunsafe-buffer-usage] Improve fix-its for local variable declarations with null pointer initializers

2023-04-10 Thread Ziqing Luo via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG63413015099b: [-Wunsafe-buffer-usage] Improve fix-its for local variable declarations with… (authored by ziqingluo-90). Changed prior to commit: h

[PATCH] D144064: [-Wunsafe-buffer-usage] Match unsafe pointers being casted to bool or participating in pointer subtractions

2023-04-11 Thread Ziqing Luo via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG88f7f018e23b: [-Wunsafe-buffer-usage] Match unsafe pointers being casted to bool or… (authored by ziqingluo-90). Changed prior to commit: https://

[PATCH] D144304: [-Wunsafe-buffer-usage] Add a Fixable for pointer pre-increment

2023-04-12 Thread Ziqing Luo via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG762af11d4c5d: [-Wunsafe-buffer-usage] Add a Fixable for pointer pre-increment (authored by ziqingluo-90). Changed prior to commit: https://reviews

[PATCH] D143128: [-Wunsafe-buffer-usage][WIP] Fix-Its transforming `&DRE[any]` to `DRE.data() + any`

2023-02-06 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 added inline comments. Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:162 + InnerMatcher)), + unless(callee(functionDecl(hasAttr(attr::UnsafeBufferUsage); + auto CastOperandMatcher = jkorous wrote: > I am ju

[PATCH] D143128: [-Wunsafe-buffer-usage][WIP] Fix-Its transforming `&DRE[any]` to `DRE.data() + any`

2023-02-06 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 added a comment. In D143128#4108375 , @NoQ wrote: > Why do we prefer `DRE.data() + any` to `&DRE.data()[any]`? It could be much > less intrusive this way, and the safety guarantees are the same. It is actually `(DRE.data() + any)` versus `&

[PATCH] D143128: [-Wunsafe-buffer-usage][WIP] Fix-Its transforming `&DRE[any]` to `(DRE.data() + any)`

2023-02-06 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 updated this revision to Diff 495325. ziqingluo-90 retitled this revision from "[-Wunsafe-buffer-usage][WIP] Fix-Its transforming `&DRE[any]` to `DRE.data() + any`" to "[-Wunsafe-buffer-usage][WIP] Fix-Its transforming `&DRE[any]` to `(DRE.data() + any)`". ziqingluo-90 added a comme

[PATCH] D139737: [-Wunsafe-buffer-usage] Initiate Fix-it generation for local variable declarations

2023-02-07 Thread Ziqing Luo via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rGa29e67614c3b: [-Wunsafe-buffer-usage] Generate fix-it for local variable declarations (authored by ziqingluo-90). Changed prior to commit: https:/

[PATCH] D141338: [-Wunsafe-buffer-usage] Filter out conflicting fix-its

2023-02-07 Thread Ziqing Luo via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG692da6245d71: [-Wunsafe-buffer-usage] Filter out conflicting fix-its (authored by ziqingluo-90). Changed prior to commit: https://reviews.llvm.org

[PATCH] D140179: [-Wunsafe-buffer-usage] Add unsafe buffer checking opt-out pragmas

2023-02-07 Thread Ziqing Luo via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rGaef05b5dc5c5: [-Wunsafe-buffer-usage] Add unsafe buffer checking opt-out pragmas (authored by ziqingluo-90). Changed prior to commit: https://revi

[PATCH] D143680: [WIP][-Wunsafe-buffer-usage] Improve fix-its for local variable declarations with null pointer initializers

2023-02-09 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 created this revision. ziqingluo-90 added reviewers: jkorous, NoQ, t-rasmud, malavikasamak. Herald added a project: All. ziqingluo-90 requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits. For a local pointer declaration of the form `

[PATCH] D143680: [WIP][-Wunsafe-buffer-usage] Improve fix-its for local variable declarations with null pointer initializers

2023-02-13 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 updated this revision to Diff 497051. ziqingluo-90 added a comment. Rebased CHANGES SINCE LAST ACTION https://reviews.llvm.org/D143680/new/ https://reviews.llvm.org/D143680 Files: clang/lib/Analysis/UnsafeBufferUsage.cpp clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-loc

[PATCH] D143128: [-Wunsafe-buffer-usage][WIP] Fix-Its transforming `&DRE[any]` to `(DRE.data() + any)`

2023-02-13 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 updated this revision to Diff 497057. ziqingluo-90 added a comment. Rebased. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D143128/new/ https://reviews.llvm.org/D143128 Files: clang/include/clang/Analysis/Analyses/UnsafeBufferUsage.h clang/include/clang/Analysis/Analyse

[PATCH] D144064: [WIP][-Wunsafe-buffer-usage] Match unsafe pointers being casted to bool or participating in pointer subtractions

2023-02-14 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 created this revision. ziqingluo-90 added reviewers: jkorous, NoQ, malavikasamak, t-rasmud. Herald added a project: All. ziqingluo-90 requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits. To add two new unique cases to the Unspecifie

[PATCH] D143680: [WIP][-Wunsafe-buffer-usage] Improve fix-its for local variable declarations with null pointer initializers

2023-02-16 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 added inline comments. Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:1034-1035 +assert(!InitFixIts.empty() && + "Expected at least one fix-it for an initializer of an unsafe " + "variable declaration."); // The loc right before the

[PATCH] D143680: [WIP][-Wunsafe-buffer-usage] Improve fix-its for local variable declarations with null pointer initializers

2023-02-17 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 updated this revision to Diff 498493. ziqingluo-90 marked 3 inline comments as done. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D143680/new/ https://reviews.llvm.org/D143680 Files: clang/lib/Analysis/UnsafeBufferUsage.cpp clang/test/SemaCXX/warn-unsafe-buffer-usage-fix

[PATCH] D143680: [WIP][-Wunsafe-buffer-usage] Improve fix-its for local variable declarations with null pointer initializers

2023-02-17 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 updated this revision to Diff 498494. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D143680/new/ https://reviews.llvm.org/D143680 Files: clang/lib/Analysis/UnsafeBufferUsage.cpp clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-local-var-span.cpp Index: clang/test/SemaC

[PATCH] D143128: [-Wunsafe-buffer-usage] Fix-Its transforming `&DRE[any]` to `(DRE.data() + any)`

2023-02-17 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 updated this revision to Diff 498498. ziqingluo-90 added a comment. Now we have different `FixableGadget`s that may match the same `Stmt` (representing a context). So in order to discover all "Fixable"s, we can no longer match `anyOf` `FixableGadget`s' matchers. Instead, we match

[PATCH] D143128: [-Wunsafe-buffer-usage] Fix-Its transforming `&DRE[any]` to `(DRE.data() + any)`

2023-02-17 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 added inline comments. Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:849 // in one `anyOf` group (for better performance via short-circuiting). - stmt(anyOf( + stmt(eachOf( #define FIXABLE_GADGET(x)

[PATCH] D144304: [WIP][-Wunsafe-buffer-usage] Add a Fixable for pointer pre-increment

2023-02-17 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 created this revision. ziqingluo-90 added reviewers: jkorous, NoQ, t-rasmud, malavikasamak. Herald added a project: All. ziqingluo-90 requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits. For a pointer type expression `e` of the form

[PATCH] D143697: [-Wunsafe-buffer-usage] Create Fix-Its only if they are emitted

2023-02-23 Thread Ziqing Luo via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rGf78c34346635: [-Wunsafe-buffer-usage] Create Fix-Its only if they are emitted (authored by ziqingluo-90). Herald added a project: clang. Herald added

[PATCH] D142794: [-Wunsafe-buffer-usage] Fixits for assignment to array subscript expr

2023-02-23 Thread Ziqing Luo via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rGcd2652963b6b: [-Wunsafe-buffer-usage] Fixits for assignments to array subscript expressions (authored by ziqingluo-90). Herald added a project: clang

[PATCH] D146342: [-Wunsafe-buffer-usage] Move the whole analysis to the end of a translation unit

2023-05-04 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 updated this revision to Diff 519719. ziqingluo-90 marked 3 inline comments as done. ziqingluo-90 added a comment. Addressed the comments: - 1) about using a more traditional way of AST traversal; and - 2) about the concern on `ObjcMethodDecl` traversal. CHANGES SINCE LAST ACTION

[PATCH] D146342: [-Wunsafe-buffer-usage] Move the whole analysis to the end of a translation unit

2023-05-04 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 added inline comments. Comment at: clang/lib/Sema/AnalysisBasedWarnings.cpp:2335 + // To analyze callables: + if (isa(Node)) { +// For code in dependent contexts, we'll do this at instantiation time: NoQ wrote: > The intended way to

[PATCH] D146342: [-Wunsafe-buffer-usage] Move the whole analysis to the end of a translation unit

2023-05-05 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 marked an inline comment as done. ziqingluo-90 added inline comments. Comment at: clang/lib/Sema/AnalysisBasedWarnings.cpp:2363-2364 + if (isa(Node)) { +// to visit implicit children of `LambdaExpr`s: +IsVisitingLambda = true; +

[PATCH] D146342: [-Wunsafe-buffer-usage] Move the whole analysis to the end of a translation unit

2023-05-05 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 updated this revision to Diff 519958. ziqingluo-90 marked an inline comment as done. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D146342/new/ https://reviews.llvm.org/D146342 Files: clang/include/clang/Sema/AnalysisBasedWarnings.h clang/lib/Sema/AnalysisBasedWarnings.cp

<    1   2   3   >