[llvm] r348729 - Adding an STL-like type trait that is duplicated in multiple places in Clang.

Aaron Ballman via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 9 11:53:15 PST 2018


Author: aaronballman
Date: Sun Dec  9 11:53:15 2018
New Revision: 348729

URL: http://llvm.org/viewvc/llvm-project?rev=348729&view=rev
Log:
Adding an STL-like type trait that is duplicated in multiple places in Clang.

This trait is used by several AST visitor classes to control whether the AST is visiting const nodes or non-const nodes. These uses cannot be easily replaced with the STL traits directly due to use of an unspecialized templated when a type is expected (due to the template template parameter involved).


Modified:
    llvm/trunk/include/llvm/ADT/STLExtras.h

Modified: llvm/trunk/include/llvm/ADT/STLExtras.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/STLExtras.h?rev=348729&r1=348728&r2=348729&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/STLExtras.h (original)
+++ llvm/trunk/include/llvm/ADT/STLExtras.h Sun Dec  9 11:53:15 2018
@@ -71,6 +71,9 @@ template <typename B1, typename... Bn>
 struct conjunction<B1, Bn...>
     : std::conditional<bool(B1::value), conjunction<Bn...>, B1>::type {};
 
+template <typename T> struct make_const_ptr {
+  using type = std::add_pointer_t<std::add_const_t<T>>;
+};
 //===----------------------------------------------------------------------===//
 //     Extra additions to <functional>
 //===----------------------------------------------------------------------===//




More information about the llvm-commits mailing list