[Sema] Don't check bounds for function pointer
authorAleksandr Platonov <platonov.aleksandr@huawei.com>
Wed, 13 Apr 2022 17:38:59 +0000 (20:38 +0300)
committerAleksandr Platonov <platonov.aleksandr@huawei.com>
Wed, 13 Apr 2022 17:39:38 +0000 (20:39 +0300)
commitb2c3ae0b6f05fd0c2184aea82637685a13b8dc4f
tree5b4b78fc8b09be9f382e06ee9e91ed8d08ad88e8
parent6f20744b7ff875bb5eb735d1e7636ad6a66d4526
[Sema] Don't check bounds for function pointer

Currently, clang crashes with i386 target on the following code:
```
void f() {
  f + 0xdead000000000000UL;
}
```
This problem is similar to the problem fixed in D104424, but that fix can't handle function pointer case, because `getTypeSizeInCharsIfKnown()` says that size is known and equal to 0 for function type.

This patch prevents bounds checking for function pointer, thus fixes the crash.

Fixes https://github.com/llvm/llvm-project/issues/50463

Reviewed By: erichkeane

Differential Revision: https://reviews.llvm.org/D122748
clang/lib/Sema/SemaChecking.cpp
clang/test/Sema/unbounded-array-bounds.c