brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.8 KiB · f41a363 Raw
39 lines · cpp
1// RUN: %check_clang_tidy -std=c++11,c++14 %s modernize-use-noexcept %t -- \2// RUN:   -config="{CheckOptions: {modernize-use-noexcept.ReplacementString: 'NOEXCEPT'}}" \3// RUN:   -- -fexceptions4// This test is not run in C++17 or later because dynamic exception5// specifications were removed in C++17.6 7// Example definition of NOEXCEPT -- simplified test to see if noexcept is supported.8#if (__has_feature(cxx_noexcept))9#define NOEXCEPT noexcept10#else11#define NOEXCEPT throw()12#endif13 14void bar() throw() {}15// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: dynamic exception specification 'throw()' is deprecated; consider using 'NOEXCEPT' instead [modernize-use-noexcept]16// CHECK-FIXES: void bar() NOEXCEPT {}17 18// Should not trigger a FixItHint, since macros only support noexcept, and this19// case throws.20class A {};21class B {};22void foobar() throw(A, B);23// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: dynamic exception specification 'throw(A, B)' is deprecated; consider removing it instead [modernize-use-noexcept]24 25// Should not trigger a replacement.26void foo() noexcept(true);27 28struct Z {29  void operator delete(void *ptr) throw();30  void operator delete[](void *ptr) throw(int);31  ~Z() throw(int) {}32};33// CHECK-MESSAGES: :[[@LINE-4]]:35: warning: dynamic exception specification 'throw()' is deprecated; consider using 'NOEXCEPT' instead [modernize-use-noexcept]34// CHECK-MESSAGES: :[[@LINE-4]]:37: warning: dynamic exception specification 'throw(int)' is deprecated; consider removing it instead [modernize-use-noexcept]35// CHECK-MESSAGES: :[[@LINE-4]]:8: warning: dynamic exception specification 'throw(int)' is deprecated; consider removing it instead [modernize-use-noexcept]36// CHECK-FIXES: void operator delete(void *ptr) NOEXCEPT;37// CHECK-FIXES: void operator delete[](void *ptr) throw(int);38// CHECK-FIXES: ~Z() throw(int) {}39