[clang] [C] Add (new) -Wimplicit-void-ptr-cast to -Wc++-compat (PR #136855)

2025-08-18 Thread Ziqing Luo via cfe-commits
ziqingluo-90 wrote: > I think it's worth filing an issue over. I will file an issue. I did bisect and verified that this commit is causing the issue. It is also a mystery to me how this commit could affect AST shapes. https://github.com/llvm/llvm-project/pull/136855 __

[clang] [C] Add (new) -Wimplicit-void-ptr-cast to -Wc++-compat (PR #136855)

2025-08-16 Thread Ziqing Luo via cfe-commits
ziqingluo-90 wrote: Hi @AaronBallman I noticed that this commit makes a difference on the example below. ``` #include typedef const struct T * T_Ref; static T_Ref _Atomic x = ATOMIC_VAR_INIT((void*)NULL); ``` After this commit, the AST of the global variable declaration changes---a level of `

[clang] [-Wunsafe-buffer-usage] Do not warn about class methods with libc function names (PR #151270)

2025-08-01 Thread Ziqing Luo via cfe-commits
https://github.com/ziqingluo-90 updated https://github.com/llvm/llvm-project/pull/151270 >From 50ea6041f13cdc4c9d4ae475d11b970f1e026fac Mon Sep 17 00:00:00 2001 From: Ziqing Luo Date: Wed, 30 Jul 2025 11:23:32 +0800 Subject: [PATCH 1/2] [-Wunsafe-buffer-usage] Do not warn about class methods w

[clang] [-Wunsafe-buffer-usage] Do not warn about class methods with libc function names (PR #151270)

2025-08-01 Thread Ziqing Luo via cfe-commits
https://github.com/ziqingluo-90 updated https://github.com/llvm/llvm-project/pull/151270 >From 50ea6041f13cdc4c9d4ae475d11b970f1e026fac Mon Sep 17 00:00:00 2001 From: Ziqing Luo Date: Wed, 30 Jul 2025 11:23:32 +0800 Subject: [PATCH 1/2] [-Wunsafe-buffer-usage] Do not warn about class methods w

[clang] [-Wunsafe-buffer-usage] Do not warn about class methods with libc function names (PR #151270)

2025-08-01 Thread Ziqing Luo via cfe-commits
https://github.com/ziqingluo-90 updated https://github.com/llvm/llvm-project/pull/151270 >From 50ea6041f13cdc4c9d4ae475d11b970f1e026fac Mon Sep 17 00:00:00 2001 From: Ziqing Luo Date: Wed, 30 Jul 2025 11:23:32 +0800 Subject: [PATCH 1/2] [-Wunsafe-buffer-usage] Do not warn about class methods w

[clang-tools-extra] [clang-tidy] add new check: modernize-use-scoped-lock (PR #126434)

2025-07-18 Thread Ziqing Luo via cfe-commits
@@ -0,0 +1,471 @@ +// RUN: %check_clang_tidy -std=c++17-or-later %s modernize-use-scoped-lock %t -- -- -isystem %clang_tidy_headers -fno-delayed-template-parsing + +#include + +void Positive() { + std::mutex m; + { +std::lock_guard l(m); +// CHECK-MESSAGES: :[[@LINE-1]

[clang-tools-extra] [clang-tidy] add new check: modernize-use-scoped-lock (PR #126434)

2025-07-18 Thread Ziqing Luo via cfe-commits
@@ -0,0 +1,471 @@ +// RUN: %check_clang_tidy -std=c++17-or-later %s modernize-use-scoped-lock %t -- -- -isystem %clang_tidy_headers -fno-delayed-template-parsing + +#include + +void Positive() { + std::mutex m; + { +std::lock_guard l(m); +// CHECK-MESSAGES: :[[@LINE-1]

[clang] [-Wunsafe-buffer-usage] Support safe patterns of "%.*s" in printf functions (PR #145862)

2025-07-17 Thread Ziqing Luo via cfe-commits
https://github.com/ziqingluo-90 updated https://github.com/llvm/llvm-project/pull/145862 >From 28cda3e7ea3f14305342d3ea663646df164ff044 Mon Sep 17 00:00:00 2001 From: Ziqing Luo Date: Tue, 24 Jun 2025 16:45:30 +0800 Subject: [PATCH 1/2] [-Wunsafe-buffer-usage] Support safe patterns of "%.*s" i

[clang] [-Wunsafe-buffer-usage] Support safe patterns of "%.*s" in printf functions (PR #145862)

2025-07-17 Thread Ziqing Luo via cfe-commits
@@ -743,28 +808,81 @@ static bool hasUnsafeFormatOrSArg(const CallExpr *Call, const Expr *&UnsafeArg, const CallExpr *Call; unsigned FmtArgIdx; const Expr *&UnsafeArg; +ASTContext &Ctx; + +// Returns an `Expr` representing the precision if specified, null +

[clang] [-Wunsafe-buffer-usage] Support safe patterns of "%.*s" in printf functions (PR #145862)

2025-07-17 Thread Ziqing Luo via cfe-commits
https://github.com/ziqingluo-90 updated https://github.com/llvm/llvm-project/pull/145862 >From 5c6a2f267f51dd321069ada7eb90f7bc5c794bdd Mon Sep 17 00:00:00 2001 From: Ziqing Luo Date: Tue, 24 Jun 2025 11:25:52 +0800 Subject: [PATCH 1/3] [NFC][-Wunsafe-buffer-usage] Refactor safe pattern check

[clang] [NFC][-Wunsafe-buffer-usage] Refactor safe pattern check for pointer-size pairs (PR #145626)

2025-07-15 Thread Ziqing Luo via cfe-commits
ziqingluo-90 wrote: > https://lab.llvm.org/buildbot/#/builders/190/builds/23511 The failed test is `ExecutionEngine/OrcLazy/multiple-compile-threads-basic.ll`, which can't be affected by this change. https://github.com/llvm/llvm-project/pull/145626 _

[clang] [NFC][-Wunsafe-buffer-usage] Refactor safe pattern check for pointer-size pairs (PR #145626)

2025-07-15 Thread Ziqing Luo via cfe-commits
https://github.com/ziqingluo-90 closed https://github.com/llvm/llvm-project/pull/145626 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [NFC][-Wunsafe-buffer-usage] Refactor safe pattern check for pointer-size pairs (PR #145626)

2025-07-11 Thread Ziqing Luo via cfe-commits
https://github.com/ziqingluo-90 updated https://github.com/llvm/llvm-project/pull/145626 >From 8c07b277562bd3d4f332a341eb1e0127545c8280 Mon Sep 17 00:00:00 2001 From: Ziqing Luo Date: Tue, 24 Jun 2025 11:25:52 +0800 Subject: [PATCH 1/3] [NFC][-Wunsafe-buffer-usage] Refactor safe pattern check

[clang] [NFC][-Wunsafe-buffer-usage] Refactor safe pattern check for pointer-size pairs (PR #145626)

2025-07-11 Thread Ziqing Luo via cfe-commits
@@ -453,22 +453,108 @@ static bool areEqualIntegers(const Expr *E1, const Expr *E2, ASTContext &Ctx) { } } +// Providing that `Ptr` is a pointer and `Size` is an unsigned-integral +// expression, returns true iff they follow one of the following safe +// patterns: +// 1. P

[clang] [clang-scan-deps] Fix "unterminated conditional directive" bug (PR #146645)

2025-07-03 Thread Ziqing Luo via cfe-commits
https://github.com/ziqingluo-90 closed https://github.com/llvm/llvm-project/pull/146645 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-scan-deps] Fix "unterminated conditional directive" bug (PR #146645)

2025-07-03 Thread Ziqing Luo via cfe-commits
ziqingluo-90 wrote: > The logic added in #143950 also handles line splices with 0 trailing > whitespace characters, so this code is now redundant. (When removing it, the > test run fine too.) > > Should removing this code be a separate PR? Done https://github.com/llvm/llvm-project/pull/14664

[clang] [clang-scan-deps] Fix "unterminated conditional directive" bug (PR #146645)

2025-07-03 Thread Ziqing Luo via cfe-commits
https://github.com/ziqingluo-90 updated https://github.com/llvm/llvm-project/pull/146645 >From 161d7b6def818f16a2f8ab82ae4643abd09e8982 Mon Sep 17 00:00:00 2001 From: Ziqing Luo Date: Wed, 2 Jul 2025 15:46:37 +0800 Subject: [PATCH 1/3] [clang-scan-deps] Fix "unterminated conditional directive"

[clang] [clang-scan-deps] Fix "unterminated conditional directive" bug (PR #146645)

2025-07-03 Thread Ziqing Luo via cfe-commits
@@ -393,7 +393,7 @@ static bool isQuoteCppDigitSeparator(const char *const Start, } void Scanner::skipLine(const char *&First, const char *const End) { ziqingluo-90 wrote: Yeah, this is much simpler. Thank you! This fix relies on the input source being vali

[clang] [clang-scan-deps] Fix "unterminated conditional directive" bug (PR #146645)

2025-07-03 Thread Ziqing Luo via cfe-commits
https://github.com/ziqingluo-90 updated https://github.com/llvm/llvm-project/pull/146645 >From b9c3c4e0eca567937e59b2ae21f805d8156f7204 Mon Sep 17 00:00:00 2001 From: Ziqing Luo Date: Wed, 2 Jul 2025 15:46:37 +0800 Subject: [PATCH 1/3] [clang-scan-deps] Fix "unterminated conditional directive"

[clang] [clang-scan-deps] Fix "unterminated conditional directive" bug (PR #146645)

2025-07-02 Thread Ziqing Luo via cfe-commits
https://github.com/ziqingluo-90 updated https://github.com/llvm/llvm-project/pull/146645 >From b9c3c4e0eca567937e59b2ae21f805d8156f7204 Mon Sep 17 00:00:00 2001 From: Ziqing Luo Date: Wed, 2 Jul 2025 15:46:37 +0800 Subject: [PATCH 1/2] [clang-scan-deps] Fix "unterminated conditional directive"

[clang] [clang-scan-deps] Fix "unterminated conditional directive" bug (PR #146645)

2025-07-02 Thread Ziqing Luo via cfe-commits
@@ -880,6 +880,37 @@ TEST(MinimizeSourceToDependencyDirectivesTest, EXPECT_EQ(pp_eof, Directives[22].Kind); } +TEST(MinimizeSourceToDependencyDirectivesTest, + TestFixedBugThatReportUnterminatedDirectiveFalsely) { + SmallVector Out; + SmallVector Tokens; + SmallVector

[clang] [clang-scan-deps] Fix "unterminated conditional directive" bug (PR #146645)

2025-07-02 Thread Ziqing Luo via cfe-commits
https://github.com/ziqingluo-90 edited https://github.com/llvm/llvm-project/pull/146645 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-scan-deps] Fix "unterminated conditional directive" bug (PR #146645)

2025-07-02 Thread Ziqing Luo via cfe-commits
https://github.com/ziqingluo-90 created https://github.com/llvm/llvm-project/pull/146645 `clang-scan-deps` threw "unterminated conditional directive" error falsely on the following example: ``` #ifndef __TEST #define __TEST #if defined(__TEST_DUMMY) #if defined(__TEST_DUMMY2) #pragma GCC w

[clang] [-Wunterminated-string-initialization] Handle C string literals ending with explicit '\0' (PR #143487)

2025-06-27 Thread Ziqing Luo via cfe-commits
ziqingluo-90 wrote: > LLVM Buildbot has detected a new failure on builder > `llvm-x86_64-debian-dylib` running on `gribozavr4` while building `clang` at > step 7 "test-build-unified-tree-check-llvm". > > Full details are available at: > https://lab.llvm.org/buildbot/#/builders/60/builds/31310

[clang] [-Wunsafe-buffer-usage] Support safe patterns of "%.*s" in printf functions (PR #145862)

2025-06-26 Thread Ziqing Luo via cfe-commits
ziqingluo-90 wrote: This PR depends on https://github.com/llvm/llvm-project/pull/145626 https://github.com/llvm/llvm-project/pull/145862 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [-Wunsafe-buffer-usage] Support safe patterns of "%.*s" in printf functions (PR #145862)

2025-06-26 Thread Ziqing Luo via cfe-commits
https://github.com/ziqingluo-90 created https://github.com/llvm/llvm-project/pull/145862 The character buffer passed to a "%.*s" specifier may be safely bound if the precision is properly specified, even if the buffer does not guarantee null-termination. For example, ``` void f(std::span span)

[clang] [-Wunsafe-buffer-usage] Support span creation from std::initializer_list and begin/end pairs (PR #145311)

2025-06-25 Thread Ziqing Luo via cfe-commits
@@ -232,3 +268,27 @@ struct HoldsStdSpanAndNotInitializedInCtor { : Ptr(P), Size(S) {} }; + +namespace test_begin_end { + struct Object { +int * begin(); +int * end(); + }; + void safe_cases(std::span Sp, std::array Arr, std::string Str, std::initializer_lis

[clang] [NFC][-Wunsafe-buffer-usage] Refactor safe pattern check for pointer-size pairs (PR #145626)

2025-06-24 Thread Ziqing Luo via cfe-commits
https://github.com/ziqingluo-90 updated https://github.com/llvm/llvm-project/pull/145626 >From 8c07b277562bd3d4f332a341eb1e0127545c8280 Mon Sep 17 00:00:00 2001 From: Ziqing Luo Date: Tue, 24 Jun 2025 11:25:52 +0800 Subject: [PATCH 1/2] [NFC][-Wunsafe-buffer-usage] Refactor safe pattern check

[clang] [-Wunsafe-buffer-usage] Support span creation from std::initializer_list and begin/end pairs (PR #145311)

2025-06-24 Thread Ziqing Luo via cfe-commits
https://github.com/ziqingluo-90 updated https://github.com/llvm/llvm-project/pull/145311 >From 9826ba3dbb8223d948ac850ec81646eb6c3c76ed Mon Sep 17 00:00:00 2001 From: Ziqing Luo Date: Mon, 23 Jun 2025 18:59:04 +0800 Subject: [PATCH 1/2] [-Wunsafe-buffer-usage] Support span creation from std::i

[clang] [clang-tools-extra] [clang-tidy] Warn about misuse of sizeof operator in loops. (PR #143205)

2025-06-23 Thread Ziqing Luo via cfe-commits
@@ -130,6 +140,14 @@ void SizeofExpressionCheck::registerMatchers(MatchFinder *Finder) { this); } + if (WarnOnSizeOfInLoopTermination) { +Finder->addMatcher(LoopExpr(hasDescendant(binaryOperator( ziqingluo-90 wrote: Since `hasDe

[clang] [-Wunsafe-buffer-usage] Support span creation from std::initializer_list and begin/end pairs (PR #145311)

2025-06-23 Thread Ziqing Luo via cfe-commits
https://github.com/ziqingluo-90 created https://github.com/llvm/llvm-project/pull/145311 Support safe construction of `std::span` from `begin` and `end` calls on hardened containers or views or `std::initializer_list`s. For example, the following code is safe: ``` void create(std::initializer_

[clang] [-Wunterminated-string-initialization] Handle C string literals ending with explicit '\0' (PR #143487)

2025-06-22 Thread Ziqing Luo via cfe-commits
https://github.com/ziqingluo-90 updated https://github.com/llvm/llvm-project/pull/143487 >From 5825b324e47c78a939d8e62d1101e1574fd04638 Mon Sep 17 00:00:00 2001 From: Ziqing Luo Date: Tue, 10 Jun 2025 15:50:10 +0800 Subject: [PATCH 1/7] [-Wunterminated-string-initialization] Handle C string li

[clang] [-Wunterminated-string-initialization] Handle C string literals ending with explicit '\0' (PR #143487)

2025-06-15 Thread Ziqing Luo via cfe-commits
ziqingluo-90 wrote: @shafik, @erichkeane @AaronBallman @tbaederr @zwuis I believe all feedback has been addressed. Could you give it another look when you are free? https://github.com/llvm/llvm-project/pull/143487 ___ cfe-commits mailing list cfe-co

[clang] [-Wunterminated-string-initialization] Handle C string literals ending with explicit '\0' (PR #143487)

2025-06-13 Thread Ziqing Luo via cfe-commits
https://github.com/ziqingluo-90 updated https://github.com/llvm/llvm-project/pull/143487 >From 5825b324e47c78a939d8e62d1101e1574fd04638 Mon Sep 17 00:00:00 2001 From: Ziqing Luo Date: Tue, 10 Jun 2025 15:50:10 +0800 Subject: [PATCH 1/6] [-Wunterminated-string-initialization] Handle C string li

[clang] [-Wunterminated-string-initialization] Handle C string literals ending with explicit '\0' (PR #143487)

2025-06-12 Thread Ziqing Luo via cfe-commits
https://github.com/ziqingluo-90 updated https://github.com/llvm/llvm-project/pull/143487 >From 5825b324e47c78a939d8e62d1101e1574fd04638 Mon Sep 17 00:00:00 2001 From: Ziqing Luo Date: Tue, 10 Jun 2025 15:50:10 +0800 Subject: [PATCH 1/5] [-Wunterminated-string-initialization] Handle C string li

[clang] [analyzer] Conversion to CheckerFamily: NullabilityChecker (PR #143735)

2025-06-11 Thread Ziqing Luo via cfe-commits
ziqingluo-90 wrote: I do not have many suggestions for this change. It's great that we can get rid of the meaningless `nullability.NullabilityBase` dummy checker. Thanks. https://github.com/llvm/llvm-project/pull/143735 ___ cfe-commits mailing list

[clang] [analyzer] Conversion to CheckerFamily: NullabilityChecker (PR #143735)

2025-06-11 Thread Ziqing Luo via cfe-commits
@@ -113,25 +114,21 @@ class NullabilityChecker void printState(raw_ostream &Out, ProgramStateRef State, const char *NL, const char *Sep) const override; - enum CheckKind { -CK_NullPassedToNonnull, -CK_NullReturnedFromNonnull, -CK_NullableDerefe

[clang] [-Wunterminated-string-initialization] Handle C string literals ending with explicit '\0' (PR #143487)

2025-06-10 Thread Ziqing Luo via cfe-commits
ziqingluo-90 wrote: Thank you all for valuable feedbacks. I have improved the PR by - supporting different character encodings - adding more test cases - updating the release notes https://github.com/llvm/llvm-project/pull/143487 ___ cfe-commits maili

[clang] [-Wunterminated-string-initialization] Handle C string literals ending with explicit '\0' (PR #143487)

2025-06-10 Thread Ziqing Luo via cfe-commits
https://github.com/ziqingluo-90 updated https://github.com/llvm/llvm-project/pull/143487 >From 5825b324e47c78a939d8e62d1101e1574fd04638 Mon Sep 17 00:00:00 2001 From: Ziqing Luo Date: Tue, 10 Jun 2025 15:50:10 +0800 Subject: [PATCH 1/3] [-Wunterminated-string-initialization] Handle C string li

[clang] [-Wunterminated-string-initialization] Handle C string literals ending with explicit '\0' (PR #143487)

2025-06-10 Thread Ziqing Luo via cfe-commits
https://github.com/ziqingluo-90 updated https://github.com/llvm/llvm-project/pull/143487 >From 5825b324e47c78a939d8e62d1101e1574fd04638 Mon Sep 17 00:00:00 2001 From: Ziqing Luo Date: Tue, 10 Jun 2025 15:50:10 +0800 Subject: [PATCH 1/2] [-Wunterminated-string-initialization] Handle C string li

[clang] [clang][CFG] Fix assertion failure in checkIncorrectLogicOperator (PR #142897)

2025-06-09 Thread Ziqing Luo via cfe-commits
https://github.com/ziqingluo-90 closed https://github.com/llvm/llvm-project/pull/142897 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [alpha.webkit.NoUnretainedMemberChecker] Recognize NS_REQUIRES_PROPERTY_DEFINITIONS (PR #143408)

2025-06-09 Thread Ziqing Luo via cfe-commits
https://github.com/ziqingluo-90 approved this pull request. LGTM now! https://github.com/llvm/llvm-project/pull/143408 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [alpha.webkit.NoUnretainedMemberChecker] Recognize NS_REQUIRES_PROPERTY_DEFINITIONS (PR #141293)

2025-06-07 Thread Ziqing Luo via cfe-commits
@@ -142,6 +144,8 @@ class RawPtrRefMemberChecker if (auto *ID = dyn_cast(CD)) { for (auto *Ivar : ID->ivars()) visitIvarDecl(CD, Ivar); + for (auto *PropImpl : ID->property_impls()) +visitPropImpl(CD, PropImpl); ziqingluo-90 wrote

[clang] [WebKit checkers] Treat passing of a member variable which is capable of CheckedPtr as safe. (PR #142485)

2025-06-07 Thread Ziqing Luo via cfe-commits
https://github.com/ziqingluo-90 approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/142485 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [WebKit checkers] Add an annotation for pointer conversion. (PR #141277)

2025-06-07 Thread Ziqing Luo via cfe-commits
https://github.com/ziqingluo-90 approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/141277 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][CFG] Fix assertion failure in checkIncorrectLogicOperator (PR #142897)

2025-06-06 Thread Ziqing Luo via cfe-commits
@@ -1261,6 +1261,28 @@ class CFGBuilder { L2Result.Val.getKind() == APValue::Float) { llvm::APFloat L1 = L1Result.Val.getFloat(); llvm::APFloat L2 = L2Result.Val.getFloat(); + // Note that L1 and L2 do not necessarily have the same type. For example +

[clang] [alpha.webkit.NoUnretainedMemberChecker] Recognize NS_REQUIRES_PROPERTY_DEFINITIONS (PR #141293)

2025-06-06 Thread Ziqing Luo via cfe-commits
ziqingluo-90 wrote: Overall, I think the change aligns with what you described. I've just left a few questions to clarify my understanding. https://github.com/llvm/llvm-project/pull/141293 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https

[clang] [alpha.webkit.NoUnretainedMemberChecker] Recognize NS_REQUIRES_PROPERTY_DEFINITIONS (PR #141293)

2025-06-06 Thread Ziqing Luo via cfe-commits
@@ -99,3 +99,22 @@ @interface AnotherObject : NSObject { @property(nonatomic, strong) NSString *prop_string; // expected-warning@-1{{Property 'prop_string' in 'AnotherObject' is a raw pointer to retainable type 'NSString'; member variables must be a RetainPtr}} @end + +NS_REQU

[clang] [alpha.webkit.NoUnretainedMemberChecker] Recognize NS_REQUIRES_PROPERTY_DEFINITIONS (PR #141293)

2025-06-06 Thread Ziqing Luo via cfe-commits
@@ -64,3 +64,33 @@ void forceTmplToInstantiate(FooTmpl) {} }; } // namespace ptr_to_ptr_to_retained + +@interface AnotherObject : NSObject { + NSString *ns_string; + CFStringRef cf_string; + // expected-warning@-1{{Instance variable 'cf_string' in 'AnotherObject' is a re

[clang] [alpha.webkit.NoUnretainedMemberChecker] Recognize NS_REQUIRES_PROPERTY_DEFINITIONS (PR #141293)

2025-06-05 Thread Ziqing Luo via cfe-commits
@@ -174,7 +175,15 @@ class RawPtrRefMemberChecker if (!PropType) return; -auto IsUnsafePtr = isUnsafePtr(QT); +if (const ObjCInterfaceDecl *ID = dyn_cast(CD)) { + if (!RTC || !RTC->defaultSynthProperties() || + ID->isObjCRequiresPropertyDefs())

[clang] [WebKit checkers] Add an annotation for pointer conversion. (PR #141277)

2025-06-05 Thread Ziqing Luo via cfe-commits
@@ -44,6 +43,12 @@ inline Target* uncheckedDowncast(Source* source) return static_cast(source); } +template +Target* [[clang::annotate_type("webkit.pointerconversion")]] newCastFunction(Source*); ziqingluo-90 wrote: If this function is a member function,

[clang] [WebKit checkers] Treat passing of a member variable which is capable of CheckedPtr as safe. (PR #142485)

2025-06-05 Thread Ziqing Luo via cfe-commits
@@ -32,6 +32,22 @@ static void baz() { } // namespace call_args_checked +namespace call_args_member { + +void consume(CheckedObj&); + +struct WrapperObj { + CheckedObj checked; + CheckedObj& checkedRef; + void foo() { +consume(checked); ziqingluo-90 wr

[clang] [clang][CFG] Fix assertion failure in checkIncorrectLogicOperator (PR #142897)

2025-06-05 Thread Ziqing Luo via cfe-commits
@@ -1261,6 +1261,28 @@ class CFGBuilder { L2Result.Val.getKind() == APValue::Float) { llvm::APFloat L1 = L1Result.Val.getFloat(); llvm::APFloat L2 = L2Result.Val.getFloat(); + // Note that L1 and L2 do not necessarily have the same type. For example +

[clang] [StaticAnalyzer] Fix tryExpandAsInteger's failures on PCH macros (PR #142722)

2025-06-05 Thread Ziqing Luo via cfe-commits
ziqingluo-90 wrote: Thanks for merging it for me. Buildbots failures seems irrelevant: ``` TEST 'lldb-api :: tools/lldb-dap/launch/TestDAP_launch.py' FAILED or FAILED: libc/src/math/amdgpu/CMakeFiles/libc.src.math.amdgpu.acosh.dir/acosh.cpp.o ``` https://github.com/llvm/llvm-project/pull/14272

[clang] [StaticAnalyzer] Fix tryExpandAsInteger's failures on PCH macros (PR #142722)

2025-06-05 Thread Ziqing Luo via cfe-commits
ziqingluo-90 wrote: Thank you for reviewing [steakhal](https://github.com/steakhal)! https://github.com/llvm/llvm-project/pull/142722 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][CFG] Fix assertion failure in checkIncorrectLogicOperator (PR #142897)

2025-06-05 Thread Ziqing Luo via cfe-commits
https://github.com/ziqingluo-90 updated https://github.com/llvm/llvm-project/pull/142897 >From 99931f58846f361e409445d06fdfca4f5e7d3bb3 Mon Sep 17 00:00:00 2001 From: Ziqing Luo Date: Thu, 5 Jun 2025 12:28:12 +0800 Subject: [PATCH 1/2] [clang][CFG] Fix assertion failure in checkIncorrectLogicO

[clang] [StaticAnalyzer] Fix tryExpandAsInteger's failures on PCH macros (PR #142722)

2025-06-04 Thread Ziqing Luo via cfe-commits
https://github.com/ziqingluo-90 updated https://github.com/llvm/llvm-project/pull/142722 >From 3bd12ac6bb3c47b5e977cffec019df15a15426fc Mon Sep 17 00:00:00 2001 From: Ziqing Luo Date: Wed, 4 Jun 2025 12:29:53 +0800 Subject: [PATCH 1/2] [StaticAnalyzer] Fix tryExpandAsInteger's failures on macr

[clang] [StaticAnalyzer] Fix tryExpandAsInteger's failures on PCH macros (PR #142722)

2025-06-04 Thread Ziqing Luo via cfe-commits
ziqingluo-90 wrote: CC @dtarditi https://github.com/llvm/llvm-project/pull/142722 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][CFG] Fix assertion failure in checkIncorrectLogicOperator (PR #142897)

2025-06-04 Thread Ziqing Luo via cfe-commits
ziqingluo-90 wrote: Godbolt example: https://godbolt.org/z/6dv3Kearx CC @YutongZhuu as this issue was first introduced in https://github.com/YutongZhuu/llvm-project/commit/9ae3368b3b912ae425b2fbe9a59949979286744f https://github.com/llvm/llvm-project/pull/142897

[clang] [clang][CFG] Fix assertion failure in checkIncorrectLogicOperator (PR #142897)

2025-06-04 Thread Ziqing Luo via cfe-commits
https://github.com/ziqingluo-90 created https://github.com/llvm/llvm-project/pull/142897 `checkIncorrectLogicOperator` checks if an expression, for example `x != 0 || x != 1.0`, is always true or false by comparing the two literals `0` and `1.0`. But in case `x` is a 16-bit float, the two lit

[clang] [StaticAnalyzer] Fix tryExpandAsInteger's failures on PCH macros (PR #142722)

2025-06-03 Thread Ziqing Luo via cfe-commits
https://github.com/ziqingluo-90 created https://github.com/llvm/llvm-project/pull/142722 The function `tryExpandAsInteger` attempts to extract an integer from a macro definition. Previously, the attempt would fail when the macro is from a PCH, because the function tried to access the text buf

[clang] [Clang][NFC] Use `llvm::sort()` (PR #140337)

2025-05-19 Thread Ziqing Luo via cfe-commits
ziqingluo-90 wrote: hi, what is the motivation of changing `std::sort` to `llvm:sort`? https://github.com/llvm/llvm-project/pull/140337 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][ExprConst] allow single element access of vector object to be constant expression (PR #101126)

2025-05-19 Thread Ziqing Luo via cfe-commits
ziqingluo-90 wrote: > Can you file an issue so we don't lose track of the bug? Looks like we have an issue already #140348 @AaronBallman do you think my original example is well-defined according to the standard? I saw there is a warning `constexpr constructor that does not initialize all memb

[clang] [clang][ExprConst] allow single element access of vector object to be constant expression (PR #101126)

2025-05-16 Thread Ziqing Luo via cfe-commits
ziqingluo-90 wrote: ``` typedef __attribute__((__ext_vector_type__(2))) float float2; struct vec2 { float2 _v; public: constexpr vec2(float x, float y) { _v.x = x; _v.y = y; } }; constexpr struct vec2 f() { return vec2(1.0, 1.0); } int main() { vec2 S = f(); } `

[clang] [-Wunsafe-buffer-usage] Fix false warnings when const sized array is safely accessed (array [idx %const]) (PR #140113)

2025-05-16 Thread Ziqing Luo via cfe-commits
https://github.com/ziqingluo-90 approved this pull request. LGTM! (AI comments in this PR aren't very helpful IMO 😅) https://github.com/llvm/llvm-project/pull/140113 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bi

[clang] [analyzer] Fix crashing __builtin_bit_cast (PR #139188)

2025-05-13 Thread Ziqing Luo via cfe-commits
https://github.com/ziqingluo-90 closed https://github.com/llvm/llvm-project/pull/139188 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [analyzer] Fix crashing __builtin_bit_cast (PR #139188)

2025-05-12 Thread Ziqing Luo via cfe-commits
https://github.com/ziqingluo-90 updated https://github.com/llvm/llvm-project/pull/139188 Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,s

[clang] [StaticAnalyzer] Handle `__builtin_bit_cast` (PR #139188)

2025-05-10 Thread Ziqing Luo via cfe-commits
@@ -1,5 +1,5 @@ // RUN: %clang_analyze_cc1 -triple x86_64-unknown-unknown -verify %s \ -// RUN: -analyzer-checker=core,debug.ExprInspection +// RUN: -analyzer-checker=debug.ExprInspection -analyzer-disable-checker=core ziqingluo-90 wrote: Oh, I was going to

[clang] [StaticAnalyzer] Handle `__builtin_bit_cast` (PR #139188)

2025-05-09 Thread Ziqing Luo via cfe-commits
ziqingluo-90 wrote: This fix should solve https://github.com/llvm/llvm-project/issues/71174, and https://github.com/llvm/llvm-project/issues/137417 https://github.com/llvm/llvm-project/pull/139188 ___ cfe-commits mailing list cfe-commits@lists.llvm.or

[clang] [StaticAnalyzer] Handle `__builtin_bit_cast` (PR #139188)

2025-05-09 Thread Ziqing Luo via cfe-commits
ziqingluo-90 wrote: Thanks for reviewing! https://github.com/llvm/llvm-project/pull/139188 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [StaticAnalyzer] Handle `__builtin_bit_cast` (PR #139188)

2025-05-09 Thread Ziqing Luo via cfe-commits
https://github.com/ziqingluo-90 updated https://github.com/llvm/llvm-project/pull/139188 Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,s

[clang] [StaticAnalyzer] Handle `__builtin_bit_cast` (PR #139188)

2025-05-09 Thread Ziqing Luo via cfe-commits
@@ -285,15 +285,43 @@ void ExprEngine::VisitCast(const CastExpr *CastE, const Expr *Ex, ExplodedNodeSet dstPreStmt; getCheckerManager().runCheckersForPreStmt(dstPreStmt, Pred, CastE, *this); - if (CastE->getCastKind() == CK_LValueToRValue || - CastE->getCastKind() =

[clang] [StaticAnalyzer] Handle `__builtin_bit_cast` (PR #139188)

2025-05-08 Thread Ziqing Luo via cfe-commits
https://github.com/ziqingluo-90 updated https://github.com/llvm/llvm-project/pull/139188 >From 95ac7cf69dbd683f70b123446115fe3893844526 Mon Sep 17 00:00:00 2001 From: Ziqing Luo Date: Thu, 8 May 2025 17:48:41 -0700 Subject: [PATCH 1/2] [StaticAnalyzer] Handle __builtin_bit_cast Previously, CSA

[clang] [StaticAnalyzer] Handle `__builtin_bit_cast` (PR #139188)

2025-05-08 Thread Ziqing Luo via cfe-commits
https://github.com/ziqingluo-90 created https://github.com/llvm/llvm-project/pull/139188 I am investigating a CSA crash: https://godbolt.org/z/fEExYqoWM. If one changes the `__builtin_bit_cast` to a C-style cast, the test will be fine. So the problem is specific to `__builtin_bit_cast`. Loo

[clang] [analyzer] Make it a noop when initializing a field of empty record (PR #138594)

2025-05-07 Thread Ziqing Luo via cfe-commits
ziqingluo-90 wrote: Re-landed: https://github.com/llvm/llvm-project/commit/b756c82bfacb2822cd516c32ae3c406e71448c0a https://github.com/llvm/llvm-project/pull/138594 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin

[clang] [analyzer] Make it a noop when initializing a field of empty record (PR #138594)

2025-05-07 Thread Ziqing Luo via cfe-commits
@@ -715,7 +716,11 @@ void ExprEngine::handleConstructor(const Expr *E, // actually make things worse. Placement new makes this tricky as well, // since it's then possible to be initializing one part of a multi- // dimensional array. -State = Stat

[clang] b756c82 - Re-land "[analyzer] Make it a noop when initializing a field of empty record" (#138951)

2025-05-07 Thread Ziqing Luo via cfe-commits
Author: Ziqing Luo Date: 2025-05-07T15:55:52-07:00 New Revision: b756c82bfacb2822cd516c32ae3c406e71448c0a URL: https://github.com/llvm/llvm-project/commit/b756c82bfacb2822cd516c32ae3c406e71448c0a DIFF: https://github.com/llvm/llvm-project/commit/b756c82bfacb2822cd516c32ae3c406e71448c0a.diff LO

[clang] [StaticAnalyzer] Make it a noop when initializing a field of empty record (PR #138594)

2025-05-07 Thread Ziqing Luo via cfe-commits
https://github.com/ziqingluo-90 updated https://github.com/llvm/llvm-project/pull/138594 Rate limit · GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,s

[clang] [StaticAnalyzer] Make it a noop when initializing a field of empty record (PR #138594)

2025-05-07 Thread Ziqing Luo via cfe-commits
@@ -715,7 +716,11 @@ void ExprEngine::handleConstructor(const Expr *E, // actually make things worse. Placement new makes this tricky as well, // since it's then possible to be initializing one part of a multi- // dimensional array. -State = Stat

[clang] [StaticAnalyzer] Make it a noop when initializing a field of empty record (PR #138594)

2025-05-06 Thread Ziqing Luo via cfe-commits
https://github.com/ziqingluo-90 updated https://github.com/llvm/llvm-project/pull/138594 >From 4e6f2ce82744322a35614532732281eacb2fe79a Mon Sep 17 00:00:00 2001 From: Ziqing Luo Date: Mon, 5 May 2025 14:27:48 -0700 Subject: [PATCH 1/2] [StaticAnalyzer] Make it a noop when initializing a field

[clang] [StaticAnalyzer] Make it a noop when initializing a field of empty record (PR #138594)

2025-05-06 Thread Ziqing Luo via cfe-commits
@@ -715,7 +717,11 @@ void ExprEngine::handleConstructor(const Expr *E, // actually make things worse. Placement new makes this tricky as well, // since it's then possible to be initializing one part of a multi- // dimensional array. -State = Stat

[clang] [libcxx] Reland: [clang] unified CWG2398 and P0522 changes; finishes implementation of P3310 (PR #124137)

2025-05-05 Thread Ziqing Luo via cfe-commits
ziqingluo-90 wrote: > @ziqingluo-90 I had already responded here: [#130778 > (comment)](https://github.com/llvm/llvm-project/issues/130778#issuecomment-2843256610) > > I think you moved your post between issues after I had responded. @mizvekov Oh, I see! Thank you! https://github.com/llvm/ll

[clang] [libcxx] Reland: [clang] unified CWG2398 and P0522 changes; finishes implementation of P3310 (PR #124137)

2025-05-05 Thread Ziqing Luo via cfe-commits
ziqingluo-90 wrote: > Hi @mizvekov > > I believe this change is impacting our downstream compiler. Here is a minimal > example: > > ``` > #include > #include > namespace { > > template > class ForEach; // intentionally undefined >

[clang] [StaticAnalyzer] Make it a noop when initializing a field of empty record (PR #138594)

2025-05-05 Thread Ziqing Luo via cfe-commits
ziqingluo-90 wrote: CC: @dtarditi https://github.com/llvm/llvm-project/pull/138594 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [StaticAnalyzer] Make it a noop when initializing a field of empty record (PR #138594)

2025-05-05 Thread Ziqing Luo via cfe-commits
https://github.com/ziqingluo-90 created https://github.com/llvm/llvm-project/pull/138594 Previously, Static Analyzer initializes empty type fields with zeroes. This can cause problems when those fields have no unique addresses. For example, https://github.com/llvm/llvm-project/issues/137252.

[clang] [libcxx] Reland: [clang] unified CWG2398 and P0522 changes; finishes implementation of P3310 (PR #124137)

2025-04-30 Thread Ziqing Luo via cfe-commits
ziqingluo-90 wrote: Hi @mizvekov I believe this change is impacting our downstream compiler. Here is a minimal example: ``` #include #include namespace { template class ForEach; // intentionally undefined

[clang] [-Wunsafe-buffer-usage] Fix a bug that wrongly assumed CXXMethodDecl always has an identifier (PR #137248)

2025-04-24 Thread Ziqing Luo via cfe-commits
https://github.com/ziqingluo-90 closed https://github.com/llvm/llvm-project/pull/137248 ___ 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 bug that wrongly assumed CXXMethodDecl always has an identifier (PR #137248)

2025-04-24 Thread Ziqing Luo via cfe-commits
https://github.com/ziqingluo-90 updated https://github.com/llvm/llvm-project/pull/137248 >From f9e68fd71677e047ee82992f2034bd62958ecbed Mon Sep 17 00:00:00 2001 From: Ziqing Luo Date: Thu, 24 Apr 2025 13:29:24 -0700 Subject: [PATCH 1/3] [-Wunsafe-buffer-usage] Fix a bug that wrongly assumed CX

[clang] [-Wunsafe-buffer-usage] Fix a bug that wrongly assumed CXXMethodDecl always has an identifier (PR #137248)

2025-04-24 Thread Ziqing Luo via cfe-commits
ziqingluo-90 wrote: CC: @dtarditi https://github.com/llvm/llvm-project/pull/137248 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [NFC][Static Analyzer] Rename and discuss about `NotNullConstraint` & `NotNullBufferConstraint` (PR #131374)

2025-04-05 Thread Ziqing Luo via cfe-commits
https://github.com/ziqingluo-90 updated https://github.com/llvm/llvm-project/pull/131374 >From fdc265eeca36dc877f56389d8dba39b517e6 Mon Sep 17 00:00:00 2001 From: Ziqing Luo Date: Fri, 14 Mar 2025 11:13:46 -0700 Subject: [PATCH 1/2] [NFC][Static Analyzer] Rename `NotNullConstraint` & `NotN

[clang] [NFC][Static Analyzer] Rename and discuss about `NotNullConstraint` & `NotNullBufferConstraint` (PR #131374)

2025-04-05 Thread Ziqing Luo via cfe-commits
@@ -1165,7 +1165,7 @@ ProgramStateRef StdLibraryFunctionsChecker::NotNullConstraint::apply( return State->assume(L, CannotBeNull); } -void StdLibraryFunctionsChecker::NotNullConstraint::describe( +void StdLibraryFunctionsChecker::NullnessConstraint::describe( Descripti

[clang] [NFC][Static Analyzer] Rename and discuss about `NotNullConstraint` & `NotNullBufferConstraint` (PR #131374)

2025-03-24 Thread Ziqing Luo via cfe-commits
https://github.com/ziqingluo-90 updated https://github.com/llvm/llvm-project/pull/131374 >From fdc265eeca36dc877f56389d8dba39b517e6 Mon Sep 17 00:00:00 2001 From: Ziqing Luo Date: Fri, 14 Mar 2025 11:13:46 -0700 Subject: [PATCH 1/3] [NFC][Static Analyzer] Rename `NotNullConstraint` & `NotN

[clang] [NFC] [ASTMatchers] Share code of `forEachArgumentWithParamType` with UnsafeBufferUsage (PR #132387)

2025-03-21 Thread Ziqing Luo via cfe-commits
ziqingluo-90 wrote: Hi @ilya-biryukov, thank you for continuing to improve this! I'm currently dealing with downstream conflicts with your previous patch. Please do not merge this PR this week, otherwise it may slow down our CI. Thanks! https://github.com/llvm/llvm-project/pull/132387 _

[clang] [NFC][Static Analyzer] Rename and discuss about `NotNullConstraint` & `NotNullBufferConstraint` (PR #131374)

2025-03-20 Thread Ziqing Luo via cfe-commits
@@ -436,9 +436,9 @@ class StdLibraryFunctionsChecker llvm::raw_ostream &Out) const override; ValueConstraintPtr negate() const override { - NotNullBufferConstraint Tmp(*this); + BufferNullnessConstraint Tmp(*this); Tmp.Cannot

[clang] [NFC][Static Analyzer] Rename and discuss about `NotNullConstraint` & `NotNullBufferConstraint` (PR #131374)

2025-03-14 Thread Ziqing Luo via cfe-commits
@@ -436,9 +436,9 @@ class StdLibraryFunctionsChecker llvm::raw_ostream &Out) const override; ValueConstraintPtr negate() const override { - NotNullBufferConstraint Tmp(*this); + BufferNullnessConstraint Tmp(*this); Tmp.Cannot

[clang] [NFC][Static Analyzer] Rename and discuss about `NotNullConstraint` & `NotNullBufferConstraint` (PR #131374)

2025-03-14 Thread Ziqing Luo via cfe-commits
@@ -1165,7 +1165,7 @@ ProgramStateRef StdLibraryFunctionsChecker::NotNullConstraint::apply( return State->assume(L, CannotBeNull); } -void StdLibraryFunctionsChecker::NotNullConstraint::describe( +void StdLibraryFunctionsChecker::NullnessConstraint::describe( Descripti

[clang] [NFC][Static Analyzer] Rename and discuss about `NotNullConstraint` & `NotNullBufferConstraint` (PR #131374)

2025-03-14 Thread Ziqing Luo via cfe-commits
https://github.com/ziqingluo-90 created https://github.com/llvm/llvm-project/pull/131374 NotNullConstraint is used to check both null and non-null of a pointer. So the name, which was created originally for just checking non-nullness, becomes less suitable. The same reason applies to `NotNull

[clang] [Clang] Optimize -Wunsafe-buffer-usage. (PR #125492)

2025-03-12 Thread Ziqing Luo via cfe-commits
@@ -186,106 +212,193 @@ class MatchDescendantVisitor : public DynamicRecursiveASTVisitor { return DynamicRecursiveASTVisitor::TraverseStmt(Node); } + void setASTContext(ASTContext &Context) { ActiveASTContext = &Context; } + + void setHandler(const UnsafeBufferUsageHa

[clang] [Clang] Optimize -Wunsafe-buffer-usage. (PR #125492)

2025-03-12 Thread Ziqing Luo via cfe-commits
https://github.com/ziqingluo-90 approved this pull request. https://github.com/llvm/llvm-project/pull/125492 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Optimize -Wunsafe-buffer-usage. (PR #125492)

2025-03-12 Thread Ziqing Luo via cfe-commits
ziqingluo-90 wrote: Please wait a day or two for @jkorous-apple , @malavikasamak and @dtarditi to take another look. https://github.com/llvm/llvm-project/pull/125492 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bi

  1   2   3   4   >