================
@@ -0,0 +1,57 @@
+// RUN: %check_clang_tidy -check-suffixes=ALL -std=c++11-or-later %s 
bugprone-exception-escape %t -- \
+// RUN:     -config='{"CheckOptions": { \
+// RUN:       
"bugprone-exception-escape.TreatFunctionsWithoutSpecificationAsThrowing": "All" 
\
+// RUN:     }}' -- -fexceptions
+// RUN: %check_clang_tidy -check-suffixes=UNDEFINED -std=c++11-or-later %s 
bugprone-exception-escape %t -- \
+// RUN:     -config='{"CheckOptions": { \
+// RUN:       
"bugprone-exception-escape.TreatFunctionsWithoutSpecificationAsThrowing": 
"OnlyUndefined" \
+// RUN:     }}' -- -fexceptions
+// RUN: %check_clang_tidy -check-suffixes=NONE -std=c++11-or-later %s 
bugprone-exception-escape %t -- \
+// RUN:     -config='{"CheckOptions": { \
+// RUN:       
"bugprone-exception-escape.TreatFunctionsWithoutSpecificationAsThrowing": 
"None" \
+// RUN:     }}' -- -fexceptions
+
+void unannotated_no_throw_body() {}
+
+void calls_unannotated() noexcept {
+  // CHECK-MESSAGES-ALL: :[[@LINE-1]]:6: warning: an exception may be thrown 
in function 'calls_unannotated' which should not throw exceptions
+  // CHECK-MESSAGES-UNDEFINED-NOT: warning:
+  // CHECK-MESSAGES-NONE-NOT: warning:
+  unannotated_no_throw_body();
+}
+
+void extern_declared();
+
+void calls_unknown() noexcept {
+  // CHECK-MESSAGES-ALL: :[[@LINE-1]]:6: warning: an exception may be thrown 
in function 'calls_unknown' which should not throw exceptions
+  // CHECK-MESSAGES-UNDEFINED: :[[@LINE-2]]:6: warning: an exception may be 
thrown in function 'calls_unknown' which should not throw exceptions
+  // CHECK-MESSAGES-NONE-NOT: warning:
+  extern_declared();
+}
+
+void calls_unknown_caught() noexcept {
+  // CHECK-MESSAGES-ALL-NOT: warning:
+  // CHECK-MESSAGES-UNDEFINED-NOT: warning:
+  // CHECK-MESSAGES-NONE-NOT: warning:
+  try {
+    extern_declared();
+  } catch(...) {
+  }
+}
+
+void definitely_nothrow() noexcept {}
----------------
vbvictor wrote:

Can we add test with
```cpp
void nothrow_nobody() throw() // can be marked noexcept

void call() {
  nothrow_nobody();
}
```

https://github.com/llvm/llvm-project/pull/168324
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to