Re: [PATCH] D18191: [clang-tidy] Add check for function parameters that are const& to builtin types

2016-04-04 Thread Steve Downey via cfe-commits
sdowney added a comment.

At least in my codebase, skipping templates is too strong. I run across ones 
where the const& parameter is not one controlled by a template. It's often a 
size_t.

I could easily see not fixing the typedef'd refs, also, although I think 
warning on them is still useful. Particularly if they can then be added to a 
list to be changed. E.g. size_t.


http://reviews.llvm.org/D18191



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


Re: [PATCH] D18191: [clang-tidy] Add check for function parameters that are const& to builtin types

2016-03-19 Thread Steve Downey via cfe-commits
sdowney updated this revision to Diff 50986.
sdowney added a comment.

Add tests with functions generated with MACROS


http://reviews.llvm.org/D18191

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/ConstRefBuiltinCheck.cpp
  clang-tidy/misc/ConstRefBuiltinCheck.h
  clang-tidy/misc/MiscTidyModule.cpp
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-const-ref-builtin.rst
  test/clang-tidy/misc-const-ref-builtin.cpp

Index: test/clang-tidy/misc-const-ref-builtin.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-const-ref-builtin.cpp
@@ -0,0 +1,103 @@
+// RUN: %check_clang_tidy %s misc-const-ref-builtin %t
+
+void f(const int& i);
+// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: const reference to 'int' at parameter 'i' in function 'f' [misc-const-ref-builtin]
+
+void f(const int& i) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: const reference to 'int' at parameter 'i' in function 'f' [misc-const-ref-builtin]
+  int k = i;
+}
+
+void f2(const int&);
+// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: const reference to 'int' type at index '0' in function 'f2' [misc-const-ref-builtin]
+
+void f2(const int& i) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: const reference to 'int' at parameter 'i' in function 'f2' [misc-const-ref-builtin]
+  int k = i;
+}
+
+typedef int Int;
+void t(const Int& i);
+// CHECK-MESSAGES: :[[@LINE-1]]:19:  warning: const reference to 'Int' (aka 'int') at parameter 'i' in function 't' [misc-const-ref-builtin]
+
+void t(const Int& i) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:19:  warning: const reference to 'Int' (aka 'int') at parameter 'i' in function 't' [misc-const-ref-builtin]
+  int k = i;
+}
+
+//Function template
+template
+void g(const T& t_) {
+  T t = t_;
+}
+
+// Explicit Specialization
+template<>
+void g(const long& l) {
+  //CHECK-MESSAGES: :[[@LINE-1]]:26: warning: const reference to 'long' at parameter 'l' in function 'g' [misc-const-ref-builtin]
+  long i = l;
+}
+
+
+// Explicit Specialization (deduced type)
+template<>
+void g(const double& d) {
+  //CHECK-MESSAGES: :[[@LINE-1]]:22:  warning: const reference to 'double' at parameter 'd' in function 'g' [misc-const-ref-builtin]
+ double f = d;
+}
+
+template
+void g2(const T&, const char& c);
+//CHECK-MESSAGES: :[[@LINE-1]]:31: warning: const reference to 'char' at parameter 'c' in function 'g2' [misc-const-ref-builtin]
+
+template
+class Klass {
+public:
+  void k(const T& t);
+  void k2(const short& s);
+  //CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const reference to 'short' at parameter 's' in function 'k2' [misc-const-ref-builtin]
+  void k3(const T& t, const short& s);
+  //CHECK-MESSAGES: :[[@LINE-1]]:36: warning: const reference to 'short' at parameter 's' in function 'k3' [misc-const-ref-builtin]
+};
+
+class K2 {
+public:
+  template
+  void f(const T& t);
+};
+
+class Bar {};
+
+void X() {
+  g(5);
+  g(123.456);
+  g2(5,'a');
+  Klass kbar;
+  K2 k2;
+  k2.f(6);
+};
+
+void f3();
+
+void h(int& i);
+
+void f4(const Bar& bar);
+
+class Baz {
+  int i;
+};
+
+void f5(const Baz& baz);
+
+void f(const int& i, const int& j);
+// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: const reference to 'int' at parameter 'i' in function 'f' [misc-const-ref-builtin]
+// CHECK-MESSAGES: :[[@LINE-2]]:33: warning: const reference to 'int' at parameter 'j' in function 'f' [misc-const-ref-builtin]
+
+#define MAKE_FUNC(Name) void Name(const int& i);
+
+MAKE_FUNC(test1);
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: const reference to 'int' at parameter 'i' in function 'test1' [misc-const-ref-builtin]
+
+#define MAKE_FUNC2(Name, ArgType) void Name(const ArgType& i);
+MAKE_FUNC2(test2, int);
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: const reference to 'int' at parameter 'i' in function 'test2' [misc-const-ref-builtin]
Index: docs/clang-tidy/checks/misc-const-ref-builtin.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/misc-const-ref-builtin.rst
@@ -0,0 +1,28 @@
+.. title:: clang-tidy - misc-const-ref-builtin
+
+misc-const-ref-builtin
+==
+
+This check will warn about function arguments that are const refs to builtin
+types, such as int or double. It will also warn about const refs to typedefs to
+builtin types. It will not flag function arguments that are due to template
+instantiations.
+
+Example code::
+
+  void f(const int& i);
+
+
+The parameter i will be flagged.
+
+Example code::
+
+  template
+  void g(const T&);
+
+  void X() {
+  g(5);
+  }
+
+
+The instantiation of g will not be flagged.
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -48,6 +48,7 @@
misc-assert-side-effect
misc-assign-operator-signature
misc-bool-pointer-implicit-conversion
+   misc-const-ref-builtin
misc-definitions-in-headers

Re: [PATCH] D18191: [clang-tidy] Add check for function parameters that are const& to builtin types

2016-03-19 Thread Steve Downey via cfe-commits
sdowney updated this revision to Diff 51000.
sdowney added a comment.

Add tests for FixIts


http://reviews.llvm.org/D18191

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/ConstRefBuiltinCheck.cpp
  clang-tidy/misc/ConstRefBuiltinCheck.h
  clang-tidy/misc/MiscTidyModule.cpp
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-const-ref-builtin.rst
  test/clang-tidy/misc-const-ref-builtin.cpp

Index: test/clang-tidy/misc-const-ref-builtin.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-const-ref-builtin.cpp
@@ -0,0 +1,119 @@
+// RUN: %check_clang_tidy %s misc-const-ref-builtin %t
+
+void f(const int& i);
+// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: const reference to 'int' at parameter 'i' in function 'f' [misc-const-ref-builtin]
+// CHECK-FIXES: void f(int i);
+
+void f(const int& i) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: const reference to 'int' at parameter 'i' in function 'f' [misc-const-ref-builtin]
+  // CHECK-FIXES: void f(int i) {
+  int k = i;
+}
+
+void f2(const int&);
+// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: const reference to 'int' type at index '0' in function 'f2' [misc-const-ref-builtin]
+// CHECK-FIXES: void f2(int)
+
+void f2(const int& i) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: const reference to 'int' at parameter 'i' in function 'f2' [misc-const-ref-builtin]
+  // CHECK-FIXES: void f2(int i) {
+  int k = i;
+}
+
+typedef int Int;
+void t(const Int& i);
+// CHECK-MESSAGES: :[[@LINE-1]]:19:  warning: const reference to 'Int' (aka 'int') at parameter 'i' in function 't' [misc-const-ref-builtin]
+// CHECK-FIXES: void t(Int i)
+
+void t(const Int& i) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:19:  warning: const reference to 'Int' (aka 'int') at parameter 'i' in function 't' [misc-const-ref-builtin]
+  // CHECK-FIXES: void t(Int i) {
+  int k = i;
+}
+
+//Function template
+template
+void g(const T& t_) {
+  T t = t_;
+}
+
+// Explicit Specialization
+template<>
+void g(const long& l) {
+  //CHECK-MESSAGES: :[[@LINE-1]]:26: warning: const reference to 'long' at parameter 'l' in function 'g' [misc-const-ref-builtin]
+  // CHECK-FIXES: void g(long l) {
+  long i = l;
+}
+
+
+// Explicit Specialization (deduced type)
+template<>
+void g(const double& d) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:22:  warning: const reference to 'double' at parameter 'd' in function 'g' [misc-const-ref-builtin]
+  // CHECK-FIXES: void g(double d) {
+
+ double f = d;
+}
+
+template
+void g2(const T&, const char& c);
+// CHECK-MESSAGES: :[[@LINE-1]]:31: warning: const reference to 'char' at parameter 'c' in function 'g2' [misc-const-ref-builtin]
+// CHECK-FIXES: void g2(const T&, char c);
+
+template
+class Klass {
+public:
+  void k(const T& t);
+  void k2(const short& s);
+  // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const reference to 'short' at parameter 's' in function 'k2' [misc-const-ref-builtin]
+  // CHECK-FIXES: void k2(short s);
+
+  void k3(const T& t, const short& s);
+  // CHECK-MESSAGES: :[[@LINE-1]]:36: warning: const reference to 'short' at parameter 's' in function 'k3' [misc-const-ref-builtin]
+  // CHECK-FIXES: void k3(const T& t, short s);
+};
+
+class K2 {
+public:
+  template
+  void f(const T& t);
+};
+
+class Bar {};
+
+void X() {
+  g(5);
+  g(123.456);
+  g2(5,'a');
+  Klass kbar;
+  K2 k2;
+  k2.f(6);
+};
+
+void f3();
+
+void h(int& i);
+
+void f4(const Bar& bar);
+
+class Baz {
+  int i;
+};
+
+void f5(const Baz& baz);
+
+void f(const int& i, const int& j);
+// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: const reference to 'int' at parameter 'i' in function 'f' [misc-const-ref-builtin]
+// CHECK-MESSAGES: :[[@LINE-2]]:33: warning: const reference to 'int' at parameter 'j' in function 'f' [misc-const-ref-builtin]
+// CHECK-FIXES: void f(int i, int j);
+
+#define MAKE_FUNC(Name) void Name(const int& i);
+
+MAKE_FUNC(test1);
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: const reference to 'int' at parameter 'i' in function 'test1' [misc-const-ref-builtin]
+// CHECK-FIXES-NOT: void test1(int i);
+
+#define MAKE_FUNC2(Name, ArgType) void Name(const ArgType& i);
+MAKE_FUNC2(test2, int);
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: const reference to 'int' at parameter 'i' in function 'test2' [misc-const-ref-builtin]
+// CHECK-FIXES-NOT: void test2(int i);
Index: docs/clang-tidy/checks/misc-const-ref-builtin.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/misc-const-ref-builtin.rst
@@ -0,0 +1,28 @@
+.. title:: clang-tidy - misc-const-ref-builtin
+
+misc-const-ref-builtin
+==
+
+This check will warn about function arguments that are const refs to builtin
+types, such as int or double. It will also warn about const refs to typedefs to
+builtin types. It will not flag function arguments that are due to template
+instantiations.
+
+Example code::
+
+  void f(const int& i);
+
+
+The parameter i will be flagged.
+

Re: [PATCH] D18191: [clang-tidy] Add check for function parameters that are const& to builtin types

2016-03-18 Thread Steve Downey via cfe-commits
sdowney updated this revision to Diff 50982.
sdowney added a comment.

Add more test cases, covering templates, template specializations, function 
definitions, member function templates.

Check if parent function of the argument is a nullptr.

Fix spelling mistake.


http://reviews.llvm.org/D18191

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/ConstRefBuiltinCheck.cpp
  clang-tidy/misc/ConstRefBuiltinCheck.h
  clang-tidy/misc/MiscTidyModule.cpp
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-const-ref-builtin.rst
  test/clang-tidy/misc-const-ref-builtin.cpp

Index: test/clang-tidy/misc-const-ref-builtin.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-const-ref-builtin.cpp
@@ -0,0 +1,94 @@
+// RUN: %check_clang_tidy %s misc-const-ref-builtin %t
+
+void f(const int& i);
+// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: const reference to 'int' at parameter 'i' in function 'f' [misc-const-ref-builtin]
+
+void f(const int& i) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: const reference to 'int' at parameter 'i' in function 'f' [misc-const-ref-builtin]
+  int k = i;
+}
+
+void f2(const int&);
+// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: const reference to 'int' type at index '0' in function 'f2' [misc-const-ref-builtin]
+
+void f2(const int& i) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: const reference to 'int' at parameter 'i' in function 'f2' [misc-const-ref-builtin]
+  int k = i;
+}
+
+typedef int Int;
+void t(const Int& i);
+// CHECK-MESSAGES: :[[@LINE-1]]:19:  warning: const reference to 'Int' (aka 'int') at parameter 'i' in function 't' [misc-const-ref-builtin]
+
+void t(const Int& i) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:19:  warning: const reference to 'Int' (aka 'int') at parameter 'i' in function 't' [misc-const-ref-builtin]
+  int k = i;
+}
+
+//Function template
+template
+void g(const T& t_) {
+  T t = t_;
+}
+
+// Explicit Specialization
+template<>
+void g(const long& l) {
+  //CHECK-MESSAGES: :[[@LINE-1]]:26: warning: const reference to 'long' at parameter 'l' in function 'g' [misc-const-ref-builtin]
+  long i = l;
+}
+
+
+// Explicit Specialization (deduced type)
+template<>
+void g(const double& d) {
+  //CHECK-MESSAGES: :[[@LINE-1]]:22:  warning: const reference to 'double' at parameter 'd' in function 'g' [misc-const-ref-builtin]
+ double f = d;
+}
+
+template
+void g2(const T&, const char& c);
+//CHECK-MESSAGES: :[[@LINE-1]]:31: warning: const reference to 'char' at parameter 'c' in function 'g2' [misc-const-ref-builtin]
+
+template
+class Klass {
+public:
+  void k(const T& t);
+  void k2(const short& s);
+  //CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const reference to 'short' at parameter 's' in function 'k2' [misc-const-ref-builtin]
+  void k3(const T& t, const short& s);
+  //CHECK-MESSAGES: :[[@LINE-1]]:36: warning: const reference to 'short' at parameter 's' in function 'k3' [misc-const-ref-builtin]
+};
+
+class K2 {
+public:
+  template
+  void f(const T& t);
+};
+
+class Bar {};
+
+void X() {
+  g(5);
+  g(123.456);
+  g2(5,'a');
+  Klass kbar;
+  K2 k2;
+  k2.f(6);
+};
+
+void f3();
+
+void h(int& i);
+
+void f4(const Bar& bar);
+
+class Baz {
+  int i;
+};
+
+void f5(const Baz& baz);
+
+void f(const int& i, const int& j);
+// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: const reference to 'int' at parameter 'i' in function 'f' [misc-const-ref-builtin]
+// CHECK-MESSAGES: :[[@LINE-2]]:33: warning: const reference to 'int' at parameter 'j' in function 'f' [misc-const-ref-builtin]
Index: docs/clang-tidy/checks/misc-const-ref-builtin.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/misc-const-ref-builtin.rst
@@ -0,0 +1,28 @@
+.. title:: clang-tidy - misc-const-ref-builtin
+
+misc-const-ref-builtin
+==
+
+This check will warn about function arguments that are const refs to builtin
+types, such as int or double. It will also warn about const refs to typedefs to
+builtin types. It will not flag function arguments that are due to template
+instantiations.
+
+Example code::
+
+  void f(const int& i);
+
+
+The parameter i will be flagged.
+
+Example code::
+
+  template
+  void g(const T&);
+
+  void X() {
+  g(5);
+  }
+
+
+The instantiation of g will not be flagged.
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -48,6 +48,7 @@
misc-assert-side-effect
misc-assign-operator-signature
misc-bool-pointer-implicit-conversion
+   misc-const-ref-builtin
misc-definitions-in-headers
misc-inaccurate-erase
misc-incorrect-roundings
Index: clang-tidy/misc/MiscTidyModule.cpp
===
--- clang-tidy/misc/MiscTidyModule.cpp
+++ clang-tidy/misc/MiscTidyModule.cpp
@@ -14,6 +14,7 @@
 #include 

Re: [PATCH] D18191: [clang-tidy] Add check for function parameters that are const& to builtin types

2016-03-18 Thread Steve Downey via cfe-commits
sdowney added a comment.

In http://reviews.llvm.org/D18191#376471, @LegalizeAdulthood wrote:

> There is utility in the definition of a function in saying that an argument 
> is `const int i` instead of `int i`.  The const-ness declares the intent that 
> this local variable is not going to be modified.  However, there is that 
> oddity in C++ that allows a declaration to say `void f(int i);` and the 
> implementation to say `void f(const int i) { ... }`.
>
> I think I would like the fixit to preserve the const-ness of the argument 
> while still stripping it of it's reference.


The usual pattern for that is to have the definition use const, and the 
declaration not, since it's an implementation detail if the passed parameter is 
modified. And, unfortunately, I'm stuck with one compiler that mangles those 
two differently, causing link errors.

Having void foo(const int i) in a declaration makes me suspicious, since the 
const is meaningless.

I could make this an option? If the option is set, emit 'const type' if the 
Decl hasBody?


http://reviews.llvm.org/D18191



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


[PATCH] D18191: [clang-tidy] Add check for function parameters that are const& to builtin types

2016-03-15 Thread Steve Downey via cfe-commits
sdowney created this revision.
sdowney added a reviewer: alexfh.
sdowney added a subscriber: cfe-commits.

Add a check for const& to builtin types. Add FixIt replacing, for example, 
'const& int i' with 'int i'.

http://reviews.llvm.org/D18191

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/ConstRefBuiltinCheck.cpp
  clang-tidy/misc/ConstRefBuiltinCheck.h
  clang-tidy/misc/MiscTidyModule.cpp
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-const-ref-builtin.rst
  test/clang-tidy/misc-const-ref-builtin.cpp

Index: test/clang-tidy/misc-const-ref-builtin.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-const-ref-builtin.cpp
@@ -0,0 +1,34 @@
+// RUN: %check_clang_tidy %s misc-const-ref-builtin %t
+
+void f(const int& i);
+// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: const reference to 'int' at parameter 'i' in function 'f' [misc-const-ref-builtin]
+
+void f2(const int&);
+// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: const reference to 'int' type at index '0' in function 'f2' [misc-const-ref-builtin]
+
+typedef int Int;
+void t(const Int& i);
+// CHECK-MESSAGES: :[[@LINE-1]]:19:  warning: const reference to 'Int' (aka 'int') at parameter 'i' in function 't' [misc-const-ref-builtin]
+
+template
+void g(const T&);
+
+void X() {
+  g(5);
+}
+
+void f3();
+
+void h(int& i);
+
+class Bar {};
+void f4(const Bar& bar);
+
+class Baz {
+  int i;
+};
+void f5(const Baz& baz);
+
+void f(const int& i, const int& j);
+// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: const reference to 'int' at parameter 'i' in function 'f' [misc-const-ref-builtin]
+// CHECK-MESSAGES: :[[@LINE-2]]:33: warning: const reference to 'int' at parameter 'j' in function 'f' [misc-const-ref-builtin]
Index: docs/clang-tidy/checks/misc-const-ref-builtin.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/misc-const-ref-builtin.rst
@@ -0,0 +1,28 @@
+.. title:: clang-tidy - misc-const-ref-builtin
+
+misc-const-ref-builtin
+==
+
+This check will warn about function arguments that are const refs to builtin
+types, such as int or double. It will also warn about const refs to typedefs to
+builtin types. It will not flag function arguments that are due to template
+instantiations.
+
+Example code::
+
+  void f(const int& i);
+
+
+The parameter i will be flagged.
+
+Example code::
+
+  template
+  void g(const T&);
+
+  void X() {
+  g(5);
+  }
+
+
+The instantion of g will not be flagged.
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -48,6 +48,7 @@
misc-assert-side-effect
misc-assign-operator-signature
misc-bool-pointer-implicit-conversion
+   misc-const-ref-builtin
misc-definitions-in-headers
misc-inaccurate-erase
misc-incorrect-roundings
Index: clang-tidy/misc/MiscTidyModule.cpp
===
--- clang-tidy/misc/MiscTidyModule.cpp
+++ clang-tidy/misc/MiscTidyModule.cpp
@@ -14,6 +14,7 @@
 #include "AssertSideEffectCheck.h"
 #include "AssignOperatorSignatureCheck.h"
 #include "BoolPointerImplicitConversionCheck.h"
+#include "ConstRefBuiltinCheck.h"
 #include "DefinitionsInHeadersCheck.h"
 #include "InaccurateEraseCheck.h"
 #include "IncorrectRoundings.h"
@@ -53,6 +54,8 @@
 "misc-assign-operator-signature");
 CheckFactories.registerCheck(
 "misc-bool-pointer-implicit-conversion");
+CheckFactories.registerCheck(
+"misc-const-ref-builtin");
 CheckFactories.registerCheck(
 "misc-definitions-in-headers");
 CheckFactories.registerCheck(
Index: clang-tidy/misc/ConstRefBuiltinCheck.h
===
--- /dev/null
+++ clang-tidy/misc/ConstRefBuiltinCheck.h
@@ -0,0 +1,39 @@
+//===--- ConstRefBuiltinCheck.h - clang-tidy-*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_CONST_REF_BUILTIN_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_CONST_REF_BUILTIN_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace misc {
+
+/// Checks for function parameters that are const& to builtin types.
+///
+/// Const reference to builtin type, such as int, adds an unnecessary layer of
+/// indirection. The Check will also warn on const& to typedef to builtin. It
+/// will not warn if the const& paramter was due to template instantiation.
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/misc-const-ref-builtin.html
+class 

Re: [PATCH] D16963: Copy LibASTMatchersReference.html to gen'd docs

2016-02-09 Thread Steve Downey via cfe-commits
sdowney added a subscriber: sdowney.
sdowney added a comment.

I'll push up a review with the one line link addition later. Thanks!

The html copy should also get applied to the release_38 branch too, if
there's going to be another RC.


http://reviews.llvm.org/D16963



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


Re: [PATCH] D16963: Copy LibASTMatchersReference.html to gen'd docs

2016-02-09 Thread Steve Downey via cfe-commits
I'll push up a review with the one line link addition later. Thanks!

The html copy should also get applied to the release_38 branch too, if
there's going to be another RC.

On Tue, Feb 9, 2016 at 11:52 AM Manuel Klimek  wrote:

> klimek added a subscriber: klimek.
> klimek added a comment.
>
> I have fixed that in r260218 for LibASTMatcherReference (basically using
> the same mechanism, but only copying the one file). Not sure which is the
> better approach, I considered globbing, but my gut feeling decided against
> it :)
> Definitely check in the link though.
> Thanks!
>
>
> http://reviews.llvm.org/D16963
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D16963: Copy LibASTMatchersReference.html to gen'd docs

2016-02-07 Thread Steve Downey via cfe-commits
sdowney created this revision.
sdowney added a reviewer: reames.
sdowney added a subscriber: cfe-commits.

The LibASTMatchersReference documentation is an html file, not an rst
document, so is not produced by sphinx. Copy the html into the proper
location as part of the sphinx html doc generation.

Also include a link to the AST Matcher Reference in the index.


http://reviews.llvm.org/D16963

Files:
  docs/CMakeLists.txt
  docs/index.rst

Index: docs/index.rst
===
--- docs/index.rst
+++ docs/index.rst
@@ -52,6 +52,7 @@
RAVFrontendAction
LibASTMatchersTutorial
LibASTMatchers
+   LibASTMatchersReference
HowToSetupToolingForLLVM
JSONCompilationDatabase
 
@@ -84,4 +85,3 @@
 * :ref:`genindex`
 * :ref:`modindex`
 * :ref:`search`
-
Index: docs/CMakeLists.txt
===
--- docs/CMakeLists.txt
+++ docs/CMakeLists.txt
@@ -95,6 +95,8 @@
 include(AddSphinxTarget)
 if (${SPHINX_OUTPUT_HTML})
   add_sphinx_target(html clang)
+  file(GLOB DOC_HTML *.html)
+  file(COPY ${DOC_HTML} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/html)
 endif()
 if (${SPHINX_OUTPUT_MAN})
   add_sphinx_target(man clang)


Index: docs/index.rst
===
--- docs/index.rst
+++ docs/index.rst
@@ -52,6 +52,7 @@
RAVFrontendAction
LibASTMatchersTutorial
LibASTMatchers
+   LibASTMatchersReference
HowToSetupToolingForLLVM
JSONCompilationDatabase
 
@@ -84,4 +85,3 @@
 * :ref:`genindex`
 * :ref:`modindex`
 * :ref:`search`
-
Index: docs/CMakeLists.txt
===
--- docs/CMakeLists.txt
+++ docs/CMakeLists.txt
@@ -95,6 +95,8 @@
 include(AddSphinxTarget)
 if (${SPHINX_OUTPUT_HTML})
   add_sphinx_target(html clang)
+  file(GLOB DOC_HTML *.html)
+  file(COPY ${DOC_HTML} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/html)
 endif()
 if (${SPHINX_OUTPUT_MAN})
   add_sphinx_target(man clang)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits