r348730 - Move the make_const_ptr trait into STLExtras; use add_pointer where possible; NFC.

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


Author: aaronballman
Date: Sun Dec  9 11:53:24 2018
New Revision: 348730

URL: http://llvm.org/viewvc/llvm-project?rev=348730&view=rev
Log:
Move the make_const_ptr trait into STLExtras; use add_pointer where possible; NFC.

Modified:
    cfe/trunk/include/clang/AST/CommentVisitor.h
    cfe/trunk/include/clang/AST/DeclVisitor.h
    cfe/trunk/include/clang/AST/EvaluatedExprVisitor.h
    cfe/trunk/include/clang/AST/StmtVisitor.h

Modified: cfe/trunk/include/clang/AST/CommentVisitor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/CommentVisitor.h?rev=348730&r1=348729&r2=348730&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/CommentVisitor.h (original)
+++ cfe/trunk/include/clang/AST/CommentVisitor.h Sun Dec  9 11:53:24 2018
@@ -11,14 +11,11 @@
 #define LLVM_CLANG_AST_COMMENTVISITOR_H
 
 #include "clang/AST/Comment.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/ErrorHandling.h"
 
 namespace clang {
 namespace comments {
-
-template <typename T> struct make_ptr { using type = T *; };
-template <typename T> struct make_const_ptr { using type = const T *; };
-
 template <template <typename> class Ptr, typename ImplClass,
           typename RetTy = void, class... ParamTys>
 class CommentVisitorBase {
@@ -59,13 +56,13 @@ public:
 };
 
 template <typename ImplClass, typename RetTy = void, class... ParamTys>
-class CommentVisitor
-    : public CommentVisitorBase<make_ptr, ImplClass, RetTy, ParamTys...> {};
+class CommentVisitor : public CommentVisitorBase<std::add_pointer, ImplClass,
+                                                 RetTy, ParamTys...> {};
 
 template <typename ImplClass, typename RetTy = void, class... ParamTys>
 class ConstCommentVisitor
-    : public CommentVisitorBase<make_const_ptr, ImplClass, RetTy, ParamTys...> {
-};
+    : public CommentVisitorBase<llvm::make_const_ptr, ImplClass, RetTy,
+                                ParamTys...> {};
 
 } // namespace comments
 } // namespace clang

Modified: cfe/trunk/include/clang/AST/DeclVisitor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclVisitor.h?rev=348730&r1=348729&r2=348730&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclVisitor.h (original)
+++ cfe/trunk/include/clang/AST/DeclVisitor.h Sun Dec  9 11:53:24 2018
@@ -21,15 +21,12 @@
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/DeclOpenMP.h"
 #include "clang/AST/DeclTemplate.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/ErrorHandling.h"
 
 namespace clang {
 
 namespace declvisitor {
-
-template <typename T> struct make_ptr { using type = T *; };
-template <typename T> struct make_const_ptr { using type = const T *; };
-
 /// A simple visitor class that helps create declaration visitors.
 template<template <typename> class Ptr, typename ImplClass, typename RetTy=void>
 class Base {
@@ -66,16 +63,16 @@ public:
 ///
 /// This class does not preserve constness of Decl pointers (see also
 /// ConstDeclVisitor).
-template<typename ImplClass, typename RetTy = void>
+template <typename ImplClass, typename RetTy = void>
 class DeclVisitor
- : public declvisitor::Base<declvisitor::make_ptr, ImplClass, RetTy> {};
+    : public declvisitor::Base<std::add_pointer, ImplClass, RetTy> {};
 
 /// A simple visitor class that helps create declaration visitors.
 ///
 /// This class preserves constness of Decl pointers (see also DeclVisitor).
-template<typename ImplClass, typename RetTy = void>
+template <typename ImplClass, typename RetTy = void>
 class ConstDeclVisitor
- : public declvisitor::Base<declvisitor::make_const_ptr, ImplClass, RetTy> {};
+    : public declvisitor::Base<llvm::make_const_ptr, ImplClass, RetTy> {};
 
 } // namespace clang
 

Modified: cfe/trunk/include/clang/AST/EvaluatedExprVisitor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/EvaluatedExprVisitor.h?rev=348730&r1=348729&r2=348730&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/EvaluatedExprVisitor.h (original)
+++ cfe/trunk/include/clang/AST/EvaluatedExprVisitor.h Sun Dec  9 11:53:24 2018
@@ -19,6 +19,7 @@
 #include "clang/AST/Expr.h"
 #include "clang/AST/ExprCXX.h"
 #include "clang/AST/StmtVisitor.h"
+#include "llvm/ADT/STLExtras.h"
 
 namespace clang {
 
@@ -107,23 +108,22 @@ public:
 };
 
 /// EvaluatedExprVisitor - This class visits 'Expr *'s
-template<typename ImplClass>
+template <typename ImplClass>
 class EvaluatedExprVisitor
- : public EvaluatedExprVisitorBase<make_ptr, ImplClass> {
+    : public EvaluatedExprVisitorBase<std::add_pointer, ImplClass> {
 public:
-  explicit EvaluatedExprVisitor(const ASTContext &Context) :
-    EvaluatedExprVisitorBase<make_ptr, ImplClass>(Context) { }
+  explicit EvaluatedExprVisitor(const ASTContext &Context)
+      : EvaluatedExprVisitorBase<std::add_pointer, ImplClass>(Context) {}
 };
 
 /// ConstEvaluatedExprVisitor - This class visits 'const Expr *'s.
-template<typename ImplClass>
+template <typename ImplClass>
 class ConstEvaluatedExprVisitor
- : public EvaluatedExprVisitorBase<make_const_ptr, ImplClass> {
+    : public EvaluatedExprVisitorBase<llvm::make_const_ptr, ImplClass> {
 public:
-  explicit ConstEvaluatedExprVisitor(const ASTContext &Context) :
-    EvaluatedExprVisitorBase<make_const_ptr, ImplClass>(Context) { }
+  explicit ConstEvaluatedExprVisitor(const ASTContext &Context)
+      : EvaluatedExprVisitorBase<llvm::make_const_ptr, ImplClass>(Context) {}
 };
-
 }
 
 #endif // LLVM_CLANG_AST_EVALUATEDEXPRVISITOR_H

Modified: cfe/trunk/include/clang/AST/StmtVisitor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtVisitor.h?rev=348730&r1=348729&r2=348730&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/StmtVisitor.h (original)
+++ cfe/trunk/include/clang/AST/StmtVisitor.h Sun Dec  9 11:53:24 2018
@@ -22,15 +22,12 @@
 #include "clang/AST/StmtObjC.h"
 #include "clang/AST/StmtOpenMP.h"
 #include "clang/Basic/LLVM.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/ErrorHandling.h"
 #include <utility>
 
 namespace clang {
-
-template <typename T> struct make_ptr { using type = T *; };
-template <typename T> struct make_const_ptr { using type = const T *; };
-
 /// StmtVisitorBase - This class implements a simple visitor for Stmt
 /// subclasses. Since Expr derives from Stmt, this also includes support for
 /// visiting Exprs.
@@ -182,18 +179,19 @@ public:
 ///
 /// This class does not preserve constness of Stmt pointers (see also
 /// ConstStmtVisitor).
-template<typename ImplClass, typename RetTy=void, typename... ParamTys>
+template <typename ImplClass, typename RetTy = void, typename... ParamTys>
 class StmtVisitor
- : public StmtVisitorBase<make_ptr, ImplClass, RetTy, ParamTys...> {};
+    : public StmtVisitorBase<std::add_pointer, ImplClass, RetTy, ParamTys...> {
+};
 
 /// ConstStmtVisitor - This class implements a simple visitor for Stmt
 /// subclasses. Since Expr derives from Stmt, this also includes support for
 /// visiting Exprs.
 ///
 /// This class preserves constness of Stmt pointers (see also StmtVisitor).
-template<typename ImplClass, typename RetTy=void, typename... ParamTys>
-class ConstStmtVisitor
- : public StmtVisitorBase<make_const_ptr, ImplClass, RetTy, ParamTys...> {};
+template <typename ImplClass, typename RetTy = void, typename... ParamTys>
+class ConstStmtVisitor : public StmtVisitorBase<llvm::make_const_ptr, ImplClass,
+                                                RetTy, ParamTys...> {};
 
 } // namespace clang
 




More information about the cfe-commits mailing list