Debian Codegraph @

clang-tools-extra/test/clang-tidy/checkers/modernize/use-nodiscard-gcc-unused.cpp

raw
1 // RUN: %check_clang_tidy %s modernize-use-nodiscard %t -- \
2 // RUN: -config="{CheckOptions: {modernize-use-nodiscard.ReplacementString: '[[gcc::warn_unused_result]]'}}"
3
4 class Foo
5 {
6 public:
7 bool f1() const;
8 // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f1' should be marked {{\[\[gcc::warn_unused_result\]\]}} [modernize-use-nodiscard]
9 // CHECK-FIXES: {{\[\[gcc::warn_unused_result\]\]}} bool f1() const;
10
11 bool f2(int) const;
12 // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f2' should be marked {{\[\[gcc::warn_unused_result\]\]}} [modernize-use-nodiscard]
13 // CHECK-FIXES: {{\[\[gcc::warn_unused_result\]\]}} bool f2(int) const;
14
15 bool f3(const int &) const;
16 // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f3' should be marked {{\[\[gcc::warn_unused_result\]\]}} [modernize-use-nodiscard]
17 // CHECK-FIXES: {{\[\[gcc::warn_unused_result\]\]}} bool f3(const int &) const;
18
19 bool f4(void) const;
20 // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f4' should be marked {{\[\[gcc::warn_unused_result\]\]}} [modernize-use-nodiscard]
21 // CHECK-FIXES: {{\[\[gcc::warn_unused_result\]\]}} bool f4(void) const;
22
23 };
24