[cfe-commits] r83089 - in /cfe/trunk: include/clang/AST/TypeLoc.h lib/AST/TypeLoc.cpp
Argiris Kirtzidis
akyrtzi at gmail.com
Tue Sep 29 12:40:46 PDT 2009
Author: akirtzidis
Date: Tue Sep 29 14:40:46 2009
New Revision: 83089
URL: http://llvm.org/viewvc/llvm-project?rev=83089&view=rev
Log:
Introduce TypeLoc::getSourceRange().
Modified:
cfe/trunk/include/clang/AST/TypeLoc.h
cfe/trunk/lib/AST/TypeLoc.cpp
Modified: cfe/trunk/include/clang/AST/TypeLoc.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TypeLoc.h?rev=83089&r1=83088&r2=83089&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/TypeLoc.h (original)
+++ cfe/trunk/include/clang/AST/TypeLoc.h Tue Sep 29 14:40:46 2009
@@ -48,6 +48,8 @@
/// \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 @@
/// \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; }
};
Modified: cfe/trunk/lib/AST/TypeLoc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TypeLoc.cpp?rev=83089&r1=83088&r2=83089&view=diff
==============================================================================
--- cfe/trunk/lib/AST/TypeLoc.cpp (original)
+++ cfe/trunk/lib/AST/TypeLoc.cpp Tue Sep 29 14:40:46 2009
@@ -18,6 +18,30 @@
// 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();
@@ -113,30 +137,6 @@
//===----------------------------------------------------------------------===//
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:
bool VisitTypeSpecLoc(TypeSpecLoc TyLoc) { return true; }
More information about the cfe-commits
mailing list