Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Sema] Perform call checking when building CXXNewExpr
Summary: There was even a TODO for this. The main motivation is to make use of call-site based `__attribute__((alloc_align(param_idx)))` validation (D72996). Reviewers: rsmith, erichkeane, aaron.ballman, jdoerfert Reviewed By: rsmith Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D73020
- Loading branch information
Showing
5 changed files
with
99 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// RUN: %clang_cc1 %s -verify -fno-builtin -std=c++14 | ||
|
||
using size_t = decltype(sizeof(int)); | ||
|
||
#define _diagnose_if(...) __attribute__((diagnose_if(__VA_ARGS__))) | ||
|
||
namespace operator_new { | ||
struct T0 { | ||
int j = 0; | ||
static void *operator new(size_t i) _diagnose_if(i == sizeof(int), "yay", "warning"); // expected-note{{from 'diagnose_if'}} | ||
}; | ||
|
||
struct T1 { | ||
int j = 0; | ||
static void *operator new[](size_t i) _diagnose_if(i == 8 * sizeof(int), "yay", "warning"); // expected-note 2{{from 'diagnose_if'}} | ||
}; | ||
|
||
void run(int x) { | ||
new T0; // expected-warning{{yay}} | ||
new T1[8]; // expected-warning{{yay}} | ||
new T1[4][2]; // expected-warning{{yay}} | ||
new T1[x]; // no warning. | ||
} | ||
} // namespace operator_new |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters