This revision was automatically updated to reflect the committed changes. Closed by commit rG9d4162ff28b4: [clang-tidy] Add fix-it support to `llvmlibc-inline-function-decl` (authored by mcgrathr).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D157164/new/ https://reviews.llvm.org/D157164 Files: clang-tools-extra/clang-tidy/llvmlibc/InlineFunctionDeclCheck.cpp clang-tools-extra/test/clang-tidy/checkers/llvmlibc/inline-function-decl.hpp
Index: clang-tools-extra/test/clang-tidy/checkers/llvmlibc/inline-function-decl.hpp =================================================================== --- clang-tools-extra/test/clang-tidy/checkers/llvmlibc/inline-function-decl.hpp +++ clang-tools-extra/test/clang-tidy/checkers/llvmlibc/inline-function-decl.hpp @@ -17,11 +17,13 @@ constexpr long long addll(long long a, long long b) { // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: 'addll' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] +// CHECK-FIXES: LIBC_INLINE constexpr long long addll(long long a, long long b) { return a + b; } inline unsigned long addul(unsigned long a, unsigned long b) { // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: 'addul' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] +// CHECK-FIXES: LIBC_INLINE inline unsigned long addul(unsigned long a, unsigned long b) { return a + b; } @@ -30,11 +32,13 @@ public: MyClass() : A(123) {} // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'MyClass' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] + // CHECK-FIXES: LIBC_INLINE MyClass() : A(123) {} LIBC_INLINE MyClass(int V) : A(V) {} constexpr operator int() const { return A; } // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'operator int' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] + // CHECK-FIXES: LIBC_INLINE constexpr operator int() const { return A; } LIBC_INLINE bool operator==(const MyClass &RHS) { return RHS.A == A; @@ -42,6 +46,7 @@ static int getVal(const MyClass &V) { // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'getVal' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] + // CHECK-FIXES: LIBC_INLINE static int getVal(const MyClass &V) { return V.A; } @@ -51,6 +56,7 @@ constexpr static int addInt(MyClass &V, int A) { // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'addInt' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] + // CHECK-FIXES: LIBC_INLINE constexpr static int addInt(MyClass &V, int A) { return V.A += A; } @@ -78,6 +84,7 @@ inline void badSimpleFunction() {} // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: 'badSimpleFunction' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] +// CHECK-FIXES: LIBC_INLINE inline void badSimpleFunction() {} void LIBC_INLINE badSimpleFunctionWrongLocation() {} // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: 'badSimpleFunctionWrongLocation' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] @@ -93,6 +100,7 @@ template <typename T> inline void badTemplateFunction() {} // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: 'badTemplateFunction' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] +// CHECK-FIXES: template <typename T> LIBC_INLINE inline void badTemplateFunction() {} template <typename T> void LIBC_INLINE badTemplateFunctionWrongLocation() {} // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: 'badTemplateFunctionWrongLocation' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] @@ -108,9 +116,11 @@ template <typename... Ts> inline void badVariadicFunction() {} // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: 'badVariadicFunction' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] +// CHECK-FIXES: template <typename... Ts> LIBC_INLINE inline void badVariadicFunction() {} template <typename... Ts> void LIBC_INLINE badVariadicFunctionWrongLocation() {} // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: 'badVariadicFunctionWrongLocation' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] +// CHECK-FIXES: template <typename... Ts> LIBC_INLINE void LIBC_INLINE badVariadicFunctionWrongLocation() {} struct NoTemplate { void goodNoTemplate(); @@ -137,22 +147,27 @@ inline void NoTemplate::badNoTemplate() {} // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: 'badNoTemplate' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] +// CHECK-FIXES: LIBC_INLINE inline void NoTemplate::badNoTemplate() {} void LIBC_INLINE NoTemplate::badNoTemplateWrongLocation() {} // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: 'badNoTemplateWrongLocation' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] +// CHECK-FIXES: LIBC_INLINE void LIBC_INLINE NoTemplate::badNoTemplateWrongLocation() {} template <typename T> LIBC_INLINE void NoTemplate::goodNestedTemplate() {} template <typename T> inline void NoTemplate::badNestedTemplate() {} // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: 'badNestedTemplate' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] +// CHECK-FIXES: template <typename T> LIBC_INLINE inline void NoTemplate::badNestedTemplate() {} template <typename T> void LIBC_INLINE NoTemplate::badNestedTemplateWrongLocation() {} // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: 'badNestedTemplateWrongLocation' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] +// CHECK-FIXES: template <typename T> LIBC_INLINE void LIBC_INLINE NoTemplate::badNestedTemplateWrongLocation() {} template <typename... Ts> LIBC_INLINE void NoTemplate::goodVariadicTemplate() {} template <typename... Ts> void inline NoTemplate::badVariadicTemplate() {} // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: 'badVariadicTemplate' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] +// CHECK-FIXES: template <typename... Ts> LIBC_INLINE void inline NoTemplate::badVariadicTemplate() {} template <typename... Ts> void LIBC_INLINE NoTemplate::badVariadicTemplateWrongLocation() {} // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: 'badVariadicTemplateWrongLocation' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] @@ -182,6 +197,7 @@ template <typename T> inline void SimpleTemplate<T>::badSimpleTemplate() {} // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: 'badSimpleTemplate' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] +// CHECK-FIXES: template <typename T> LIBC_INLINE inline void SimpleTemplate<T>::badSimpleTemplate() {} template <typename T> void LIBC_INLINE SimpleTemplate<T>::badSimpleTemplateWrongLocation() {} // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: 'badSimpleTemplateWrongLocation' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] @@ -190,6 +206,7 @@ template <typename T> template <typename U> inline void SimpleTemplate<T>::badNestedTemplate() {} // CHECK-MESSAGES: :[[@LINE-1]]:45: warning: 'badNestedTemplate' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] +// CHECK-FIXES: template <typename T> template <typename U> LIBC_INLINE inline void SimpleTemplate<T>::badNestedTemplate() {} template <typename T> template <typename U> void LIBC_INLINE SimpleTemplate<T>::badNestedTemplateWrongLocation() {} // CHECK-MESSAGES: :[[@LINE-1]]:45: warning: 'badNestedTemplateWrongLocation' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] @@ -198,6 +215,7 @@ template <typename T> template <typename... Ts> inline void SimpleTemplate<T>::badNestedVariadicTemplate() {} // CHECK-MESSAGES: :[[@LINE-1]]:49: warning: 'badNestedVariadicTemplate' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] +// CHECK-FIXES: template <typename T> template <typename... Ts> LIBC_INLINE inline void SimpleTemplate<T>::badNestedVariadicTemplate() {} template <typename T> template <typename... Ts> void LIBC_INLINE SimpleTemplate<T>::badNestedVariadicTemplateWrongLocation() {} // CHECK-MESSAGES: :[[@LINE-1]]:49: warning: 'badNestedVariadicTemplateWrongLocation' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] @@ -227,6 +245,7 @@ template <typename... Ts> inline void VariadicTemplate<Ts...>::badVariadicTemplate() {} // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: 'badVariadicTemplate' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] +// CHECK-FIXES: template <typename... Ts> LIBC_INLINE inline void VariadicTemplate<Ts...>::badVariadicTemplate() {} template <typename... Ts> void LIBC_INLINE VariadicTemplate<Ts...>::badVariadicTemplateWrongLocation() {} // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: 'badVariadicTemplateWrongLocation' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] @@ -235,6 +254,7 @@ template <typename... Ts> template <typename U> inline void VariadicTemplate<Ts...>::badNestedTemplate() {} // CHECK-MESSAGES: :[[@LINE-1]]:49: warning: 'badNestedTemplate' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] +// CHECK-FIXES: template <typename... Ts> template <typename U> LIBC_INLINE inline void VariadicTemplate<Ts...>::badNestedTemplate() {} template <typename... Ts> template <typename U> void LIBC_INLINE VariadicTemplate<Ts...>::badNestedTemplateWrongLocation() {} // CHECK-MESSAGES: :[[@LINE-1]]:49: warning: 'badNestedTemplateWrongLocation' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] @@ -243,6 +263,7 @@ template <typename... Ts> template <typename... Us> inline void VariadicTemplate<Ts...>::badNestedVariadicTemplate() {} // CHECK-MESSAGES: :[[@LINE-1]]:53: warning: 'badNestedVariadicTemplate' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] +// CHECK-FIXES: template <typename... Ts> template <typename... Us> LIBC_INLINE inline void VariadicTemplate<Ts...>::badNestedVariadicTemplate() {} template <typename... Ts> template <typename... Us> void LIBC_INLINE VariadicTemplate<Ts...>::badNestedVariadicTemplateWrongLocation() {} // CHECK-MESSAGES: :[[@LINE-1]]:53: warning: 'badNestedVariadicTemplateWrongLocation' must be tagged with the LIBC_INLINE macro; the macro should be placed at the beginning of the declaration [llvmlibc-inline-function-decl] Index: clang-tools-extra/clang-tidy/llvmlibc/InlineFunctionDeclCheck.cpp =================================================================== --- clang-tools-extra/clang-tidy/llvmlibc/InlineFunctionDeclCheck.cpp +++ clang-tools-extra/clang-tidy/llvmlibc/InlineFunctionDeclCheck.cpp @@ -88,7 +88,7 @@ diag(SrcBegin, "%0 must be tagged with the LIBC_INLINE macro; the macro " "should be placed at the beginning of the declaration") - << FuncDecl; + << FuncDecl << FixItHint::CreateInsertion(Loc, "LIBC_INLINE "); } } // namespace clang::tidy::llvm_libc
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits