From 7ceee0f1ec0e349d0df4980d7fdedbd13c7917c5 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Tue, 9 Oct 2018 10:28:48 +0200 Subject: Extend loplugin:redundantinline to catch inline functions w/o external linkage ...where "inline" (in its meaning of "this function can be defined in multiple translation units") thus doesn't make much sense. (As discussed in compilerplugins/clang/redundantinline.cxx, exempt such "static inline" functions in include files for now.) All the rewriting has been done automatically by the plugin, except for one instance in sw/source/ui/frmdlg/column.cxx that used to involve an #if), plus some subsequent solenv/clang-format/reformat-formatted-files. Change-Id: Ib8b996b651aeafc03bbdc8890faa05ed50517224 Reviewed-on: https://gerrit.libreoffice.org/61573 Tested-by: Jenkins Reviewed-by: Stephan Bergmann --- compilerplugins/clang/test/redundantinline.cxx | 10 ++++++++++ compilerplugins/clang/test/redundantinline.hxx | 20 +++++++++++--------- 2 files changed, 21 insertions(+), 9 deletions(-) (limited to 'compilerplugins/clang/test') diff --git a/compilerplugins/clang/test/redundantinline.cxx b/compilerplugins/clang/test/redundantinline.cxx index 038a1497d98e..f69e0a3b80cf 100644 --- a/compilerplugins/clang/test/redundantinline.cxx +++ b/compilerplugins/clang/test/redundantinline.cxx @@ -11,4 +11,14 @@ S1::~S1() = default; +static inline int f8() { return 0; } // expected-error {{function has no external linkage but is explicitly declared 'inline' [loplugin:redundantinline]}} + +namespace { + +static inline int f9() { return 0; } // expected-error {{function has no external linkage but is explicitly declared 'inline' [loplugin:redundantinline]}} + +} + +int main() { return f8() + f9(); } + /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/compilerplugins/clang/test/redundantinline.hxx b/compilerplugins/clang/test/redundantinline.hxx index e4efc5663e42..8e87ae05fcf7 100644 --- a/compilerplugins/clang/test/redundantinline.hxx +++ b/compilerplugins/clang/test/redundantinline.hxx @@ -52,27 +52,29 @@ void f3() {} S3::operator int() { return 0; } struct S4 { - inline S4() {} // expected-error {{[loplugin:redundantinline]}} - inline ~S4() { f1(); } // expected-error {{[loplugin:redundantinline]}} + inline S4() {} // expected-error {{function definition redundantly declared 'inline' [loplugin:redundantinline]}} + inline ~S4() { f1(); } // expected-error {{function definition redundantly declared 'inline' [loplugin:redundantinline]}} - inline void f1() { (void)this; } // expected-error {{[loplugin:redundantinline]}} + inline void f1() { (void)this; } // expected-error {{function definition redundantly declared 'inline' [loplugin:redundantinline]}} - static inline void f2() {} // expected-error {{[loplugin:redundantinline]}} + static inline void f2() {} // expected-error {{function definition redundantly declared 'inline' [loplugin:redundantinline]}} - inline void operator +() {} // expected-error {{[loplugin:redundantinline]}} + inline void operator +() {} // expected-error {{function definition redundantly declared 'inline' [loplugin:redundantinline]}} - inline operator int() { return 0; } // expected-error {{[loplugin:redundantinline]}} + inline operator int() { return 0; } // expected-error {{function definition redundantly declared 'inline' [loplugin:redundantinline]}} - friend inline void f4() {} // expected-error {{[loplugin:redundantinline]}} + friend inline void f4() {} // expected-error {{function definition redundantly declared 'inline' [loplugin:redundantinline]}} static constexpr int f5() { return 0; } - static constexpr inline int f6() { return 0; } // expected-error {{[loplugin:redundantinline]}} + static constexpr inline int f6() { return 0; } // expected-error {{function definition redundantly declared 'inline' [loplugin:redundantinline]}} }; constexpr int f5() { return 0; } -constexpr inline int f6() { return 0; } // expected-error {{[loplugin:redundantinline]}} +constexpr inline int f6() { return 0; } // expected-error {{function definition redundantly declared 'inline' [loplugin:redundantinline]}} + +static inline int f7() { return 0; } #endif -- cgit