[cfe-commits] r104382 - in /cfe/trunk: include/clang/AST/TypeLoc.h lib/AST/TypeLoc.cpp
Abramo Bagnara
abramo.bagnara at gmail.com
Fri May 21 14:12:12 PDT 2010
Author: abramo
Date: Fri May 21 16:12:12 2010
New Revision: 104382
URL: http://llvm.org/viewvc/llvm-project?rev=104382&view=rev
Log:
Improved 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=104382&r1=104381&r2=104382&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/TypeLoc.h (original)
+++ cfe/trunk/include/clang/AST/TypeLoc.h Fri May 21 16:12:12 2010
@@ -85,16 +85,15 @@
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.
Modified: cfe/trunk/lib/AST/TypeLoc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TypeLoc.cpp?rev=104382&r1=104381&r2=104382&view=diff
==============================================================================
--- cfe/trunk/lib/AST/TypeLoc.cpp (original)
+++ cfe/trunk/lib/AST/TypeLoc.cpp Fri May 21 16:12:12 2010
@@ -108,6 +108,42 @@
}
}
+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.
More information about the cfe-commits
mailing list