[cfe-commits] r83112 - in /cfe/trunk: include/clang/AST/TypeLoc.h include/clang/AST/TypeLocVisitor.h lib/AST/TypeLoc.cpp lib/Frontend/PCHReaderDecl.cpp lib/Frontend/PCHWriterDecl.cpp lib/Index/ASTVisitor.h lib/Index/ResolveLocation.cpp

Argiris Kirtzidis akyrtzi at gmail.com
Tue Sep 29 14:27:33 PDT 2009


Author: akirtzidis
Date: Tue Sep 29 16:27:32 2009
New Revision: 83112

URL: http://llvm.org/viewvc/llvm-project?rev=83112&view=rev
Log:
Pull TypeLocVisitor into its own header file.

Added:
    cfe/trunk/include/clang/AST/TypeLocVisitor.h
Modified:
    cfe/trunk/include/clang/AST/TypeLoc.h
    cfe/trunk/lib/AST/TypeLoc.cpp
    cfe/trunk/lib/Frontend/PCHReaderDecl.cpp
    cfe/trunk/lib/Frontend/PCHWriterDecl.cpp
    cfe/trunk/lib/Index/ASTVisitor.h
    cfe/trunk/lib/Index/ResolveLocation.cpp

Modified: cfe/trunk/include/clang/AST/TypeLoc.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TypeLoc.h?rev=83112&r1=83111&r2=83112&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/TypeLoc.h (original)
+++ cfe/trunk/include/clang/AST/TypeLoc.h Tue Sep 29 16:27:32 2009
@@ -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 @@
   static bool classof(const ArrayLoc *TL) { return true; }
 };
 
-#define DISPATCH(CLASS) \
-  return static_cast<ImplClass*>(this)->Visit ## CLASS(cast<CLASS>(TyLoc))
-
-template<typename ImplClass, typename RetTy=void>
-class TypeLocVisitor {
-  class TypeDispatch : public TypeVisitor<TypeDispatch, RetTy> {
-    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<CLASS&>(TyLoc)); \
-    }
-#include "clang/AST/TypeLocNodes.def"
-  };
-
-public:
-  RetTy Visit(TypeLoc TyLoc) {
-    TypeDispatch TD(static_cast<ImplClass*>(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

Added: cfe/trunk/include/clang/AST/TypeLocVisitor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TypeLocVisitor.h?rev=83112&view=auto

==============================================================================
--- cfe/trunk/include/clang/AST/TypeLocVisitor.h (added)
+++ cfe/trunk/include/clang/AST/TypeLocVisitor.h Tue Sep 29 16:27:32 2009
@@ -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<ImplClass*>(this)->Visit ## CLASS(cast<CLASS>(TyLoc))
+
+template<typename ImplClass, typename RetTy=void>
+class TypeLocVisitor {
+  class TypeDispatch : public TypeVisitor<TypeDispatch, RetTy> {
+    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<CLASS&>(TyLoc)); \
+    }
+#include "clang/AST/TypeLocNodes.def"
+  };
+
+public:
+  RetTy Visit(TypeLoc TyLoc) {
+    TypeDispatch TD(static_cast<ImplClass*>(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

Modified: cfe/trunk/lib/AST/TypeLoc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TypeLoc.cpp?rev=83112&r1=83111&r2=83112&view=diff

==============================================================================
--- cfe/trunk/lib/AST/TypeLoc.cpp (original)
+++ cfe/trunk/lib/AST/TypeLoc.cpp Tue Sep 29 16:27:32 2009
@@ -11,7 +11,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "clang/AST/TypeLoc.h"
+#include "clang/AST/TypeLocVisitor.h"
 using namespace clang;
 
 //===----------------------------------------------------------------------===//

Modified: cfe/trunk/lib/Frontend/PCHReaderDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHReaderDecl.cpp?rev=83112&r1=83111&r2=83112&view=diff

==============================================================================
--- cfe/trunk/lib/Frontend/PCHReaderDecl.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHReaderDecl.cpp Tue Sep 29 16:27:32 2009
@@ -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;
 
 

Modified: cfe/trunk/lib/Frontend/PCHWriterDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHWriterDecl.cpp?rev=83112&r1=83111&r2=83112&view=diff

==============================================================================
--- cfe/trunk/lib/Frontend/PCHWriterDecl.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHWriterDecl.cpp Tue Sep 29 16:27:32 2009
@@ -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 <cstdio>
 

Modified: cfe/trunk/lib/Index/ASTVisitor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/ASTVisitor.h?rev=83112&r1=83111&r2=83112&view=diff

==============================================================================
--- cfe/trunk/lib/Index/ASTVisitor.h (original)
+++ cfe/trunk/lib/Index/ASTVisitor.h Tue Sep 29 16:27:32 2009
@@ -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 {
 

Modified: cfe/trunk/lib/Index/ResolveLocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/ResolveLocation.cpp?rev=83112&r1=83111&r2=83112&view=diff

==============================================================================
--- cfe/trunk/lib/Index/ResolveLocation.cpp (original)
+++ cfe/trunk/lib/Index/ResolveLocation.cpp Tue Sep 29 16:27:32 2009
@@ -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"





More information about the cfe-commits mailing list