diff options
author | George Burgess IV <george.burgess.iv@gmail.com> | 2017-01-09 04:12:14 +0000 |
---|---|---|
committer | George Burgess IV <george.burgess.iv@gmail.com> | 2017-01-09 04:12:14 +0000 |
commit | 5a6ff0d53430d50714fa0b1117cd8ccb68d90813 (patch) | |
tree | f40510106a50285b226ebcc86e56d78aa4779c75 /include/clang/Basic/DiagnosticCommonKinds.td | |
parent | 25f75c4838e012e4c08ac295c62c85db644820af (diff) |
Add the diagnose_if attribute to clang.
`diagnose_if` can be used to have clang emit either warnings or errors
for function calls that meet user-specified conditions. For example:
```
constexpr int foo(int a)
__attribute__((diagnose_if(a > 10, "configurations with a > 10 are "
"expensive.", "warning")));
int f1 = foo(9);
int f2 = foo(10); // warning: configuration with a > 10 are expensive.
int f3 = foo(f2);
```
It currently only emits diagnostics in cases where the condition is
guaranteed to always be true. So, the following code will emit no
warnings:
```
constexpr int bar(int a) {
foo(a);
return 0;
}
constexpr int i = bar(10);
```
We hope to support optionally emitting diagnostics for cases like that
(and emitting runtime checks) in the future.
Release notes will appear shortly. :)
Differential Revision: https://reviews.llvm.org/D27424
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@291418 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Basic/DiagnosticCommonKinds.td')
-rw-r--r-- | include/clang/Basic/DiagnosticCommonKinds.td | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/include/clang/Basic/DiagnosticCommonKinds.td b/include/clang/Basic/DiagnosticCommonKinds.td index e8180eb1db..af0612a829 100644 --- a/include/clang/Basic/DiagnosticCommonKinds.td +++ b/include/clang/Basic/DiagnosticCommonKinds.td @@ -161,6 +161,8 @@ def ext_old_implicitly_unsigned_long_cxx : ExtWarn< InGroup<CXX11Compat>; def ext_clang_enable_if : Extension<"'enable_if' is a clang extension">, InGroup<GccCompat>; +def ext_clang_diagnose_if : Extension<"'diagnose_if' is a clang extension">, + InGroup<GccCompat>; // SEH def err_seh_expected_handler : Error< |