From 0c411806d540f7158bf12fee5c10f7de2647de76 Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Tue, 29 Sep 2009 21:27:32 +0000 Subject: [PATCH] Pull TypeLocVisitor into its own header file. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83112 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/AST/TypeLoc.h | 36 ------------------- include/clang/AST/TypeLocVisitor.h | 58 ++++++++++++++++++++++++++++++ lib/AST/TypeLoc.cpp | 2 +- lib/Frontend/PCHReaderDecl.cpp | 2 +- lib/Frontend/PCHWriterDecl.cpp | 2 +- lib/Index/ASTVisitor.h | 2 +- lib/Index/ResolveLocation.cpp | 2 +- 7 files changed, 63 insertions(+), 41 deletions(-) create mode 100644 include/clang/AST/TypeLocVisitor.h diff --git a/include/clang/AST/TypeLoc.h b/include/clang/AST/TypeLoc.h index 100003929d..a6184375e0 100644 --- a/include/clang/AST/TypeLoc.h +++ b/include/clang/AST/TypeLoc.h @@ -15,7 +15,6 @@ #define LLVM_CLANG_AST_TYPELOC_H #include "clang/AST/Type.h" -#include "clang/AST/TypeVisitor.h" namespace clang { class ParmVarDecl; @@ -534,41 +533,6 @@ public: static bool classof(const ArrayLoc *TL) { return true; } }; -#define DISPATCH(CLASS) \ - return static_cast(this)->Visit ## CLASS(cast(TyLoc)) - -template -class TypeLocVisitor { - class TypeDispatch : public TypeVisitor { - ImplClass *Impl; - TypeLoc TyLoc; - - public: - TypeDispatch(ImplClass *impl, TypeLoc &tyLoc) : Impl(impl), TyLoc(tyLoc) { } -#define ABSTRACT_TYPELOC(CLASS) -#define TYPELOC(CLASS, PARENT, TYPE) \ - RetTy Visit##TYPE(TYPE *) { \ - return Impl->Visit##CLASS(reinterpret_cast(TyLoc)); \ - } -#include "clang/AST/TypeLocNodes.def" - }; - -public: - RetTy Visit(TypeLoc TyLoc) { - TypeDispatch TD(static_cast(this), TyLoc); - return TD.Visit(TyLoc.getSourceType().getTypePtr()); - } - -#define TYPELOC(CLASS, PARENT, TYPE) RetTy Visit##CLASS(CLASS TyLoc) { \ - DISPATCH(PARENT); \ -} -#include "clang/AST/TypeLocNodes.def" - - RetTy VisitTypeLoc(TypeLoc TyLoc) { return RetTy(); } -}; - -#undef DISPATCH - } #endif diff --git a/include/clang/AST/TypeLocVisitor.h b/include/clang/AST/TypeLocVisitor.h new file mode 100644 index 0000000000..df386cab6f --- /dev/null +++ b/include/clang/AST/TypeLocVisitor.h @@ -0,0 +1,58 @@ +//===--- TypeLocVisitor.h - Visitor for TypeLoc subclasses ------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file defines the TypeLocVisitor interface. +// +//===----------------------------------------------------------------------===// +#ifndef LLVM_CLANG_AST_TYPELOCVISITOR_H +#define LLVM_CLANG_AST_TYPELOCVISITOR_H + +#include "clang/AST/TypeLoc.h" +#include "clang/AST/TypeVisitor.h" + +namespace clang { + +#define DISPATCH(CLASS) \ + return static_cast(this)->Visit ## CLASS(cast(TyLoc)) + +template +class TypeLocVisitor { + class TypeDispatch : public TypeVisitor { + ImplClass *Impl; + TypeLoc TyLoc; + + public: + TypeDispatch(ImplClass *impl, TypeLoc &tyLoc) : Impl(impl), TyLoc(tyLoc) { } +#define ABSTRACT_TYPELOC(CLASS) +#define TYPELOC(CLASS, PARENT, TYPE) \ + RetTy Visit##TYPE(TYPE *) { \ + return Impl->Visit##CLASS(reinterpret_cast(TyLoc)); \ + } +#include "clang/AST/TypeLocNodes.def" + }; + +public: + RetTy Visit(TypeLoc TyLoc) { + TypeDispatch TD(static_cast(this), TyLoc); + return TD.Visit(TyLoc.getSourceType().getTypePtr()); + } + +#define TYPELOC(CLASS, PARENT, TYPE) RetTy Visit##CLASS(CLASS TyLoc) { \ + DISPATCH(PARENT); \ +} +#include "clang/AST/TypeLocNodes.def" + + RetTy VisitTypeLoc(TypeLoc TyLoc) { return RetTy(); } +}; + +#undef DISPATCH + +} // end namespace clang + +#endif // LLVM_CLANG_AST_TYPELOCVISITOR_H diff --git a/lib/AST/TypeLoc.cpp b/lib/AST/TypeLoc.cpp index 1337def2a0..c24477ae81 100644 --- a/lib/AST/TypeLoc.cpp +++ b/lib/AST/TypeLoc.cpp @@ -11,7 +11,7 @@ // //===----------------------------------------------------------------------===// -#include "clang/AST/TypeLoc.h" +#include "clang/AST/TypeLocVisitor.h" using namespace clang; //===----------------------------------------------------------------------===// diff --git a/lib/Frontend/PCHReaderDecl.cpp b/lib/Frontend/PCHReaderDecl.cpp index 9b28e8bac7..353a6464b1 100644 --- a/lib/Frontend/PCHReaderDecl.cpp +++ b/lib/Frontend/PCHReaderDecl.cpp @@ -18,7 +18,7 @@ #include "clang/AST/DeclVisitor.h" #include "clang/AST/DeclGroup.h" #include "clang/AST/Expr.h" -#include "clang/AST/TypeLoc.h" +#include "clang/AST/TypeLocVisitor.h" using namespace clang; diff --git a/lib/Frontend/PCHWriterDecl.cpp b/lib/Frontend/PCHWriterDecl.cpp index 9573d43c71..4527bb1f90 100644 --- a/lib/Frontend/PCHWriterDecl.cpp +++ b/lib/Frontend/PCHWriterDecl.cpp @@ -14,7 +14,7 @@ #include "clang/Frontend/PCHWriter.h" #include "clang/AST/DeclVisitor.h" #include "clang/AST/Expr.h" -#include "clang/AST/TypeLoc.h" +#include "clang/AST/TypeLocVisitor.h" #include "llvm/Bitcode/BitstreamWriter.h" #include diff --git a/lib/Index/ASTVisitor.h b/lib/Index/ASTVisitor.h index 4da1888095..e18aa57b4d 100644 --- a/lib/Index/ASTVisitor.h +++ b/lib/Index/ASTVisitor.h @@ -16,7 +16,7 @@ #include "clang/AST/DeclVisitor.h" #include "clang/AST/StmtVisitor.h" -#include "clang/AST/TypeLoc.h" +#include "clang/AST/TypeLocVisitor.h" namespace clang { diff --git a/lib/Index/ResolveLocation.cpp b/lib/Index/ResolveLocation.cpp index 633ed0590e..229669dc33 100644 --- a/lib/Index/ResolveLocation.cpp +++ b/lib/Index/ResolveLocation.cpp @@ -14,7 +14,7 @@ #include "clang/Index/Utils.h" #include "clang/Index/ASTLocation.h" -#include "clang/AST/TypeLoc.h" +#include "clang/AST/TypeLocVisitor.h" #include "clang/AST/DeclVisitor.h" #include "clang/AST/StmtVisitor.h" #include "clang/Lex/Lexer.h"