Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[clang-tidy] Optionally ignore findings in macros in `readability-con…
…st-return-type`. Adds support for options-controlled configuration of the check to ignore results in macros. Differential Revision: https://reviews.llvm.org/D137972
- Loading branch information
1 parent
f3afd16
commit a49fcca
Showing
6 changed files
with
71 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type-macros.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// RUN: %check_clang_tidy -std=c++14 %s readability-const-return-type %t -- \ | ||
// RUN: -config="{CheckOptions: [{key: readability-const-return-type.IgnoreMacros, value: false}]}" | ||
|
||
// p# = positive test | ||
// n# = negative test | ||
|
||
// Regression tests involving macros | ||
#define CONCAT(a, b) a##b | ||
CONCAT(cons, t) int p22(){} | ||
// CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const int' is 'const'-qu | ||
// We warn, but we can't give a fix | ||
|
||
#define CONSTINT const int | ||
CONSTINT p23() {} | ||
// CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const int' is 'const'-qu | ||
|
||
#define CONST const | ||
CONST int p24() {} | ||
// CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const int' is 'const'-qu | ||
|
||
#define CREATE_FUNCTION() \ | ||
const int p_inside_macro() { \ | ||
return 1; \ | ||
} | ||
CREATE_FUNCTION(); | ||
// CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const int' is 'const'-qu | ||
// We warn, but we can't give a fix |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters