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

2023-05-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. ziqingluo-90 marked an inline comment as done. Closed by commit rG6d861d498de1: [-Wunsafe-buffer-usage] Move the whole analysis to the end of a translation unit

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

2023-05-12 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:2364 + Node->getBeginLoc())) { + UnsafeBufferUsageReporter R(S); + clang::checkUnsafeBufferUsage(Node, R,

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

2023-05-11 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision. NoQ added a comment. This revision is now accepted and ready to land. Ok looks great to me now! Comment at: clang/lib/Sema/AnalysisBasedWarnings.cpp:2364 + Node->getBeginLoc())) { + UnsafeBufferUsageReporter R(S); +

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

2023-05-11 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 updated this revision to Diff 521409. ziqingluo-90 added a comment. Address comments: refactor the callable-definition visitor to take a lambda Callback, who calls various analyses that need whole-TU information.If one needs to add a new such analysis later, just add a call

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

2023-05-10 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments. Comment at: clang/lib/Sema/AnalysisBasedWarnings.cpp:2340 + if (Node->doesThisDeclarationHaveABody()) +checkUnsafeBufferUsage(Node); + return true; This code will grow bigger when more warnings are added, and it's

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

2023-05-10 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 updated this revision to Diff 521184. 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.cpp clang/lib/Sema/Sema.cpp

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

2023-05-10 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 updated this revision to Diff 521177. 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.cpp clang/lib/Sema/Sema.cpp

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

2023-05-10 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 updated this revision to Diff 521176. ziqingluo-90 added a comment. Clean up the code for early return in case of ignoring `unsafe_buffer_usage` warnings. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D146342/new/ https://reviews.llvm.org/D146342 Files:

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

2023-05-09 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 updated this revision to Diff 520859. ziqingluo-90 added a comment. Visit `LambdaExpr` properly CHANGES SINCE LAST ACTION https://reviews.llvm.org/D146342/new/ https://reviews.llvm.org/D146342 Files: clang/include/clang/Sema/AnalysisBasedWarnings.h

[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

[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-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

[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-02 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments. Comment at: clang/lib/Sema/AnalysisBasedWarnings.cpp:2320-2323 +void traverseTU(const TranslationUnitDecl *TU) { + for (auto I = TU->decls_begin(); I != TU->decls_end(); ++I) +TraverseDecl(*I); +}

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

2023-05-01 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 updated this revision to Diff 518608. 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.cpp clang/lib/Sema/Sema.cpp

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

2023-04-26 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 updated this revision to Diff 517413. ziqingluo-90 added a comment. Move the traversal framework to `AnalysisBasedWarnings` so that the `UnsafeBufferUsage` analyzer (as well as other possible analyzers) is still function based. It is in the same pattern as the original

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

2023-04-19 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments. Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:1478 + + struct CallableFinderCallback : MatchFinder::MatchCallback { +UnsafeBufferUsageHandler I think this entire matcher business can easily live in