<feed xmlns='http://www.w3.org/2005/Atom'>
<title>llvm-project.git/clang/test/Analysis/initialization.cpp, branch main</title>
<subtitle>Unnamed repository; edit this file 'description' to name the repository.
</subtitle>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/'/>
<entry>
<title>[NFC][analyzer] Use %clang_analyze_cc1 consistently (#145895)</title>
<updated>2025-06-30T10:59:51+00:00</updated>
<author>
<name>Donát Nagy</name>
<email>donat.nagy@ericsson.com</email>
</author>
<published>2025-06-30T10:59:51+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=c3f8dd1228224841e2fae52cf4f4f4070f2edfac'/>
<id>c3f8dd1228224841e2fae52cf4f4f4070f2edfac</id>
<content type='text'>
A large majority of the LIT tests of the clang static analyzer use RUN
lines with the placeholder `%clang_analyze_cc1` which expands to
`%clang_cc1 -analyze -setup-static-analyzer` where the only effect of
`-setup-static-analyzer` is that it ensures that the macro
`__clang_analyzer__` is defined. However, there were some tests that
used `%clang_cc1 -analyze` directly; this commit changes those to using
`%clang_analyze_cc1` for the sake of consistency.

Previously `%clang_analyze_cc1` did not work within the directory
`exploded-graph-rewriter` (because that directory has its own custom
`lit.local.cfg`) but this problem was eliminated by the recent commit
40cc4379cda6e0d6efe72c55d1968f9cf427a16a, so it was possible to resolve
and delete the FIXME comments asking for this change.

There are a few tests that use `%clang --analyze` or other command-line
flags (e.g. help flags), those are not affected by this change.

This cleanup was discussed in the discourse thread
https://discourse.llvm.org/t/taking-ownership-of-clang-test-analysis/84689/11</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
A large majority of the LIT tests of the clang static analyzer use RUN
lines with the placeholder `%clang_analyze_cc1` which expands to
`%clang_cc1 -analyze -setup-static-analyzer` where the only effect of
`-setup-static-analyzer` is that it ensures that the macro
`__clang_analyzer__` is defined. However, there were some tests that
used `%clang_cc1 -analyze` directly; this commit changes those to using
`%clang_analyze_cc1` for the sake of consistency.

Previously `%clang_analyze_cc1` did not work within the directory
`exploded-graph-rewriter` (because that directory has its own custom
`lit.local.cfg`) but this problem was eliminated by the recent commit
40cc4379cda6e0d6efe72c55d1968f9cf427a16a, so it was possible to resolve
and delete the FIXME comments asking for this change.

There are a few tests that use `%clang --analyze` or other command-line
flags (e.g. help flags), those are not affected by this change.

This cleanup was discussed in the discourse thread
https://discourse.llvm.org/t/taking-ownership-of-clang-test-analysis/84689/11</pre>
</div>
</content>
</entry>
<entry>
<title>[analyzer] Update the undefined assignment checker diagnostics to not use the term 'garbage' (#126596)</title>
<updated>2025-02-26T12:57:33+00:00</updated>
<author>
<name>David Tarditi</name>
<email>d_tarditi@apple.com</email>
</author>
<published>2025-02-26T12:57:33+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=8138d85f630726d2ddbf4a7950683c7db3853eb8'/>
<id>8138d85f630726d2ddbf4a7950683c7db3853eb8</id>
<content type='text'>
A clang user pointed out that messages for the static analyzer undefined
assignment checker use the term ‘garbage’, which might have a negative
connotation to some users. This change updates the messages to use the
term ‘uninitialized’. This is the usual reason why a value is undefined
in the static analyzer and describes the logical error that a programmer
should take action to fix.

Out-of-bounds reads can also produce undefined values in the static
analyzer. The right long-term design is to have to the array bounds
checker cover out-of-bounds reads, so we do not cover that case in the
updated messages. The recent improvements to the array bounds checker
make it a candidate to add to the core set of checkers.

rdar://133418644</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
A clang user pointed out that messages for the static analyzer undefined
assignment checker use the term ‘garbage’, which might have a negative
connotation to some users. This change updates the messages to use the
term ‘uninitialized’. This is the usual reason why a value is undefined
in the static analyzer and describes the logical error that a programmer
should take action to fix.

Out-of-bounds reads can also produce undefined values in the static
analyzer. The right long-term design is to have to the array bounds
checker cover out-of-bounds reads, so we do not cover that case in the
updated messages. The recent improvements to the array bounds checker
make it a candidate to add to the core set of checkers.

rdar://133418644</pre>
</div>
</content>
</entry>
<entry>
<title>[analyzer] Fix crashing getSValFromInitListExpr for nested initlists</title>
<updated>2023-03-22T07:43:09+00:00</updated>
<author>
<name>Balazs Benics</name>
<email>benicsbalazs@gmail.com</email>
</author>
<published>2023-03-22T07:43:09+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=558b46fde2db2215794336bbd08e411fee5240d7'/>
<id>558b46fde2db2215794336bbd08e411fee5240d7</id>
<content type='text'>
In the following example, we will end up hitting the `llvm_unreachable()`:
https://godbolt.org/z/5sccc95Ec
```lang=C++
enum class E {};
const E glob[] = {{}};
void initlistWithinInitlist() {
  clang_analyzer_dump(glob[0]); // crashes at loading from `glob[0]`
}
```

We should just return `std::nullopt` instead for these cases.
It's better than crashing.

Reviewed By: xazax.hun

Differential Revision: https://reviews.llvm.org/D146538
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
In the following example, we will end up hitting the `llvm_unreachable()`:
https://godbolt.org/z/5sccc95Ec
```lang=C++
enum class E {};
const E glob[] = {{}};
void initlistWithinInitlist() {
  clang_analyzer_dump(glob[0]); // crashes at loading from `glob[0]`
}
```

We should just return `std::nullopt` instead for these cases.
It's better than crashing.

Reviewed By: xazax.hun

Differential Revision: https://reviews.llvm.org/D146538
</pre>
</div>
</content>
</entry>
<entry>
<title>[analyzer] Fix region cast between the same types with different qualifiers.</title>
<updated>2021-11-15T17:23:00+00:00</updated>
<author>
<name>Denys Petrov</name>
<email>dpetrov@accesssoftek.com</email>
</author>
<published>2021-11-09T12:20:23+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=f0bc7d24882ab84f6398a1ea614dd0bf6e2a1085'/>
<id>f0bc7d24882ab84f6398a1ea614dd0bf6e2a1085</id>
<content type='text'>
Summary: Specifically, this fixes the case when we get an access to array element through the pointer to element. This covers several FIXME's. in https://reviews.llvm.org/D111654.
Example:
  const int arr[4][2];
  const int *ptr = arr[1]; // Fixes this.
The issue is that `arr[1]` is `int*` (&amp;Element{Element{glob_arr5,1 S64b,int[2]},0 S64b,int}), and `ptr` is `const int*`. We don't take qualifiers into account. Consequently, we doesn't match the types as the same ones.

Differential Revision: https://reviews.llvm.org/D113480
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Summary: Specifically, this fixes the case when we get an access to array element through the pointer to element. This covers several FIXME's. in https://reviews.llvm.org/D111654.
Example:
  const int arr[4][2];
  const int *ptr = arr[1]; // Fixes this.
The issue is that `arr[1]` is `int*` (&amp;Element{Element{glob_arr5,1 S64b,int[2]},0 S64b,int}), and `ptr` is `const int*`. We don't take qualifiers into account. Consequently, we doesn't match the types as the same ones.

Differential Revision: https://reviews.llvm.org/D113480
</pre>
</div>
</content>
</entry>
<entry>
<title>[analyzer] Retrieve a value from list initialization of multi-dimensional array declaration.</title>
<updated>2021-11-08T14:17:55+00:00</updated>
<author>
<name>Denys Petrov</name>
<email>dpetrov@accesssoftek.com</email>
</author>
<published>2021-10-22T00:24:19+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=a12bfac292db2195d3461dce51467d350de865dc'/>
<id>a12bfac292db2195d3461dce51467d350de865dc</id>
<content type='text'>
Summary: Add support of multi-dimensional arrays in `RegionStoreManager::getBindingForElement`. Handle nested ElementRegion's getting offsets and checking for being in bounds. Get values from the nested initialization lists using obtained offsets.

Differential Revision: https://reviews.llvm.org/D111654
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Summary: Add support of multi-dimensional arrays in `RegionStoreManager::getBindingForElement`. Handle nested ElementRegion's getting offsets and checking for being in bounds. Get values from the nested initialization lists using obtained offsets.

Differential Revision: https://reviews.llvm.org/D111654
</pre>
</div>
</content>
</entry>
<entry>
<title>[analyzer] Retrieve a character from StringLiteral as an initializer for constant arrays.</title>
<updated>2021-10-29T16:44:37+00:00</updated>
<author>
<name>Denys Petrov</name>
<email>dpetrov@accesssoftek.com</email>
</author>
<published>2021-10-20T08:59:04+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=1deccd05ba8a326e57a513002f482ed0924b1fd8'/>
<id>1deccd05ba8a326e57a513002f482ed0924b1fd8</id>
<content type='text'>
Summary: Assuming that values of constant arrays never change, we can retrieve values for specific position(index) right from the initializer, if presented. Retrieve a character code by index from StringLiteral which is an initializer of constant arrays in global scope.

This patch has a known issue of getting access to characters past the end of the literal. The declaration, in which the literal is used, is an implicit cast of kind `array-to-pointer`. The offset should be in literal length's bounds. This should be distinguished from the states in the Standard C++20 [dcl.init.string] 9.4.2.3. Example:
  const char arr[42] = "123";
  char c = arr[41]; // OK
  const char * const str = "123";
  char c = str[41]; // NOK

Differential Revision: https://reviews.llvm.org/D107339
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Summary: Assuming that values of constant arrays never change, we can retrieve values for specific position(index) right from the initializer, if presented. Retrieve a character code by index from StringLiteral which is an initializer of constant arrays in global scope.

This patch has a known issue of getting access to characters past the end of the literal. The declaration, in which the literal is used, is an implicit cast of kind `array-to-pointer`. The offset should be in literal length's bounds. This should be distinguished from the states in the Standard C++20 [dcl.init.string] 9.4.2.3. Example:
  const char arr[42] = "123";
  char c = arr[41]; // OK
  const char * const str = "123";
  char c = str[41]; // NOK

Differential Revision: https://reviews.llvm.org/D107339
</pre>
</div>
</content>
</entry>
<entry>
<title>[analyzer][NFCI] Move a block from `getBindingForElement` to separate functions</title>
<updated>2021-10-25T12:14:10+00:00</updated>
<author>
<name>Denys Petrov</name>
<email>dpetrov@accesssoftek.com</email>
</author>
<published>2021-10-18T16:13:05+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=44e803ef6d41770adf309960e37bcc6a75dbbe2c'/>
<id>44e803ef6d41770adf309960e37bcc6a75dbbe2c</id>
<content type='text'>
Summary:
1. Improve readability by moving deeply nested block of code from RegionStoreManager::getBindingForElement to new separate functions:
- getConstantValFromConstArrayInitializer;
- getSValFromInitListExpr.
2. Handle the case when index is a symbolic value. Write specific test cases.
3. Add test cases when there is no initialization expression presented.
This patch implies to make next patches clearer and easier for review process.

Differential Revision: https://reviews.llvm.org/D106681
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Summary:
1. Improve readability by moving deeply nested block of code from RegionStoreManager::getBindingForElement to new separate functions:
- getConstantValFromConstArrayInitializer;
- getSValFromInitListExpr.
2. Handle the case when index is a symbolic value. Write specific test cases.
3. Add test cases when there is no initialization expression presented.
This patch implies to make next patches clearer and easier for review process.

Differential Revision: https://reviews.llvm.org/D106681
</pre>
</div>
</content>
</entry>
<entry>
<title>[analyzer] Retrieve a value from list initialization of constant array declaration in a global scope.</title>
<updated>2021-09-24T09:37:58+00:00</updated>
<author>
<name>Denys Petrov</name>
<email>dpetrov@accesssoftek.com</email>
</author>
<published>2021-09-21T11:34:37+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=98a95d4844caf8edfabd9352393a5546049b54e8'/>
<id>98a95d4844caf8edfabd9352393a5546049b54e8</id>
<content type='text'>
Summary: Fix the point that we didn't take into account array's dimension. Retrieve a value of global constant array by iterating through its initializer list.

Differential Revision: https://reviews.llvm.org/D104285

Fixes: https://bugs.llvm.org/show_bug.cgi?id=50604
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Summary: Fix the point that we didn't take into account array's dimension. Retrieve a value of global constant array by iterating through its initializer list.

Differential Revision: https://reviews.llvm.org/D104285

Fixes: https://bugs.llvm.org/show_bug.cgi?id=50604
</pre>
</div>
</content>
</entry>
<entry>
<title>[analyzer] Specify the C++ standard in more tests.</title>
<updated>2019-10-19T00:08:17+00:00</updated>
<author>
<name>Artem Dergachev</name>
<email>artem.dergachev@gmail.com</email>
</author>
<published>2019-10-19T00:08:17+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=b0914e7276bf97cb57f84fecc3a95e0d3ceeaf3e'/>
<id>b0914e7276bf97cb57f84fecc3a95e0d3ceeaf3e</id>
<content type='text'>
Makes life easier for downstream developers with different default standard.

llvm-svn: 375308
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Makes life easier for downstream developers with different default standard.

llvm-svn: 375308
</pre>
</div>
</content>
</entry>
<entry>
<title>[analyzer] const init: handle non-explicit cases more accurately</title>
<updated>2018-05-29T14:14:22+00:00</updated>
<author>
<name>Rafael Stahl</name>
<email>r.stahl@tum.de</email>
</author>
<published>2018-05-29T14:14:22+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=0137aa8679d6675b2440c1e19943b23cee4dc794'/>
<id>0137aa8679d6675b2440c1e19943b23cee4dc794</id>
<content type='text'>
Summary: If the access is out of bounds, return UndefinedVal. If it is missing an explicit init, return the implicit zero value it must have.

Reviewers: NoQ, xazax.hun, george.karpenkov

Reviewed By: NoQ

Subscribers: szepet, rnkovacs, a.sidorin, cfe-commits

Differential Revision: https://reviews.llvm.org/D46823

llvm-svn: 333417
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Summary: If the access is out of bounds, return UndefinedVal. If it is missing an explicit init, return the implicit zero value it must have.

Reviewers: NoQ, xazax.hun, george.karpenkov

Reviewed By: NoQ

Subscribers: szepet, rnkovacs, a.sidorin, cfe-commits

Differential Revision: https://reviews.llvm.org/D46823

llvm-svn: 333417
</pre>
</div>
</content>
</entry>
</feed>
