Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
0630d81
[clang][analyzer] Add StoreToImmutable checker
gamesh411 Jul 24, 2025
fa3f84f
Apply review suggestiongs by @steakhal
gamesh411 Jul 25, 2025
b022182
[review-fix] fix test files
gamesh411 Jul 28, 2025
5190ee0
[review-fix] add test case for complex memory hierarchy
gamesh411 Jul 28, 2025
856a865
[review-fix] remove isInSystemMacro check
gamesh411 Jul 28, 2025
d8f3456
[review-fix] add example note on string literal limitation
gamesh411 Jul 28, 2025
01d0521
[review-fix] implement hierarchical memregion handling
gamesh411 Jul 28, 2025
2aacf92
[cornercase] Lambda initialization gives a false positive in C++14 an…
gamesh411 Jul 29, 2025
6e8a332
[format] fixed example file code formatting
gamesh411 Jul 29, 2025
d65aa88
[review-fix] don't repeat type names
gamesh411 Jul 29, 2025
7e94b10
[cornercase] fix false positive cornercase
gamesh411 Jul 29, 2025
4db2804
[review-fix] streamline example file
gamesh411 Jul 30, 2025
7e73177
[review-fix] add more C++ standard versions
gamesh411 Jul 30, 2025
cac94fe
[review-fix] streamline implementation
gamesh411 Jul 30, 2025
373679b
[review-fix] support SubRegions not just ElementRegions
gamesh411 Jul 30, 2025
7cbabf8
[review-fix] fix typo
gamesh411 Jul 30, 2025
e377b19
[review-fix] delete stray whitespace
gamesh411 Jul 30, 2025
cfedf88
[review-fix] more elaborate notes
gamesh411 Aug 1, 2025
fa0a379
[review-fix] remove redundant comments from example
gamesh411 Aug 1, 2025
4e6c988
[review-fix] document our options for the fixme
gamesh411 Aug 1, 2025
17a0e9c
Merge branch 'main' into store-to-immutable-checker
gamesh411 Aug 1, 2025
89389a5
[review-fix] clarify wording
gamesh411 Aug 2, 2025
4d883f1
fix formatting
gamesh411 Aug 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions clang/test/Analysis/store-to-immutable-basic.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.core.StoreToImmutable -verify %s

// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.core.StoreToImmutable -std=c++17 -verify %s

void test_write_to_const_ref_param(const int &param) {
*(int*)&param = 100; // expected-warning {{Writing to immutable memory is undefined behavior. This memory region is marked as immutable and should not be modified}}
Expand Down
10 changes: 10 additions & 0 deletions clang/test/Analysis/store-to-immutable-lambda-init.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.core.StoreToImmutable -std=c++14 -verify %s

// expected-no-diagnostics

// In C++14 and before, when initializing a lambda, the statement given in the checkBind callback is not the whole DeclExpr, but the CXXConstructExpr of the lambda object.
// FIXME: Once the API of checkBind provides more information about the statement, the checker should be simplified, and this this test case will no longer be a cornercase in the checker.

void test_const_lambda_initialization_pre_cpp17() {
const auto lambda = [](){}; // No warning expected
}
Loading