diff options
| author | Denys Petrov <dpetrov@accesssoftek.com> | 2021-10-20 11:59:04 +0300 |
|---|---|---|
| committer | Denys Petrov <dpetrov@accesssoftek.com> | 2021-10-29 19:44:37 +0300 |
| commit | 1deccd05ba8a326e57a513002f482ed0924b1fd8 (patch) | |
| tree | 1e9cec0aada15f6e148cfa1008290d5ab7f2a4b1 /llvm/lib/Bitcode/Reader/BitcodeReader.cpp | |
| parent | 9faed889cfebf5d77faf1fab1ef8f0a2f0255e5c (diff) | |
[analyzer] Retrieve a character from StringLiteral as an initializer for constant arrays.
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
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
0 files changed, 0 insertions, 0 deletions
