forked from OSchip/llvm-project
parent
3dca28d0e2
commit
f7eba5091c
|
@ -85,16 +85,15 @@ public:
|
|||
return Data;
|
||||
}
|
||||
|
||||
/// \brief Get the begin source location.
|
||||
SourceLocation getBeginLoc() const;
|
||||
|
||||
/// \brief Get the end source location.
|
||||
SourceLocation getEndLoc() const;
|
||||
|
||||
/// \brief Get the full source range.
|
||||
SourceRange getSourceRange() const {
|
||||
SourceLocation End = getLocalSourceRange().getEnd();
|
||||
TypeLoc Cur = *this;
|
||||
while (true) {
|
||||
TypeLoc Next = Cur.getNextTypeLoc();
|
||||
if (Next.isNull()) break;
|
||||
Cur = Next;
|
||||
}
|
||||
return SourceRange(Cur.getLocalSourceRange().getBegin(), End);
|
||||
return SourceRange(getBeginLoc(), getEndLoc());
|
||||
}
|
||||
|
||||
/// \brief Get the local source range.
|
||||
|
|
|
@ -108,6 +108,42 @@ void TypeLoc::initializeImpl(TypeLoc TL, SourceLocation Loc) {
|
|||
}
|
||||
}
|
||||
|
||||
SourceLocation TypeLoc::getBeginLoc() const {
|
||||
TypeLoc Cur = *this;
|
||||
while (true) {
|
||||
switch (Cur.getTypeLocClass()) {
|
||||
// FIXME: Currently QualifiedTypeLoc does not have a source range
|
||||
// case Qualified:
|
||||
case Elaborated:
|
||||
break;
|
||||
default:
|
||||
TypeLoc Next = Cur.getNextTypeLoc();
|
||||
if (Next.isNull()) break;
|
||||
Cur = Next;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return Cur.getLocalSourceRange().getBegin();
|
||||
}
|
||||
|
||||
SourceLocation TypeLoc::getEndLoc() const {
|
||||
TypeLoc Cur = *this;
|
||||
while (true) {
|
||||
switch (Cur.getTypeLocClass()) {
|
||||
default:
|
||||
break;
|
||||
case Qualified:
|
||||
case Elaborated:
|
||||
Cur = Cur.getNextTypeLoc();
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return Cur.getLocalSourceRange().getEnd();
|
||||
}
|
||||
|
||||
|
||||
namespace {
|
||||
struct TSTChecker : public TypeLocVisitor<TSTChecker, bool> {
|
||||
// Overload resolution does the real work for us.
|
||||
|
|
Loading…
Reference in New Issue