ahatanak wrote:
Thanks for working on this. It's a real improvement, but I think there's more
room for improvement. it seems to me that `isConstantInitializer` itself, which
is the function that determines whether it's constant or not, is fine. The bugs
seem to be in the code in `CheckForConstantInitializer` that finds the culprit
and emits the diagnostics for ObjC constant literals.
For example:
1. Under ARC, the diagnostic points at the whole dictionary literal instead of
the specific culprit key.
```
static NSDictionary *const dNumberKey = @{@5 : @1};
```
The diagnostic points at `@{@5 : @1}` instead of the culprit key `@5`.
2. Even without ARC, a valid string key gets blamed when the value is actually
the problem.
```
int foo(void);
static NSDictionary *const dValueBad = @{@"a" : @(foo())};
```
The diagnostic points at `@"a"` instead of the actual culprit `@(foo())`.
3. Declaring the variable as `id` under ARC falls back to the generic
diagnostic instead of the ObjC-specific one.
```
static id const dNumberKeyAsId = @{@5 : @1};
```
The diagnostic is `initializer element is not a compile-time constant` instead
of the message that's specific to dictionary literals.
https://github.com/llvm/llvm-project/pull/209688
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits