[PATCH] D157164: [clang-tidy] Add fix-it support to `llvmlibc-inline-function-decl`

2023-08-07 Thread Roland McGrath via Phabricator via cfe-commits
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 ) {
 return RHS.A == A;
@@ -42,6 +46,7 @@
 
   static int getVal(const MyClass ) {
   // 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 ) {
 return V.A;
   }
 
@@ -51,6 +56,7 @@
 
   constexpr static int addInt(MyClass , 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 , 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  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  LIBC_INLINE inline void badTemplateFunction() {}
 
 template  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  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  LIBC_INLINE inline void badVariadicFunction() {}
 
 template  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  LIBC_INLINE void LIBC_INLINE badVariadicFunctionWrongLocation() {}
 
 struct 

[PATCH] D157164: [clang-tidy] Add fix-it support to `llvmlibc-inline-function-decl`

2023-08-07 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL added a comment.

Release notes are missing.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157164/new/

https://reviews.llvm.org/D157164

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D157164: [clang-tidy] Add fix-it support to `llvmlibc-inline-function-decl`

2023-08-04 Thread Roland McGrath via Phabricator via cfe-commits
mcgrathr created this revision.
mcgrathr added reviewers: abrachet, Caslyn, sivachandra, michaelrj.
Herald added subscribers: PiotrZSL, carlosgalvezp, xazax.hun.
Herald added a reviewer: njames93.
Herald added a project: All.
mcgrathr requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

This is very simplistic and could be more thorough by replacing
an existing `LIBC_INLINE` in the wrong location or a redunant
`inline` when inserting the right macro use.  But as is this
suffices to automatically apply fixes for most or all of the
instances in the libc tree today and get working results (despite
some superfluous `inline` keywords left behind).


Repository:
  rG LLVM Github Monorepo

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 ) {
 return RHS.A == A;
@@ -42,6 +46,7 @@
 
   static int getVal(const MyClass ) {
   // 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 ) {
 return V.A;
   }
 
@@ -51,6 +56,7 @@
 
   constexpr static int addInt(MyClass , 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 , 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  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  LIBC_INLINE inline void badTemplateFunction() {}
 
 template  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  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: