]> granicus.if.org Git - clang/commitdiff
Introduce TypeLoc::getSourceRange().
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Tue, 29 Sep 2009 19:40:46 +0000 (19:40 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Tue, 29 Sep 2009 19:40:46 +0000 (19:40 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83089 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/TypeLoc.h
lib/AST/TypeLoc.cpp

index 93cc48aa07c5a54f0d20f2702777ffdba1c6f04f..21b7d9af523cb9c8749f7c69253680dd5540eb8a 100644 (file)
@@ -48,6 +48,8 @@ public:
   /// \brief Get the pointer where source information is stored.
   void *getOpaqueData() const { return Data; }
 
+  SourceRange getSourceRange() const;
+
   /// \brief Find the TypeSpecLoc that is part of this TypeLoc.
   TypeSpecLoc getTypeSpecLoc() const;
 
@@ -76,8 +78,6 @@ public:
 /// \brief Base wrapper of type source info data for type-spec types.
 class TypeSpecLoc : public TypeLoc  {
 public:
-  SourceRange getSourceRange() const;
-
   static bool classof(const TypeLoc *TL);
   static bool classof(const TypeSpecLoc *TL) { return true; }
 };
index a95f38897a33630a6012f99d6c758be5386be095..cea8dc51698d3a1d9e42d494a530f841ef7443de 100644 (file)
@@ -18,6 +18,30 @@ using namespace clang;
 // TypeLoc Implementation
 //===----------------------------------------------------------------------===//
 
+namespace {
+
+/// \brief Return the source range for the visited TypeSpecLoc.
+class TypeLocRanger : public TypeLocVisitor<TypeLocRanger, SourceRange> {
+public:
+#define ABSTRACT_TYPELOC(CLASS)
+#define TYPELOC(CLASS, PARENT, TYPE) \
+    SourceRange Visit##CLASS(CLASS TyLoc) { return TyLoc.getSourceRange(); }
+#include "clang/AST/TypeLocNodes.def"
+
+  SourceRange VisitTypeLoc(TypeLoc TyLoc) {
+    assert(0 && "A typeloc wrapper was not handled!");
+    return SourceRange();
+  }
+};
+
+}
+
+SourceRange TypeLoc::getSourceRange() const {
+  if (isNull())
+    return SourceRange();
+  return TypeLocRanger().Visit(*this);
+}
+
 /// \brief Returns the size of type source info data block for the given type.
 unsigned TypeLoc::getFullDataSizeForType(QualType Ty) {
   return TypeLoc(Ty, 0).getFullDataSize();
@@ -112,30 +136,6 @@ TypeLoc TypeLoc::getNextTypeLoc() const {
 // TypeSpecLoc Implementation
 //===----------------------------------------------------------------------===//
 
-namespace {
-
-/// \brief Return the source range for the visited TypeSpecLoc.
-class TypeSpecRanger : public TypeLocVisitor<TypeSpecRanger, SourceRange> {
-public:
-#define TYPELOC(CLASS, PARENT, TYPE)
-#define TYPESPEC_TYPELOC(CLASS, TYPE) \
-    SourceRange Visit##CLASS(CLASS TyLoc) { return TyLoc.getSourceRange(); }
-#include "clang/AST/TypeLocNodes.def"
-
-  SourceRange VisitTypeLoc(TypeLoc TyLoc) {
-    assert(0 && "A typespec loc wrapper was not handled!");
-    return SourceRange();
-  }
-};
-
-}
-
-SourceRange TypeSpecLoc::getSourceRange() const {
-  if (isNull())
-    return SourceRange();
-  return TypeSpecRanger().Visit(*this);
-}
-
 namespace {
 class TypeSpecChecker : public TypeLocVisitor<TypeSpecChecker, bool> {
 public: