summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy/readability/RedundantDeclarationCheck.cpp
diff options
context:
space:
mode:
authorMatthias Gehre <M.Gehre@gmx.de>2019-05-13 19:21:57 +0000
committerMatthias Gehre <M.Gehre@gmx.de>2019-05-13 19:21:57 +0000
commit5f9afe953deabd919da9d6aff88d9e3480d8d1f2 (patch)
treea12cbf493279d8704c683023df3fb50f1b7178b7 /clang-tools-extra/clang-tidy/readability/RedundantDeclarationCheck.cpp
parentae54fc9f0422ed541e4f3197fb2a3538af7f1ab9 (diff)
downloadbcm5719-llvm-5f9afe953deabd919da9d6aff88d9e3480d8d1f2.tar.gz
bcm5719-llvm-5f9afe953deabd919da9d6aff88d9e3480d8d1f2.zip
[clang-tidy] readability-redundant-declaration: fix false positive with C "extern inline"
Summary: readability-redundant-declaration was diagnosing a redundant declaration on "extern inline void f();", which is needed in C code to force an external definition of the inline function f. (This is different to how inline behaves in C++). Reviewers: alexfh, danielmarjamaki Subscribers: xazax.hun, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61700 llvm-svn: 360613
Diffstat (limited to 'clang-tools-extra/clang-tidy/readability/RedundantDeclarationCheck.cpp')
-rw-r--r--clang-tools-extra/clang-tidy/readability/RedundantDeclarationCheck.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/clang-tools-extra/clang-tidy/readability/RedundantDeclarationCheck.cpp b/clang-tools-extra/clang-tidy/readability/RedundantDeclarationCheck.cpp
index ff3809a2ff1..ab2e15b0723 100644
--- a/clang-tools-extra/clang-tidy/readability/RedundantDeclarationCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/RedundantDeclarationCheck.cpp
@@ -17,6 +17,10 @@ namespace clang {
namespace tidy {
namespace readability {
+AST_MATCHER(FunctionDecl, doesDeclarationForceExternallyVisibleDefinition) {
+ return Node.doesDeclarationForceExternallyVisibleDefinition();
+}
+
RedundantDeclarationCheck::RedundantDeclarationCheck(StringRef Name,
ClangTidyContext *Context)
: ClangTidyCheck(Name, Context),
@@ -25,8 +29,10 @@ RedundantDeclarationCheck::RedundantDeclarationCheck(StringRef Name,
void RedundantDeclarationCheck::registerMatchers(MatchFinder *Finder) {
Finder->addMatcher(
namedDecl(anyOf(varDecl(unless(isDefinition())),
- functionDecl(unless(anyOf(isDefinition(), isDefaulted(),
- hasParent(friendDecl()))))))
+ functionDecl(unless(anyOf(
+ isDefinition(), isDefaulted(),
+ doesDeclarationForceExternallyVisibleDefinition(),
+ hasParent(friendDecl()))))))
.bind("Decl"),
this);
}
OpenPOWER on IntegriCloud