Skip to content

Commit 40ff8cd

Browse files
committed
fixup! [clang-tidy] Added check to detect redundant inline keyword
Disable inline variable check for pre c++-17 code
1 parent 095c17a commit 40ff8cd

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

clang-tools-extra/clang-tidy/readability/RedundantInlineSpecifierCheck.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,18 +61,18 @@ void RedundantInlineSpecifierCheck::registerMatchers(MatchFinder *Finder) {
6161
allOf(isDefinition(), hasAncestor(recordDecl()))))
6262
.bind("fun_decl"),
6363
this);
64-
65-
Finder->addMatcher(
66-
varDecl(isInlineSpecified(),
67-
anyOf(isInAnonymousNamespace(),
68-
allOf(isConstexpr(), hasAncestor(recordDecl()))))
69-
.bind("var_decl"),
70-
this);
71-
7264
Finder->addMatcher(
7365
functionTemplateDecl(has(functionDecl(isInlineSpecified())))
7466
.bind("templ_decl"),
7567
this);
68+
if (getLangOpts().CPlusPlus17) {
69+
Finder->addMatcher(
70+
varDecl(isInlineSpecified(),
71+
anyOf(isInAnonymousNamespace(),
72+
allOf(isConstexpr(), hasAncestor(recordDecl()))))
73+
.bind("var_decl"),
74+
this);
75+
}
7676
}
7777

7878
template <typename T>

clang-tools-extra/test/clang-tidy/checkers/readability/redundant-inline-specifier.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %check_clang_tidy %s readability-redundant-inline-specifier %t
1+
// RUN: %check_clang_tidy %s readability-redundant-inline-specifier -std=c++17 %t
22

33
template <typename T> inline T f()
44
// CHECK-MESSAGES: :[[@LINE-1]]:23: warning: function 'f' has inline specifier but is implicitly inlined [readability-redundant-inline-specifier]

0 commit comments

Comments
 (0)