Balazs Benics
ffcf214b5d
[analyzer] NonParamVarRegion should prefer definition over canonical decl
...
When we construct a `NonParamVarRegion`, we canonicalize the decl to
always use the same entity for consistency.
At the moment that is the canonical decl - which is the first decl in
the redecl chain.
However, this can cause problems with tentative declarations and extern
declarations if we declare an array with unknown bounds.
Consider this C example: https://godbolt.org/z/Kdvr11EqY
```lang=C
typedef typeof(sizeof(int)) size_t;
size_t clang_analyzer_getExtent(const void *p);
void clang_analyzer_dump(size_t n);
extern const unsigned char extern_redecl[];
const unsigned char extern_redecl[] = { 1,2,3,4 };
const unsigned char tentative_redecl[];
const unsigned char tentative_redecl[] = { 1,2,3,4 };
const unsigned char direct_decl[] = { 1,2,3,4 };
void test_redeclaration_extent(void) {
clang_analyzer_dump(clang_analyzer_getExtent(direct_decl)); // 4
clang_analyzer_dump(clang_analyzer_getExtent(extern_redecl)); // should be 4 instead of Unknown
clang_analyzer_dump(clang_analyzer_getExtent(tentative_redecl)); // should be 4 instead of Unknown
}
```
The `getType()` of the canonical decls for the forward declared globals,
will return `IncompleteArrayType`, unlike the
`getDefinition()->getType()`, which would have returned
`ConstantArrayType` of 4 elements.
This makes the `MemRegionManager::getStaticSize()` return `Unknown` as
the extent for the array variables, leading to FNs.
To resolve this, I think we should prefer the definition decl (if
present) over the canonical decl when constructing `NonParamVarRegion`s.
FYI The canonicalization of the decl was introduced by D57619 in 2019.
Differential Revision: https://reviews.llvm.org/D154827
2023-07-11 08:50:59 +02:00
..
2022-05-05 17:52:08 +02:00
2023-05-31 07:26:03 +02:00
2022-11-17 14:47:02 -05:00
2023-05-23 08:29:52 +02:00
2023-07-07 08:41:11 -04:00
2023-07-07 08:41:11 -04:00
2023-05-23 08:29:52 +02:00
2022-05-12 15:40:11 +02:00
2022-03-29 17:08:19 -05:00
2023-03-04 02:01:45 +01:00
2022-06-14 09:20:41 +02:00
2023-05-23 08:29:52 +02:00
2023-07-07 13:24:33 +02:00
2022-07-27 11:10:54 +02:00
2023-06-01 09:54:35 +02:00
2022-06-14 10:22:37 +02:00
2023-04-26 15:02:23 +02:00
2022-08-25 12:42:02 +02:00
2022-05-05 04:53:45 -05:00
2023-07-07 08:41:11 -04:00
2022-06-14 09:20:41 +02:00
2023-01-20 15:51:32 -08:00
2023-03-07 08:41:30 +01:00
2023-07-07 08:41:11 -04:00
2022-07-27 11:10:54 +02:00
2022-06-14 09:20:41 +02:00
2022-07-22 15:24:54 -04:00
2022-06-14 09:20:41 +02:00
2023-05-31 14:43:16 +02:00
2022-07-27 11:10:54 +02:00
2023-07-07 08:41:11 -04:00
2023-07-07 08:41:11 -04:00
2022-07-27 11:10:54 +02:00
2022-07-27 11:10:54 +02:00
2022-06-14 09:20:41 +02:00
2022-06-14 09:20:41 +02:00
2022-06-14 09:20:41 +02:00
2023-06-15 12:41:09 +05:30
2022-07-27 11:10:54 +02:00
2022-07-27 11:10:54 +02:00
2022-07-28 15:27:50 -07:00
2022-06-14 09:20:41 +02:00
2022-12-12 11:25:19 -08:00
2023-07-07 08:41:11 -04:00
2022-06-14 09:20:41 +02:00
2022-06-14 09:20:41 +02:00
2023-05-23 08:29:52 +02:00
2022-12-15 12:26:33 -08:00
2022-05-18 14:35:12 -07:00
2022-06-14 09:20:41 +02:00
2022-06-14 09:20:41 +02:00
2022-12-19 12:49:43 +01:00
2023-01-25 02:32:55 +05:30
2022-05-26 14:09:46 +02:00
2022-05-26 14:09:46 +02:00
2023-06-01 09:54:35 +02:00
2022-09-26 11:39:10 +02:00
2022-06-14 09:20:41 +02:00
2022-03-31 17:34:56 +02:00
2022-06-14 09:20:41 +02:00
2022-07-14 23:30:21 +02:00
2022-09-05 17:06:27 +02:00
2022-09-13 08:58:46 +02:00
2022-03-28 10:55:26 +02:00
2022-05-18 10:35:52 +02:00
2022-03-22 10:28:42 +08:00
2022-03-22 10:28:42 +08:00
2022-05-18 10:35:52 +02:00
2022-05-18 10:35:52 +02:00
2022-05-18 10:35:52 +02:00
2022-05-18 10:35:52 +02:00
2022-05-18 10:35:52 +02:00
2022-05-18 10:35:52 +02:00
2022-05-18 10:35:52 +02:00
2022-05-18 10:35:52 +02:00
2022-10-26 17:22:12 +02:00
2022-06-14 09:20:41 +02:00
2022-07-27 11:10:54 +02:00
2022-07-14 23:30:21 +02:00
2022-05-09 15:44:33 +02:00
2023-07-07 08:41:11 -04:00
2022-08-23 18:33:26 +02:00
2023-07-07 08:41:11 -04:00
2023-07-07 08:41:11 -04:00
2022-05-02 11:48:52 +02:00
2023-07-07 08:41:11 -04:00
2022-06-14 09:20:41 +02:00
2023-07-07 08:41:11 -04:00
2023-07-07 13:24:33 +02:00
2022-06-14 09:20:41 +02:00
2022-11-09 15:06:46 +01:00
2022-07-14 23:30:21 +02:00
2022-05-02 11:42:08 +02:00
2022-07-27 11:10:54 +02:00
2023-07-07 08:41:11 -04:00
2022-06-14 09:20:41 +02:00
2022-08-10 19:52:55 +03:00
2022-06-20 10:07:31 +02:00
2022-06-20 10:07:31 +02:00
2023-06-01 09:54:35 +02:00
2023-06-01 09:54:35 +02:00
2022-06-20 10:07:31 +02:00
2022-04-20 11:30:12 -04:00
2022-05-26 14:00:27 +02:00
2022-09-13 09:04:27 +02:00
2022-06-15 16:06:53 +02:00
2022-06-14 09:20:41 +02:00
2022-12-11 17:56:51 -06:00
2022-08-25 12:42:02 +02:00
2022-11-25 10:24:56 +01:00
2022-06-14 09:20:41 +02:00
2022-06-14 09:20:41 +02:00
2022-07-05 13:45:52 +02:00
2022-06-14 09:20:41 +02:00
2023-07-07 08:41:11 -04:00
2022-06-15 17:08:27 +02:00
2023-07-11 08:50:59 +02:00
2022-06-14 09:20:41 +02:00
2022-07-14 23:30:21 +02:00
2022-05-18 14:35:12 -07:00
2022-05-10 11:18:35 +02:00
2022-05-10 10:16:55 +02:00
2023-03-22 08:43:09 +01:00
2022-07-27 11:10:54 +02:00
2023-07-07 08:41:11 -04:00
2022-05-04 08:35:47 -04:00
2022-05-03 14:05:19 +02:00
2022-09-04 23:06:58 +02:00
2023-07-03 16:13:47 +08:00
2022-06-14 09:20:41 +02:00
2022-06-14 09:20:41 +02:00
2022-10-20 14:14:52 +02:00
2022-11-08 07:21:23 -05:00
2023-01-20 15:51:32 -08:00
2023-07-05 07:39:14 +02:00
2023-05-23 08:29:52 +02:00
2022-07-26 10:24:29 +02:00
2022-06-14 09:20:41 +02:00
2022-06-14 09:20:41 +02:00
2022-06-14 09:20:41 +02:00
2022-06-14 09:20:41 +02:00
2022-06-14 09:20:41 +02:00
2023-07-07 08:41:11 -04:00
2023-07-07 08:41:11 -04:00
2022-07-27 11:10:54 +02:00
2023-01-12 10:42:57 +01:00
2022-04-20 11:30:12 -04:00
2023-07-07 08:41:11 -04:00
2022-06-14 09:20:41 +02:00
2022-06-14 09:20:41 +02:00
2022-09-13 08:58:46 +02:00
2022-06-14 09:20:41 +02:00
2023-07-07 08:41:11 -04:00
2023-07-07 08:41:11 -04:00
2023-07-07 08:41:11 -04:00
2023-07-07 08:41:11 -04:00
2022-06-14 09:20:41 +02:00
2022-06-14 09:20:41 +02:00
2023-07-07 08:41:11 -04:00
2023-07-07 08:41:11 -04:00
2022-06-14 10:22:37 +02:00
2023-07-07 08:41:11 -04:00
2023-05-25 09:50:56 -07:00
2022-07-27 11:10:54 +02:00
2023-07-07 08:41:11 -04:00
2022-10-26 17:22:12 +02:00
2022-10-26 17:22:12 +02:00
2022-06-14 09:20:41 +02:00
2022-10-26 17:22:12 +02:00
2022-10-26 17:22:12 +02:00
2022-10-03 15:42:38 +02:00
2023-07-07 08:41:11 -04:00
2022-06-14 09:20:41 +02:00
2022-06-14 09:20:41 +02:00
2022-06-14 09:20:41 +02:00
2022-10-12 14:46:32 +02:00
2022-07-22 15:24:54 -04:00
2023-06-08 16:48:24 +02:00
2022-06-14 09:20:41 +02:00
2023-07-07 08:41:11 -04:00
2022-06-14 09:20:41 +02:00
2022-06-14 09:20:41 +02:00
2023-07-07 08:41:11 -04:00
2023-07-06 22:36:51 +08:00
2022-04-15 09:08:54 -04:00
2023-07-06 22:36:51 +08:00
2022-06-14 09:20:41 +02:00
2022-07-22 15:24:54 -04:00
2022-07-22 15:24:54 -04:00
2023-07-07 08:41:11 -04:00
2022-06-14 09:20:41 +02:00
2023-07-07 08:41:11 -04:00
2022-06-14 09:20:41 +02:00
2023-07-07 08:41:11 -04:00
2022-07-22 15:24:54 -04:00
2022-07-14 23:30:21 +02:00
2022-04-20 11:30:12 -04:00
2023-07-07 08:41:11 -04:00
2023-07-07 08:41:11 -04:00
2022-06-14 09:20:41 +02:00
2022-06-14 09:20:41 +02:00
2022-06-14 09:20:41 +02:00
2022-07-13 15:32:29 -04:00
2022-07-13 15:32:29 -04:00
2022-09-21 17:26:09 -07:00
2022-10-26 17:22:12 +02:00
2022-04-20 11:30:12 -04:00
2023-07-07 08:41:11 -04:00
2023-07-07 08:41:11 -04:00
2022-06-01 18:53:19 +02:00
2022-06-14 09:20:41 +02:00
2023-07-03 16:13:47 +08:00
2022-06-14 09:20:41 +02:00
2022-06-14 09:20:41 +02:00
2023-07-07 08:41:11 -04:00
2023-06-01 09:54:35 +02:00
2023-03-04 02:01:45 +01:00
2022-06-14 09:20:41 +02:00
2022-06-14 09:20:41 +02:00
2022-07-15 20:07:04 +03:00
2022-07-05 19:00:23 +02:00
2023-07-07 08:41:11 -04:00
2023-07-07 08:41:11 -04:00
2022-09-13 08:58:46 +02:00
2022-11-23 15:52:11 +01:00
2023-05-16 15:38:55 +02:00
2022-06-14 09:20:41 +02:00
2022-06-14 09:20:41 +02:00
2022-06-14 09:20:41 +02:00
2022-06-14 09:20:41 +02:00
2022-06-14 09:20:41 +02:00
2022-06-14 09:20:41 +02:00
2022-06-14 09:20:41 +02:00
2023-07-07 08:41:11 -04:00
2022-06-14 09:20:41 +02:00
2022-10-26 11:27:01 +02:00
2022-10-26 17:22:12 +02:00
2023-07-07 08:41:11 -04:00
2022-06-14 09:20:41 +02:00
2023-07-07 08:41:11 -04:00
2023-07-07 08:41:11 -04:00
2023-07-07 08:41:11 -04:00
2023-01-26 17:26:05 +01:00
2022-04-08 10:16:58 +02:00
2022-05-26 13:50:40 +02:00
2023-01-20 15:51:32 -08:00
2023-07-07 08:41:11 -04:00
2023-07-07 08:41:11 -04:00
2023-07-07 08:41:11 -04:00
2022-06-14 09:20:41 +02:00
2022-08-26 12:19:32 -07:00
2022-08-26 12:19:32 -07:00
2023-06-01 09:54:35 +02:00
2023-06-01 09:54:35 +02:00
2023-06-01 09:54:35 +02:00
2023-06-01 09:54:35 +02:00
2023-06-01 09:54:35 +02:00
2023-06-01 09:54:35 +02:00
2023-06-06 11:51:33 +02:00
2023-06-06 11:51:33 +02:00
2023-06-01 09:54:35 +02:00
2023-06-01 09:54:35 +02:00
2023-06-01 09:54:35 +02:00
2023-06-01 09:54:35 +02:00
2023-06-01 09:54:35 +02:00
2023-06-01 09:54:35 +02:00
2023-06-01 09:54:35 +02:00
2023-06-01 09:54:35 +02:00
2023-06-01 09:54:35 +02:00
2023-06-01 09:54:35 +02:00
2023-06-01 09:54:35 +02:00
2023-06-01 09:54:35 +02:00
2023-06-01 09:54:35 +02:00
2023-06-01 09:54:35 +02:00
2023-06-01 09:54:35 +02:00
2023-06-01 09:54:35 +02:00
2023-06-30 10:29:49 +02:00
2023-06-01 09:54:35 +02:00
2023-06-06 11:51:33 +02:00
2023-06-06 11:51:33 +02:00
2023-06-06 11:51:33 +02:00
2022-06-14 09:20:41 +02:00
2022-07-13 19:19:23 -05:00
2022-06-29 13:01:19 +02:00
2022-06-01 08:42:04 +02:00
2022-11-23 15:52:11 +01:00
2022-12-04 15:57:24 -08:00
2022-06-09 16:13:57 +02:00
2022-10-03 15:42:38 +02:00
2022-05-25 10:55:50 +02:00
2022-03-23 08:26:40 -05:00
2023-02-17 11:37:02 +01:00
2022-07-05 18:42:34 +02:00
2023-04-26 12:43:36 +02:00
2023-05-03 18:52:27 +02:00
2023-04-26 12:43:36 +02:00
2022-07-27 11:10:54 +02:00
2022-10-13 08:41:31 +02:00
2023-07-07 08:41:11 -04:00
2022-04-08 10:16:58 +02:00
2022-10-19 16:06:32 +02:00
2022-05-26 14:09:46 +02:00
2022-05-26 14:14:10 +02:00
2022-05-26 14:09:46 +02:00
2022-06-14 09:20:41 +02:00
2022-09-04 23:06:58 +02:00
2023-02-16 17:58:35 -08:00
2023-07-07 08:41:11 -04:00
2022-10-26 17:22:12 +02:00
2023-07-07 08:41:11 -04:00
2023-07-07 08:41:11 -04:00
2022-07-26 09:07:22 +02:00
2022-06-17 19:50:10 +02:00
2022-07-26 10:24:29 +02:00
2022-06-14 09:20:41 +02:00
2023-07-07 08:41:11 -04:00
2023-07-07 08:41:11 -04:00
2022-06-14 09:20:41 +02:00
2022-06-14 09:20:41 +02:00
2022-06-14 10:22:37 +02:00
2023-07-07 08:41:11 -04:00
2023-07-05 07:39:14 +02:00
2023-07-07 08:41:11 -04:00
2022-06-14 09:20:41 +02:00
2022-06-14 09:20:41 +02:00
2022-06-14 09:20:41 +02:00
2022-06-14 09:20:41 +02:00
2023-06-01 09:54:35 +02:00
2022-06-14 09:20:41 +02:00
2022-08-05 10:32:53 +02:00
2023-01-26 12:55:42 -06:00
2022-05-02 10:54:26 +02:00
2022-08-25 12:42:02 +02:00