[llvm][DiagnosticInfo] handle function pointer casts
authorNick Desaulniers <ndesaulniers@google.com>
Tue, 24 Jan 2023 21:52:24 +0000 (13:52 -0800)
committerNick Desaulniers <ndesaulniers@google.com>
Tue, 24 Jan 2023 21:59:34 +0000 (13:59 -0800)
commitdef20427b401a839210ff27b34dd31b929fa82ef
treea26b5dc88f04b5e682f87d43ad3132ad88582244
parent778cf5431cafc243f81dd5c8cbd27701ff7f9120
[llvm][DiagnosticInfo] handle function pointer casts

As pointed out by @arsenm in https://reviews.llvm.org/D141451#4045099,
we don't handle ConstantExpressions for dontcall-{warn|error} IR Fn
Attrs.

Use CallBase::getCalledOperand() and Value::stripPointerCasts() should
the call to CallBase::getCalledFunction return nullptr.

I don't know how to express the IR test case in C, otherwise I'd add a
clang test, too.

Reviewed By: aeubanks

Differential Revision: https://reviews.llvm.org/D142058
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/lib/IR/DiagnosticInfo.cpp
llvm/test/CodeGen/X86/attr-dontcall.ll