Introduce TypeLoc::getSourceRange().

llvm-svn: 83089
This commit is contained in:
Argyrios Kyrtzidis 2009-09-29 19:40:46 +00:00
parent 1b7c4ca37d
commit 402e1dcf6f
2 changed files with 26 additions and 26 deletions

View 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; }
};

View 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: