[clang] [llvm] [analyzer] Delete `alpha.security.MallocOverflow` (PR #103059)

2024-08-13 Thread Artem Dergachev via cfe-commits
@@ -1039,10 +1039,6 @@ def ArrayBoundCheckerV2 : Checker<"ArrayBoundV2">, HelpText<"Warn about buffer overflows (newer checker)">, Documentation; -def MallocOverflowSecurityChecker : Checker<"MallocOverflow">, haoNoQ wrote: We could keep this for a while

[clang] [llvm] [analyzer] Delete `alpha.security.MallocOverflow` (PR #103059)

2024-08-13 Thread Artem Dergachev via cfe-commits
haoNoQ wrote: > Instead of actually tracking the symbolic values and the known constraints on > them, this checker blindly gropes the AST and uses heuristics like "this > variable was seen in a comparison operator expression that is not a loop > condition, so it's probably not too large" (whic

[clang] Warning Libc functions (PR #101583)

2024-08-13 Thread Artem Dergachev via cfe-commits
@@ -443,6 +448,368 @@ AST_MATCHER(ArraySubscriptExpr, isSafeArraySubscript) { return false; } +namespace libc_fun_disjoint_inner_matchers { +// `libc_fun_disjoint_inner_matchers` covers a set of matchers that match +// disjoint node sets. They all take a `CoreName`, which

[clang] Warning Libc functions (PR #101583)

2024-08-13 Thread Artem Dergachev via cfe-commits
@@ -783,6 +783,18 @@ bool ParsePrintfString(FormatStringHandler &H, bool ParseFormatStringHasSArg(const char *beg, const char *end, const LangOptions &LO, const TargetInfo &Target); +/// Parse C format string and return index (relative to `ArgInde

[clang] Warning Libc functions (PR #101583)

2024-08-13 Thread Artem Dergachev via cfe-commits
@@ -443,6 +448,368 @@ AST_MATCHER(ArraySubscriptExpr, isSafeArraySubscript) { return false; } +namespace libc_fun_disjoint_inner_matchers { +// `libc_fun_disjoint_inner_matchers` covers a set of matchers that match +// disjoint node sets. They all take a `CoreName`, which

[clang] Warning Libc functions (PR #101583)

2024-08-13 Thread Artem Dergachev via cfe-commits
@@ -483,6 +483,34 @@ bool clang::analyze_format_string::ParseFormatStringHasSArg(const char *I, return false; } +unsigned clang::analyze_format_string::ParseFormatStringFirstSArgIndex( +const char *&I, const char *E, unsigned ArgIndex, const LangOptions &LO, +const

[clang] Warning Libc functions (PR #101583)

2024-08-13 Thread Artem Dergachev via cfe-commits
@@ -443,6 +448,368 @@ AST_MATCHER(ArraySubscriptExpr, isSafeArraySubscript) { return false; } +namespace libc_fun_disjoint_inner_matchers { +// `libc_fun_disjoint_inner_matchers` covers a set of matchers that match +// disjoint node sets. They all take a `CoreName`, which

[clang] Warning Libc functions (PR #101583)

2024-08-13 Thread Artem Dergachev via cfe-commits
@@ -2292,6 +2292,18 @@ class UnsafeBufferUsageReporter : public UnsafeBufferUsageHandler { } } + void handleUnsafeLibcCall(const CallExpr *Call, unsigned PrintfInfo, +ASTContext &Ctx) override { +// We have checked that there is a direct

[clang] Warning Libc functions (PR #101583)

2024-08-13 Thread Artem Dergachev via cfe-commits
@@ -443,6 +448,368 @@ AST_MATCHER(ArraySubscriptExpr, isSafeArraySubscript) { return false; } +namespace libc_fun_disjoint_inner_matchers { +// `libc_fun_disjoint_inner_matchers` covers a set of matchers that match +// disjoint node sets. They all take a `CoreName`, which

[clang] Warning Libc functions (PR #101583)

2024-08-13 Thread Artem Dergachev via cfe-commits
@@ -443,6 +448,368 @@ AST_MATCHER(ArraySubscriptExpr, isSafeArraySubscript) { return false; } +namespace libc_fun_disjoint_inner_matchers { +// `libc_fun_disjoint_inner_matchers` covers a set of matchers that match +// disjoint node sets. They all take a `CoreName`, which

[clang] Warning Libc functions (PR #101583)

2024-08-13 Thread Artem Dergachev via cfe-commits
@@ -443,6 +448,368 @@ AST_MATCHER(ArraySubscriptExpr, isSafeArraySubscript) { return false; } +namespace libc_fun_disjoint_inner_matchers { +// `libc_fun_disjoint_inner_matchers` covers a set of matchers that match +// disjoint node sets. They all take a `CoreName`, which

[clang] [-Wunsafe-buffer-usage] Fix a small bug recently found (PR #102953)

2024-08-14 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ edited https://github.com/llvm/llvm-project/pull/102953 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [-Wunsafe-buffer-usage] Warning Libc functions (PR #101583)

2024-08-14 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ edited https://github.com/llvm/llvm-project/pull/101583 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [-Wunsafe-buffer-usage] Fix a small bug recently found (PR #102953)

2024-08-14 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ approved this pull request. LGTM! https://github.com/llvm/llvm-project/pull/102953 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [analyzer] Set and display CSA analysis entry points as notes on debugging (PR #84823)

2024-04-04 Thread Artem Dergachev via cfe-commits
@@ -788,7 +791,7 @@ class PathDiagnostic : public llvm::FoldingSetNode { PathDiagnostic(StringRef CheckerName, const Decl *DeclWithIssue, StringRef bugtype, StringRef verboseDesc, StringRef shortDesc, StringRef category, PathDiagnosticLocatio

[clang] [analyzer] `canReasonAbout` does not support `nonloc::LazyCompoundVal` (PR #87521)

2024-04-04 Thread Artem Dergachev via cfe-commits
@@ -0,0 +1,17 @@ +// REQUIRES: crash-recovery, asserts haoNoQ wrote: You probably don't need this. There's no need to disable a perfectly normal test just because it didn't crash before the patch in that configuration. It's still nice to know that it doesn't cr

[clang] [analyzer] `canReasonAbout` does not support `nonloc::LazyCompoundVal` (PR #87521)

2024-04-04 Thread Artem Dergachev via cfe-commits
haoNoQ wrote: > Here's the traceback for the second set: The constraint manager doesn't even exist yet at the moment of time represented by this backtrace. There's something else going on. I suspect that you're loading checkers as clang plugins and one of them is causing it. https://github.co

[clang] Add handling of the `-nostdlibinc` option to ccc-analyzer (PR #88017)

2024-04-08 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ approved this pull request. https://github.com/llvm/llvm-project/pull/88017 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Add handling of the `-nostdlibinc` option to ccc-analyzer (PR #88017)

2024-04-08 Thread Artem Dergachev via cfe-commits
haoNoQ wrote: I never realized that scan-build makes a "short list" of flags to pass through and throws away the rest. This is terrifying. It only works because most compiler flags are recognized because they're prefixed with `-f`, `-W`, etc.; but it's fascinating that it even works. This may

[clang] Respect the [[clang::unsafe_buffer_usage]] attribute for field and constructor initializers (PR #91991)

2024-06-06 Thread Artem Dergachev via cfe-commits
@@ -3328,3 +3300,63 @@ void clang::checkUnsafeBufferUsage(const Decl *D, } } } + +void clang::checkUnsafeBufferUsage(const Decl *D, + UnsafeBufferUsageHandler &Handler, + bool EmitSuggestions) { +#ifndef

[clang] Respect the [[clang::unsafe_buffer_usage]] attribute for field and constructor initializers (PR #91991)

2024-06-10 Thread Artem Dergachev via cfe-commits
@@ -3328,3 +3300,63 @@ void clang::checkUnsafeBufferUsage(const Decl *D, } } } + +void clang::checkUnsafeBufferUsage(const Decl *D, + UnsafeBufferUsageHandler &Handler, + bool EmitSuggestions) { +#ifndef

[clang] Respect the [[clang::unsafe_buffer_usage]] attribute for field and constructor initializers (PR #91991)

2024-06-10 Thread Artem Dergachev via cfe-commits
@@ -3328,3 +3300,63 @@ void clang::checkUnsafeBufferUsage(const Decl *D, } } } + +void clang::checkUnsafeBufferUsage(const Decl *D, + UnsafeBufferUsageHandler &Handler, + bool EmitSuggestions) { +#ifndef

[clang] [Safe Buffers] Serialize unsafe_buffer_usage pragmas (PR #92031)

2024-06-12 Thread Artem Dergachev via cfe-commits
@@ -1483,26 +1484,40 @@ void Preprocessor::emitFinalMacroWarning(const Token &Identifier, } bool Preprocessor::isSafeBufferOptOut(const SourceManager &SourceMgr, - const SourceLocation &Loc) const { - // Try to find a region in `Safe

[clang] [Safe Buffers] Serialize unsafe_buffer_usage pragmas (PR #92031)

2024-06-12 Thread Artem Dergachev via cfe-commits
@@ -1911,6 +1911,20 @@ SourceManager::getDecomposedIncludedLoc(FileID FID) const { return DecompLoc; } +FileID SourceManager::getFirstFIDOfLoadedAST(SourceLocation Loc) const { + assert(isLoadedSourceLocation(Loc) && + "Must be a source location in a loaded PCH/Mod

[clang] [Safe Buffers] Serialize unsafe_buffer_usage pragmas (PR #92031)

2024-06-12 Thread Artem Dergachev via cfe-commits
haoNoQ wrote: Ok I think I'm completely happy with the patch now. It makes perfect sense to me and appears to be doing the right thing. Thank you @ziqingluo-90 for figuring this out! Let's add that comment and land. https://github.com/llvm/llvm-project/pull/92031 __

[clang] [clang] Clean up macOS version flags (PR #95374)

2024-06-13 Thread Artem Dergachev via cfe-commits
@@ -389,6 +389,7 @@ my %CompilerLinkerOptionMap = ( '-target' => 1, '-v' => 0, '-mmacosx-version-min' => 0, # This is really a 1 argument, but always has '=' + '-mmacos-version-min' => 0, # This is really a 1 argument, but always has '=' haoNoQ wrote:

[clang] [Safe Buffers] Serialize unsafe_buffer_usage pragmas (PR #92031)

2024-06-13 Thread Artem Dergachev via cfe-commits
@@ -1911,18 +1911,22 @@ SourceManager::getDecomposedIncludedLoc(FileID FID) const { return DecompLoc; } -FileID SourceManager::getFirstFIDOfLoadedAST(SourceLocation Loc) const { +unsigned SourceManager::getUniqueLoadedASTID(SourceLocation Loc) const { assert(isLoadedSour

[clang] [Safe Buffers] Serialize unsafe_buffer_usage pragmas (PR #92031)

2024-06-13 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ approved this pull request. Ok LGTM!! Thanks again for figuring this all out! https://github.com/llvm/llvm-project/pull/92031 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listi

[clang] Respect the [[clang::unsafe_buffer_usage]] attribute for field and constructor initializers (PR #91991)

2024-06-17 Thread Artem Dergachev via cfe-commits
@@ -3328,3 +3300,63 @@ void clang::checkUnsafeBufferUsage(const Decl *D, } } } + +void clang::checkUnsafeBufferUsage(const Decl *D, + UnsafeBufferUsageHandler &Handler, + bool EmitSuggestions) { +#ifndef

[clang] [clang] Move 'alpha.cplusplus.MisusedMovedObject' to 'cplusplus.Move' in documentation (NFC) (PR #95003)

2024-06-20 Thread Artem Dergachev via cfe-commits
haoNoQ wrote: > The checker was renamed at some time ago but the documentation was not > updated. Yupp my bad. Thank you folks! https://github.com/llvm/llvm-project/pull/95003 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm

[clang] [clang][dataflow] Handle CXXInheritedCtorInitExpr in ResultObjectVisitor. (PR #99616)

2024-07-24 Thread Artem Dergachev via cfe-commits
haoNoQ wrote: I have a high-level question not directly related to the patch. We have probably even talked about it at a conference a few years ago but I don't remember 😅 > `ResultObjectVisitor` I briefly looked at the implementation and I suspect that you folks might be reinventing [`Const

[clang] [clang][dataflow] Handle CXXInheritedCtorInitExpr in ResultObjectVisitor. (PR #99616)

2024-07-30 Thread Artem Dergachev via cfe-commits
haoNoQ wrote: > Thanks for the info -- I wasn't aware of `ConstructionContext`. Will take a > look. Can you point me to some examples of how this is used? The initial motivation was here: https://github.com/llvm/llvm-project/blob/llvmorg-19-init/clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp#

[clang] [alpha.webkit.UncountedCallArgsChecker] Avoid emitting warnings for Ref, RefPtr, and their variants. (PR #90153)

2024-04-25 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ approved this pull request. LGTM! https://github.com/llvm/llvm-project/pull/90153 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Revert "[LinkerWrapper] Extend with usual pass options (#96704)" (PR #102226)

2024-08-27 Thread Artem Dergachev via cfe-commits
haoNoQ wrote: Yeah I think we really gotta cherry-pick this revert, because failing tests on release branches are somewhat scary (cf. https://green.lab.llvm.org/job/llvm.org/job/clang-stage1-RA-release-branch/69/console). I don't know how it's usually done but let me try to push some buttons,

[clang] Revert "[LinkerWrapper] Extend with usual pass options (#96704)" (PR #102226)

2024-08-27 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ milestoned https://github.com/llvm/llvm-project/pull/102226 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Revert "[LinkerWrapper] Extend with usual pass options (#96704)" (PR #102226)

2024-08-27 Thread Artem Dergachev via cfe-commits
haoNoQ wrote: /cherry-pick 3ddd7a6df3ef85cbfe3f5fc0294817638275d4df https://github.com/llvm/llvm-project/pull/102226 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Revert "[LinkerWrapper] Extend with usual pass options (#96704)" (PR #102226)

2024-08-27 Thread Artem Dergachev via cfe-commits
haoNoQ wrote: /cherry-pick 030ee841a9c9fbbd6e7c001e751737381da01f7b https://github.com/llvm/llvm-project/pull/102226 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Revert "[LinkerWrapper] Extend with usual pass options (#96704)" (PR #102226)

2024-08-27 Thread Artem Dergachev via cfe-commits
haoNoQ wrote: Oh that's just a whitespace change. Would you like me to make a manual PR or were you looking into it anyway? https://github.com/llvm/llvm-project/pull/102226 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org

[clang] Revert "[LinkerWrapper] Extend with usual pass options (#96704)" (PR #102226)

2024-08-28 Thread Artem Dergachev via cfe-commits
haoNoQ wrote: #106439 https://github.com/llvm/llvm-project/pull/102226 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [-Wunsafe-buffer-usage] Warning Libc functions (PR #101583)

2024-08-29 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ approved this pull request. I think this is good to go, LGTM!! https://github.com/llvm/llvm-project/pull/101583 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commit

[clang] [-Wunsafe-buffer-usage] Warning Libc functions (PR #101583)

2024-08-29 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ edited https://github.com/llvm/llvm-project/pull/101583 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [-Wunsafe-buffer-usage] Warning Libc functions (PR #101583)

2024-08-29 Thread Artem Dergachev via cfe-commits
@@ -443,6 +443,426 @@ AST_MATCHER(ArraySubscriptExpr, isSafeArraySubscript) { return false; } +AST_MATCHER_P(CallExpr, hasNumArgs, unsigned, Num) { + return Node.getNumArgs() == Num; +} + +namespace libc_func_matchers { +// Under `libc_func_matchers`, define a set of matche

[clang] [alpha.webkit.UncountedCallArgsChecker] Ignore methods of WTF String classes. (PR #90180)

2024-04-30 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ approved this pull request. LGTM! https://github.com/llvm/llvm-project/pull/90180 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [alpha.webkit.UncountedCallArgsChecker] Support more trivial expressions. (PR #90414)

2024-04-30 Thread Artem Dergachev via cfe-commits
@@ -360,6 +370,16 @@ class TrivialFunctionAnalysisVisitor return TrivialFunctionAnalysis::isTrivialImpl(Callee, Cache); } + bool + VisitSubstNonTypeTemplateParmExpr(const SubstNonTypeTemplateParmExpr *E) { +// Non-type template paramter is trivial if the replacemen

[clang] [alpha.webkit.UncountedCallArgsChecker] Support more trivial expressions. (PR #90414)

2024-04-30 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ approved this pull request. LGTM other than the other tiny comment. https://github.com/llvm/llvm-project/pull/90414 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-co

[clang] Skip over std namespace in WebKit checkers. (PR #90552)

2024-04-30 Thread Artem Dergachev via cfe-commits
haoNoQ wrote: Ok am I reading this right: this is about testing code that lives directly in namespace `std::` but somehow still lives in your project right? Such as your custom modifications to standard classes, various overloads and specializations of standard things. This patch does not aff

[clang] Skip over std namespace in WebKit checkers. (PR #90552)

2024-04-30 Thread Artem Dergachev via cfe-commits
haoNoQ wrote: (If yes, LGTM!) https://github.com/llvm/llvm-project/pull/90552 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Skip over std namespace in WebKit checkers. (PR #90552)

2024-05-01 Thread Artem Dergachev via cfe-commits
haoNoQ wrote: Hmm it doesn't look like we actually have that other suppression. It looks like the checker simply never warned in the standard library because there aren't WebKit classes in the standard library. But it looks like you've found a few cases where it actually happens? How does this

[clang] [alpha.webkit.UncountedCallArgsChecker] Ignore methods of WTF String classes. (PR #90704)

2024-05-01 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ approved this pull request. LGTM! The revert was caused entirely by something in the mock headers in tests right? https://github.com/llvm/llvm-project/pull/90704 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https:/

[clang] [alpha.webkit.UncountedLocalVarsChecker] Don't warning on inlined functions (PR #90733)

2024-05-01 Thread Artem Dergachev via cfe-commits
haoNoQ wrote: @mikhailramalho long time no see! I think @rniwa is right on this one. "Inline" is completely orthogonal to "safe". Fundamentally it only matters what the function _actually does_; it doesn't matter how it's defined or where or how the code is generated for it. These checkers do

[clang] [analyzer] MallocChecker: Recognize std::atomics in smart pointer suppression. (PR #90918)

2024-05-02 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ created https://github.com/llvm/llvm-project/pull/90918 Fixes #90498. Same as 5337efc69cdd5 for atomic builtins, but for `std::atomic` this time. This is useful because even though the actual builtin atomic is still there, it may be buried beyond the inlining depth l

[clang] [webkit.RefCntblBaseVirtualDtor] Ignore WTF::RefCounted and its variants missing virtual destructor (PR #91009)

2024-05-06 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ approved this pull request. LGTM! https://github.com/llvm/llvm-project/pull/91009 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [alpha.webkit.UncountedCallArgsChecker] Treat (foo())->bar() like foo()->bar(). (PR #91052)

2024-05-06 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ approved this pull request. LGTM! Yeah I really don't know why `ParenExpr` needed to be a thing in the AST. https://github.com/llvm/llvm-project/pull/91052 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.

[clang] [alpha.webkit.UncountedCallArgsChecker] Allow trivial operator++ (PR #91102)

2024-05-06 Thread Artem Dergachev via cfe-commits
@@ -316,10 +316,15 @@ class TrivialFunctionAnalysisVisitor if (UO->isIncrementOp() || UO->isDecrementOp()) { // Allow increment or decrement of a POD type. - if (auto *RefExpr = dyn_cast(UO->getSubExpr())) { + auto *SubExpr = UO->getSubExpr(); + if (au

[clang] [analyzer] Ignore system headers in WebKit checkers. (PR #91103)

2024-05-06 Thread Artem Dergachev via cfe-commits
haoNoQ wrote: Aha, this looks like a more traditional solution! Looks great. You can make tests for this by feeding the compiler fake system headers with the help of ``` #pragma clang system_header ``` ! https://github.com/llvm/llvm-project/pull/91103 ___

[clang] [analyzer] Support determining origins in a conditional operator in WebKit checkers. (PR #91143)

2024-05-06 Thread Artem Dergachev via cfe-commits
@@ -27,12 +28,18 @@ tryToFindPtrOrigin(const Expr *E, bool StopAtFirstRefCountedObj) { E = tempExpr->getSubExpr(); continue; } +if (auto *Expr = dyn_cast(E)) { + return tryToFindPtrOrigin(Expr->getTrueExpr(), StopAtFirstRefCountedObj, +

[clang] Use cmake to find perl executable (PR #91275)

2024-05-06 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ approved this pull request. Looks great thanks a lot!! I can confirm that it works for me on a mac too. @jroelofs's comment is on point. https://github.com/llvm/llvm-project/pull/91275 ___ cfe-commits mailing list cfe-commit

[clang] Use cmake to find perl executable (PR #91275)

2024-05-06 Thread Artem Dergachev via cfe-commits
@@ -1,4 +1,4 @@ -REQUIRES: shell +REQUIRES: perl haoNoQ wrote: A few of those require `rm` and `ls` but these don't count as shell right? https://github.com/llvm/llvm-project/pull/91275 ___ cfe-commits mailing list cfe

[clang] Use cmake to find perl executable (PR #91275)

2024-05-06 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ edited https://github.com/llvm/llvm-project/pull/91275 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Use cmake to find perl executable (PR #91275)

2024-05-06 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ approved this pull request. https://github.com/llvm/llvm-project/pull/91275 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [analyzer] MallocChecker: Recognize std::atomics in smart pointer suppression. (PR #90918)

2024-05-06 Thread Artem Dergachev via cfe-commits
@@ -3479,13 +3479,24 @@ PathDiagnosticPieceRef MallocBugVisitor::VisitNode(const ExplodedNode *N, // original reference count is positive, we should not report use-after-frees // on objects deleted in such destructors. This can probably be improved // through better shar

[clang] [analyzer] MallocChecker: Recognize std::atomics in smart pointer suppression. (PR #90918)

2024-05-06 Thread Artem Dergachev via cfe-commits
@@ -3479,13 +3479,24 @@ PathDiagnosticPieceRef MallocBugVisitor::VisitNode(const ExplodedNode *N, // original reference count is positive, we should not report use-after-frees // on objects deleted in such destructors. This can probably be improved // through better shar

[clang] [analyzer] MallocChecker: Recognize std::atomics in smart pointer suppression. (PR #90918)

2024-05-06 Thread Artem Dergachev via cfe-commits
haoNoQ wrote: > I've just left here what my thought process was when I dig into a similar > case. It might be useful, who knows. Medium-to-long-term I think an attribute-based approach might make sense there: - Either annotate reference-counting pointers as "hey I'm a smart pointer (I'm follow

[clang] [analyzer] Use explicit call description mode in MIGChecker (PR #91331)

2024-05-07 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ edited https://github.com/llvm/llvm-project/pull/91331 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [analyzer] Use explicit call description mode in MIGChecker (PR #91331)

2024-05-07 Thread Artem Dergachev via cfe-commits
@@ -87,7 +90,7 @@ class MIGChecker : public Checker, #undef CALL }; - CallDescription OsRefRetain{{"os_ref_retain"}, 1}; + CallDescription OsRefRetain{CDM::SimpleFunc, {"os_ref_retain"}, 1}; haoNoQ wrote: Yes, this is a plain C function. Definitely not bu

[clang] [analyzer] Use explicit call description mode in MIGChecker (PR #91331)

2024-05-07 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ approved this pull request. Looks awesome thank you! https://github.com/llvm/llvm-project/pull/91331 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Fix a typo in webkit.NoUncountedMemberChecker. (PR #91402)

2024-05-07 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ approved this pull request. Nice LGTM! You could test this patch by pasting the warning into one of the `expected-warning{{}}` clauses in the tests but I honestly don't think it's all that important for a patch like this. https://github.com/llvm/llvm-project/pull/914

[clang] [analyzer] Ignore system headers in WebKit checkers. (PR #91103)

2024-05-07 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ approved this pull request. Perfect thanks!! https://github.com/llvm/llvm-project/pull/91103 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [alpha.webkit.UncountedCallArgsChecker] Allow trivial operator++ (PR #91102)

2024-05-08 Thread Artem Dergachev via cfe-commits
@@ -309,21 +309,8 @@ class TrivialFunctionAnalysisVisitor bool VisitDefaultStmt(const DefaultStmt *DS) { return VisitChildren(DS); } bool VisitUnaryOperator(const UnaryOperator *UO) { -// Operator '*' and '!' are allowed as long as the operand is trivial. -auto op

[clang] [alpha.webkit.UncountedCallArgsChecker] Allow trivial operator++ (PR #91102)

2024-05-08 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ edited https://github.com/llvm/llvm-project/pull/91102 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [alpha.webkit.UncountedCallArgsChecker] Allow trivial operator++ (PR #91102)

2024-05-08 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ approved this pull request. LGTM now thanks! https://github.com/llvm/llvm-project/pull/91102 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [alpha.webkit.UncountedCallArgsChecker] Allow trivial operator++ (PR #91102)

2024-05-08 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ edited https://github.com/llvm/llvm-project/pull/91102 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [analyzer] Support determining origins in a conditional operator in WebKit checkers. (PR #91143)

2024-05-08 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ edited https://github.com/llvm/llvm-project/pull/91143 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [analyzer] Support determining origins in a conditional operator in WebKit checkers. (PR #91143)

2024-05-08 Thread Artem Dergachev via cfe-commits
@@ -27,12 +28,18 @@ tryToFindPtrOrigin(const Expr *E, bool StopAtFirstRefCountedObj) { E = tempExpr->getSubExpr(); continue; } +if (auto *Expr = dyn_cast(E)) { + return tryToFindPtrOrigin(Expr->getTrueExpr(), StopAtFirstRefCountedObj, +

[clang] [analyzer] Support determining origins in a conditional operator in WebKit checkers. (PR #91143)

2024-05-08 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ approved this pull request. Aha ok this aligns with my understanding. LGTM! https://github.com/llvm/llvm-project/pull/91143 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinf

[clang] [analyzer] MallocChecker: Recognize std::atomics in smart pointer suppression. (PR #90918)

2024-05-08 Thread Artem Dergachev via cfe-commits
haoNoQ wrote: @sharkautarch Yeah I think the situation where we observe the allocation site during analysis may be significantly different in presence of smart pointers. It may be a good idea to include such check in the heuristic, to reclaim some of the false negatives currently silenced by i

[clang] [analyzer] MallocChecker: Recognize std::atomics in smart pointer suppression. (PR #90918)

2024-05-08 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ closed https://github.com/llvm/llvm-project/pull/90918 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [analyzer] Treat bitwise_cast, std::addressof, and new as trivial in WebKit checkers. (PR #91830)

2024-05-10 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ approved this pull request. LGTM thanks! https://github.com/llvm/llvm-project/pull/91830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [analyzer] Treat bitwise_cast, std::addressof, and new as trivial in WebKit checkers. (PR #91830)

2024-05-10 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ approved this pull request. https://github.com/llvm/llvm-project/pull/91830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Respect the [[clang::unsafe_buffer_usage]] attribute for constructors (PR #91777)

2024-05-13 Thread Artem Dergachev via cfe-commits
haoNoQ wrote: Hi! Thank you for digging into this! Sorry for the delay. > The new UnsafeBufferUsageCtorAttrGadget gadget explicitly avoids matching > against the std::span(ptr, size) constructor because that is handled by > SpanTwoParamConstructorGadget and we never want two gadgets to match t

[clang] [analyzer] Treat break, continue, goto, and label statements as trivial in WebKit checkers. (PR #91873)

2024-05-13 Thread Artem Dergachev via cfe-commits
@@ -445,6 +456,10 @@ class TrivialFunctionAnalysisVisitor return Visit(VMT->getSubExpr()); } + bool VisitCXXBindTemporaryExpr(const CXXBindTemporaryExpr* BTE) { +return Visit(BTE->getSubExpr()); haoNoQ wrote: At this point you probably want to doub

[clang] [alpha.webkit.UncountedCallArgsChecker] Allow explicit instantiation of Ref/RefPtr on call arguments. (PR #91875)

2024-05-13 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ approved this pull request. LGTM! https://github.com/llvm/llvm-project/pull/91875 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Respect the [[clang::unsafe_buffer_usage]] attribute for constructors (PR #91777)

2024-05-14 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ commented: > https://github.com/llvm/llvm-project/blob/2ff43ce87e66d9324370e35ea6743ef57400c76e/clang/lib/Analysis/UnsafeBufferUsage.cpp#L1373-L1374 > > These assert that exactly one gadget matched. I think it's kinda worthwhile > keeping the warnings independent too,

[clang] Respect the [[clang::unsafe_buffer_usage]] attribute for constructors (PR #91777)

2024-05-14 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ edited https://github.com/llvm/llvm-project/pull/91777 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Respect the [[clang::unsafe_buffer_usage]] attribute for constructors (PR #91777)

2024-05-14 Thread Artem Dergachev via cfe-commits
@@ -2856,7 +2916,7 @@ getFixIts(FixableGadgetSets &FixablesForAllVars, const FixitStrategy &S, } #ifndef NDEBUG Handler.addDebugNoteForVar( - VD, F->getBaseStmt()->getBeginLoc(), + VD, F->getSourceLoc(), haoNoQ wrote: This is the

[clang] Respect the [[clang::unsafe_buffer_usage]] attribute for constructors (PR #91777)

2024-05-14 Thread Artem Dergachev via cfe-commits
@@ -921,10 +937,55 @@ class UnsafeBufferUsageAttrGadget : public WarningGadget { } static Matcher matcher() { -return stmt(callExpr(callee(functionDecl(hasAttr(attr::UnsafeBufferUsage -.bind(OpTag)); +auto HasUnsafeFnDecl = +callee(

[clang] Respect the [[clang::unsafe_buffer_usage]] attribute for constructors (PR #91777)

2024-05-14 Thread Artem Dergachev via cfe-commits
@@ -2295,6 +2292,23 @@ class UnsafeBufferUsageReporter : public UnsafeBufferUsageHandler { } } + void handleUnsafeOperationInContainer(const Stmt *Operation, +bool IsRelatedToDecl, +ASTCont

[clang] Respect the [[clang::unsafe_buffer_usage]] attribute for constructors (PR #91777)

2024-05-14 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ approved this pull request. Aha ok everything makes sense now! I think this is good to go so LGTM! Let me see the other PR too. https://github.com/llvm/llvm-project/pull/91777 ___ cfe-commits mailing list cfe-commits@lists.ll

[clang] Respect the [[clang::unsafe_buffer_usage]] attribute for constructors (PR #91777)

2024-05-14 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ edited https://github.com/llvm/llvm-project/pull/91777 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Respect the [[clang::unsafe_buffer_usage]] attribute for constructors (PR #91777)

2024-05-14 Thread Artem Dergachev via cfe-commits
@@ -1315,9 +1374,9 @@ class DerefSimplePtrArithFixableGadget : public FixableGadget { virtual std::optional getFixits(const FixitStrategy &s) const final; - - // TODO remove this method from FixableGadget interface haoNoQ wrote: Still relevant tbh. htt

[clang] Respect the [[clang::unsafe_buffer_usage]] attribute for constructors (PR #91777)

2024-05-14 Thread Artem Dergachev via cfe-commits
@@ -2856,7 +2916,7 @@ getFixIts(FixableGadgetSets &FixablesForAllVars, const FixitStrategy &S, } #ifndef NDEBUG Handler.addDebugNoteForVar( - VD, F->getBaseStmt()->getBeginLoc(), + VD, F->getSourceLoc(), haoNoQ wrote: Hmm right,

[clang] Respect the [[clang::unsafe_buffer_usage]] attribute for field and constructor initializers (PR #91991)

2024-05-14 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ edited https://github.com/llvm/llvm-project/pull/91991 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Respect the [[clang::unsafe_buffer_usage]] attribute for field and constructor initializers (PR #91991)

2024-05-14 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ commented: Aha makes sense! Thanks for catching these false negatives!! https://github.com/llvm/llvm-project/pull/91991 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cf

[clang] Respect the [[clang::unsafe_buffer_usage]] attribute for field and constructor initializers (PR #91991)

2024-05-14 Thread Artem Dergachev via cfe-commits
@@ -3328,3 +3300,63 @@ void clang::checkUnsafeBufferUsage(const Decl *D, } } } + +void clang::checkUnsafeBufferUsage(const Decl *D, + UnsafeBufferUsageHandler &Handler, + bool EmitSuggestions) { +#ifndef

[clang] Respect the [[clang::unsafe_buffer_usage]] attribute for field and constructor initializers (PR #91991)

2024-05-14 Thread Artem Dergachev via cfe-commits
@@ -3328,3 +3300,63 @@ void clang::checkUnsafeBufferUsage(const Decl *D, } } } + +void clang::checkUnsafeBufferUsage(const Decl *D, + UnsafeBufferUsageHandler &Handler, + bool EmitSuggestions) { +#ifndef

[clang] [WIP][Safe Buffers] Serialize unsafe_buffer_usage pragmas (PR #92031)

2024-05-14 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ edited https://github.com/llvm/llvm-project/pull/92031 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [WIP][Safe Buffers] Serialize unsafe_buffer_usage pragmas (PR #92031)

2024-05-14 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ commented: I'm very happy that this is going somewhere! Everything makes sense to me but I also don't know a lot about this stuff. > During serialization, it only serializes regions of the current translation > unit. Regions from loaded files are not serialized. Hmm

[clang] [WIP][Safe Buffers] Serialize unsafe_buffer_usage pragmas (PR #92031)

2024-05-14 Thread Artem Dergachev via cfe-commits
@@ -1551,6 +1567,58 @@ bool Preprocessor::isPPInSafeBufferOptOutRegion(SourceLocation &StartLoc) { return InSafeBufferOptOutRegion; } +SmallVector +Preprocessor::serializeSafeBufferOptOutMap() const { + assert(!InSafeBufferOptOutRegion && haoNoQ wrote: We

[clang] [WIP][Safe Buffers] Serialize unsafe_buffer_usage pragmas (PR #92031)

2024-05-14 Thread Artem Dergachev via cfe-commits
@@ -1551,6 +1567,58 @@ bool Preprocessor::isPPInSafeBufferOptOutRegion(SourceLocation &StartLoc) { return InSafeBufferOptOutRegion; } +SmallVector +Preprocessor::serializeSafeBufferOptOutMap() const { + assert(!InSafeBufferOptOutRegion && + "Attempt to serialize sa

[clang] Respect the [[clang::unsafe_buffer_usage]] attribute for field and constructor initializers (PR #91991)

2024-05-14 Thread Artem Dergachev via cfe-commits
@@ -3328,3 +3300,63 @@ void clang::checkUnsafeBufferUsage(const Decl *D, } } } + +void clang::checkUnsafeBufferUsage(const Decl *D, + UnsafeBufferUsageHandler &Handler, + bool EmitSuggestions) { +#ifndef

<    6   7   8   9   10   11   12   13   >