mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-30 07:16:08 +00:00

In C++17, when class C has large alignment value, a special case of overload resolution rule kicks in for expression new C that causes the aligned version of operator new() to be called. The aligned new has two arguments: size and alignment. However, the new-expression has only one "argument": the construct-expression for C(). This causes a false positive in core.CallAndMessage's check for matching number of arguments and number of parameters. Update CXXAllocatorCall, which is a CallEvent sub-class for operator new calls within new-expressions, so that the number of arguments always matched the number of parameters. rdar://problem/44738501 Differential Revision: https://reviews.llvm.org/D52957 llvm-svn: 344539
15 lines
423 B
C++
15 lines
423 B
C++
//RUN: %clang_analyze_cc1 -std=c++17 -analyze -analyzer-checker=core -verify %s
|
|
|
|
// expected-no-diagnostics
|
|
|
|
// Notice the weird alignment.
|
|
struct alignas(1024) S {};
|
|
|
|
void foo() {
|
|
// Operator new() here is the C++17 aligned new that takes two arguments:
|
|
// size and alignment. Size is passed implicitly as usual, and alignment
|
|
// is passed implicitly in a similar manner.
|
|
S *s = new S; // no-warning
|
|
delete s;
|
|
}
|