[clang] [webkit.RefCntblBaseVirtualDtor] Allow CRTP classes without a virtual destructor. (PR #92837)

2024-05-23 Thread Artem Dergachev via cfe-commits
@@ -11,16 +11,134 @@ #include "PtrTypesSemantics.h" #include "clang/AST/CXXInheritance.h" #include "clang/AST/RecursiveASTVisitor.h" +#include "clang/AST/StmtVisitor.h" #include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h" #include

[clang] [webkit.RefCntblBaseVirtualDtor] Allow CRTP classes without a virtual destructor. (PR #92837)

2024-05-23 Thread Artem Dergachev via cfe-commits
@@ -11,16 +11,134 @@ #include "PtrTypesSemantics.h" #include "clang/AST/CXXInheritance.h" #include "clang/AST/RecursiveASTVisitor.h" +#include "clang/AST/StmtVisitor.h" #include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h" #include

[clang] [webkit.RefCntblBaseVirtualDtor] Allow CRTP classes without a virtual destructor. (PR #92837)

2024-05-23 Thread Artem Dergachev via cfe-commits
@@ -11,16 +11,134 @@ #include "PtrTypesSemantics.h" #include "clang/AST/CXXInheritance.h" #include "clang/AST/RecursiveASTVisitor.h" +#include "clang/AST/StmtVisitor.h" #include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h" #include

[clang] [webkit.RefCntblBaseVirtualDtor] Allow CRTP classes without a virtual destructor. (PR #92837)

2024-05-23 Thread Artem Dergachev via cfe-commits
@@ -11,16 +11,134 @@ #include "PtrTypesSemantics.h" #include "clang/AST/CXXInheritance.h" #include "clang/AST/RecursiveASTVisitor.h" +#include "clang/AST/StmtVisitor.h" #include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h" #include

[clang] [analyzer] Allow recursive functions to be trivial. (PR #91876)

2024-05-23 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ commented: > If that is an issue, one way to do this "properly" would be to create a graph Note that we do have a [`CallGraph`](https://clang.llvm.org/doxygen/classclang_1_1CallGraph.html) class. The static analyzer uses it to identify top-level entry points. It

[clang] [analyzer] Allow recursive functions to be trivial. (PR #91876)

2024-05-23 Thread Artem Dergachev via cfe-commits
@@ -231,6 +231,15 @@ class RefCounted { void method(); void someFunction(); int otherFunction(); + unsigned recursiveTrivialFunction(int n) { return !n ? 1 : recursiveTrivialFunction(n - 1); } + unsigned recursiveComplexFunction(int n) { return !n ? otherFunction() :

[clang] [analyzer] Allow recursive functions to be trivial. (PR #91876)

2024-05-23 Thread Artem Dergachev via cfe-commits
@@ -231,6 +231,15 @@ class RefCounted { void method(); void someFunction(); int otherFunction(); + unsigned recursiveTrivialFunction(int n) { return !n ? 1 : recursiveTrivialFunction(n - 1); } + unsigned recursiveComplexFunction(int n) { return !n ? otherFunction() :

[clang] [analyzer] Allow recursive functions to be trivial. (PR #91876)

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

[clang] [alpha.webkit.UncountedLocalVarsChecker] Detect assignments to uncounted local variable and parameters. (PR #92639)

2024-05-23 Thread Artem Dergachev via cfe-commits
haoNoQ wrote: (It might be a good idea to add comments to those parts of the code to make sure the reader knows that it was intentional.) https://github.com/llvm/llvm-project/pull/92639 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[clang] [alpha.webkit.UncountedLocalVarsChecker] Detect assignments to uncounted local variable and parameters. (PR #92639)

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

[clang] [webkit.RefCntblBaseVirtualDtor] Allow CRTP classes without a virtual destructor. (PR #92837)

2024-05-23 Thread Artem Dergachev via cfe-commits
@@ -11,16 +11,134 @@ #include "PtrTypesSemantics.h" #include "clang/AST/CXXInheritance.h" #include "clang/AST/RecursiveASTVisitor.h" +#include "clang/AST/StmtVisitor.h" #include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h" #include

[clang] [webkit.RefCntblBaseVirtualDtor] Allow CRTP classes without a virtual destructor. (PR #92837)

2024-05-23 Thread Artem Dergachev via cfe-commits
@@ -51,92 +169,137 @@ class RefCntblBaseVirtualDtorChecker bool shouldVisitImplicitCode() const { return false; } bool VisitCXXRecordDecl(const CXXRecordDecl *RD) { -Checker->visitCXXRecordDecl(RD); +if (!RD->hasDefinition()) + return

[clang] [webkit.RefCntblBaseVirtualDtor] Allow CRTP classes without a virtual destructor. (PR #92837)

2024-05-23 Thread Artem Dergachev via cfe-commits
@@ -11,16 +11,134 @@ #include "PtrTypesSemantics.h" #include "clang/AST/CXXInheritance.h" #include "clang/AST/RecursiveASTVisitor.h" +#include "clang/AST/StmtVisitor.h" #include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h" #include

[clang] [webkit.RefCntblBaseVirtualDtor] Allow CRTP classes without a virtual destructor. (PR #92837)

2024-05-23 Thread Artem Dergachev via cfe-commits
@@ -11,16 +11,134 @@ #include "PtrTypesSemantics.h" #include "clang/AST/CXXInheritance.h" #include "clang/AST/RecursiveASTVisitor.h" +#include "clang/AST/StmtVisitor.h" #include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h" #include

[clang] [webkit.RefCntblBaseVirtualDtor] Allow CRTP classes without a virtual destructor. (PR #92837)

2024-05-23 Thread Artem Dergachev via cfe-commits
@@ -11,16 +11,134 @@ #include "PtrTypesSemantics.h" #include "clang/AST/CXXInheritance.h" #include "clang/AST/RecursiveASTVisitor.h" +#include "clang/AST/StmtVisitor.h" #include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h" #include

[clang] [webkit.RefCntblBaseVirtualDtor] Allow CRTP classes without a virtual destructor. (PR #92837)

2024-05-23 Thread Artem Dergachev via cfe-commits
@@ -11,16 +11,134 @@ #include "PtrTypesSemantics.h" #include "clang/AST/CXXInheritance.h" #include "clang/AST/RecursiveASTVisitor.h" +#include "clang/AST/StmtVisitor.h" #include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h" #include

[clang] [webkit.RefCntblBaseVirtualDtor] Allow CRTP classes without a virtual destructor. (PR #92837)

2024-05-23 Thread Artem Dergachev via cfe-commits
@@ -11,16 +11,134 @@ #include "PtrTypesSemantics.h" #include "clang/AST/CXXInheritance.h" #include "clang/AST/RecursiveASTVisitor.h" +#include "clang/AST/StmtVisitor.h" #include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h" #include

[clang] [alpha.webkit.UncountedLocalVarsChecker] Detect assignments to uncounted local variable and parameters. (PR #92639)

2024-05-23 Thread Artem Dergachev via cfe-commits
@@ -135,7 +135,19 @@ class UncountedLocalVarsChecker bool shouldVisitImplicitCode() const { return false; } bool VisitVarDecl(VarDecl *V) { -Checker->visitVarDecl(V); +auto *Init = V->getInit(); +if (Init && V->isLocalVarDecl())

[clang] [alpha.webkit.UncountedLocalVarsChecker] Detect assignments to uncounted local variable and parameters. (PR #92639)

2024-05-23 Thread Artem Dergachev via cfe-commits
@@ -135,7 +135,19 @@ class UncountedLocalVarsChecker bool shouldVisitImplicitCode() const { return false; } bool VisitVarDecl(VarDecl *V) { -Checker->visitVarDecl(V); +auto *Init = V->getInit(); +if (Init && V->isLocalVarDecl()) +

[clang] [-Wunsafe-buffer-usage] Fix false positives for constant cases (PR #92432)

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

[clang] [-Wunsafe-buffer-usage] Fix false positives for constant cases (PR #92432)

2024-05-20 Thread Artem Dergachev via cfe-commits
@@ -420,25 +420,63 @@ AST_MATCHER(ArraySubscriptExpr, isSafeArraySubscript) { //already duplicated // - call both from Sema and from here - const auto *BaseDRE = - dyn_cast(Node.getBase()->IgnoreParenImpCasts()); - if (!BaseDRE) + if (const auto *BaseDRE = +

[clang] [-Wunsafe-buffer-usage] Fix false positives for constant cases (PR #92432)

2024-05-20 Thread Artem Dergachev via cfe-commits
@@ -0,0 +1,17 @@ +// RUN: %clang_cc1 -std=c++20 -Wno-everything -Wunsafe-buffer-usage \ +// RUN:-fsafe-buffer-usage-suggestions \ +// RUN:-verify %s + +void char_literal() { + if ("abc"[2] == 'c') +return; + if ("def"[3] == '0') +return; +} +

[clang] [-Wunsafe-buffer-usage] Fix false positives for constant cases (PR #92432)

2024-05-20 Thread Artem Dergachev via cfe-commits
@@ -420,25 +420,63 @@ AST_MATCHER(ArraySubscriptExpr, isSafeArraySubscript) { //already duplicated // - call both from Sema and from here - const auto *BaseDRE = - dyn_cast(Node.getBase()->IgnoreParenImpCasts()); - if (!BaseDRE) + if (const auto *BaseDRE = +

[clang] [-Wunsafe-buffer-usage] Fix false positives for constant cases (PR #92432)

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

[clang] [-Wunsafe-buffer-usage] Fix false positives for constant cases (PR #92432)

2024-05-20 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ commented: Overall looks great! I think I see a couple easy improvements, this isn't blocking but let's take a moment to consider them  https://github.com/llvm/llvm-project/pull/92432 ___ cfe-commits mailing list

[clang] [-Wunsafe-buffer-usage] Fix false positives for constant cases (PR #92432)

2024-05-20 Thread Artem Dergachev via cfe-commits
@@ -420,25 +420,63 @@ AST_MATCHER(ArraySubscriptExpr, isSafeArraySubscript) { //already duplicated // - call both from Sema and from here - const auto *BaseDRE = - dyn_cast(Node.getBase()->IgnoreParenImpCasts()); - if (!BaseDRE) + if (const auto *BaseDRE = +

[clang] [analyzer] Adding taint analysis capability to unix.Malloc checker (PR #92420)

2024-05-16 Thread Artem Dergachev via cfe-commits
haoNoQ wrote: I think there should be a way to enable/disable this check separately because memory exhaustion / denial of service isn't necessarily something you care about when you enable taint analysis. It's essential for web servers when the attacker is interested in interrupting their

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

2024-05-15 Thread Artem Dergachev via cfe-commits
haoNoQ wrote: > serializing the pragmas themselves as AST nodes These pragmas don't really translate very well into the AST. Similarly to `#pragma clang diagnostic`, they can be placed weirdly "across" other AST nodes, like: ``` #pragma clang unsafe_buffer_usage begin void foo() { #pragma

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

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

[clang] [analyzer] Check C++ base or member initializer in WebKit checkers. (PR #92220)

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

[clang] [analyzer] Check C++ base or member initializer in WebKit checkers. (PR #92220)

2024-05-15 Thread Artem Dergachev via cfe-commits
@@ -525,11 +525,19 @@ bool TrivialFunctionAnalysis::isTrivialImpl( if (!IsNew) return It->second; + TrivialFunctionAnalysisVisitor V(Cache); + + if (auto *CtorDecl = dyn_cast(D)) { +for (auto *CtorInit : CtorDecl->inits()) { + if

[clang] [analyzer] Check C++ base or member initializer in WebKit checkers. (PR #92220)

2024-05-15 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ edited https://github.com/llvm/llvm-project/pull/92220 ___ 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-15 Thread Artem Dergachev via cfe-commits
@@ -1315,9 +1374,9 @@ class DerefSimplePtrArithFixableGadget : public FixableGadget { virtual std::optional getFixits(const FixitStrategy ) const final; - - // TODO remove this method from FixableGadget interface haoNoQ wrote: Right!

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

2024-05-14 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: Which reminds me, I think we're also

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

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

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

2024-05-14 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ approved this pull request. Aha great LGTM! https://github.com/llvm/llvm-project/pull/91873 ___ 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
@@ -3328,3 +3300,63 @@ void clang::checkUnsafeBufferUsage(const Decl *D, } } } + +void clang::checkUnsafeBufferUsage(const Decl *D, + UnsafeBufferUsageHandler , + bool EmitSuggestions) { +#ifndef NDEBUG

[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 ) { return InSafeBufferOptOutRegion; } +SmallVector +Preprocessor::serializeSafeBufferOptOutMap() const { + assert(!InSafeBufferOptOutRegion && + "Attempt to serialize safe

[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 ) { return InSafeBufferOptOutRegion; } +SmallVector +Preprocessor::serializeSafeBufferOptOutMap() const { + assert(!InSafeBufferOptOutRegion && haoNoQ wrote: We require

[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
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] 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 , + bool EmitSuggestions) { +#ifndef NDEBUG

[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 , + bool EmitSuggestions) { +#ifndef NDEBUG

[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

[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 constructors (PR #91777)

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

[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 ) const final; - - // TODO remove this method from FixableGadget interface haoNoQ wrote: Still relevant tbh.

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

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

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

[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 , const FixitStrategy , } #ifndef NDEBUG Handler.addDebugNoteForVar( - VD, F->getBaseStmt()->getBeginLoc(), + VD, F->getSourceLoc(), haoNoQ wrote: This is the only place where we

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

[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

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

[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

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

[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

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

[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

[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

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

[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

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

[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

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

[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

[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

[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

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

[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

[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

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

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

[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

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

  1   2   3   4   5   6   7   8   9   10   >