brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.3 KiB · 0dbd744 Raw
71 lines · cpp
1// RUN: %check_clang_tidy %s bugprone-reserved-identifier %t -- \2// RUN:   -config='{CheckOptions: { \3// RUN:     bugprone-reserved-identifier.Invert: true, \4// RUN:     bugprone-reserved-identifier.AllowedIdentifiers: "std;reference_wrapper;ref;^c?ref;type;get" \5// RUN:   }}' -- \6// RUN:   -I%S/Inputs/reserved-identifier \7// RUN:   -isystem %S/Inputs/reserved-identifier/system8 9namespace std {10 11void __f() {}12 13void f();14// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: declaration uses identifier 'f', which is not a reserved identifier [bugprone-reserved-identifier]15// CHECK-FIXES: void __f();16struct helper {};17// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: declaration uses identifier 'helper', which is not a reserved identifier [bugprone-reserved-identifier]18// CHECK-FIXES: struct __helper {};19struct Helper {};20// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: declaration uses identifier 'Helper', which is not a reserved identifier [bugprone-reserved-identifier]21// CHECK-FIXES: struct _Helper {};22struct _helper2 {};23// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: declaration uses identifier '_helper2', which is not a reserved identifier [bugprone-reserved-identifier]24// CHECK-FIXES: struct __helper2 {};25 26template <class _Tp>27class reference_wrapper {28public:29  typedef _Tp type;30 31private:32  type *__f_;33 34public:35  reference_wrapper(type &__f)36      : __f_(&__f) {}37  // access38  operator type &() const { return *__f_; }39  type &get() const { return *__f_; }40};41 42template <class _Tp>43inline reference_wrapper<_Tp>44ref(_Tp &__t) noexcept {45  return reference_wrapper<_Tp>(__t);46}47 48template <class _Tp>49inline reference_wrapper<_Tp>50ref(reference_wrapper<_Tp> __t) noexcept {51  return ref(__t.get());52}53 54template <class Up>55// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: declaration uses identifier 'Up', which is not a reserved identifier [bugprone-reserved-identifier]56// CHECK-FIXES: template <class _Up>57inline reference_wrapper<const Up>58cref(const Up &u) noexcept {59  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: declaration uses identifier 'u', which is not a reserved identifier [bugprone-reserved-identifier]60  // CHECK-FIXES: cref(const _Up &__u) noexcept {61  return reference_wrapper<const Up>(u);62}63 64template <class _Tp>65inline reference_wrapper<_Tp>66cref(reference_wrapper<const _Tp> __t) noexcept {67  return cref(__t.get());68}69 70} // namespace std71