The commit r316245 introduced a regression that causes an assertion failure when Clang tries to cast an IncompleteArrayType to a PointerType when evaluating __builtin_object_size in this sample:
typedef struct { char string[512]; } NestedArrayStruct; typedef struct { int x; NestedArrayStruct session[]; } IncompleteArrayStruct; void func(IncompleteArrayStruct* p) { __builtin___strlcpy_chk (p->session[0].string, "ab", 2, __builtin_object_size(p->session[0].string, 1)); }
Interestingly enough gcc seems to produce a different output for the above code (when 1 is the last parameter to __builtin_object_size). It evaluates __builtin_object_size to 512 instead of -1 like Clang:
I'm still not sure what's the right behavior after reading GCC's description of __builtin_object_size (https://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html). Maybe someone who's more familiar with this builtin could point to the cause of this discrepancy.
rdar://36094951
Please clang-format the additions to this file.