SourceLocation TypeLoc::getBeginLoc() const { TypeLoc Cur = *this; TypeLoc LeftMost = Cur; while (true) { switch (Cur.getTypeLocClass()) { case Elaborated: LeftMost = Cur; break; case FunctionProto: if (cast<FunctionProtoTypeLoc>(&Cur)->getTypePtr()->hasTrailingReturn()) { LeftMost = Cur; break; } /* Fall through */ case FunctionNoProto: case ConstantArray: case DependentSizedArray: case IncompleteArray: case VariableArray: // FIXME: Currently QualifiedTypeLoc does not have a source range case Qualified: Cur = Cur.getNextTypeLoc(); continue; default: if (!Cur.getLocalSourceRange().getBegin().isInvalid()) LeftMost = Cur; Cur = Cur.getNextTypeLoc(); if (Cur.isNull()) break; continue; } // switch break; } // while return LeftMost.getLocalSourceRange().getBegin(); }
SourceLocation TypeLoc::getEndLoc() const { TypeLoc Cur = *this; TypeLoc Last; while (true) { switch (Cur.getTypeLocClass()) { default: if (!Last) Last = Cur; return Last.getLocalSourceRange().getEnd(); case Paren: case ConstantArray: case DependentSizedArray: case IncompleteArray: case VariableArray: case FunctionProto: case FunctionNoProto: Last = Cur; break; case Pointer: case BlockPointer: case MemberPointer: case LValueReference: case RValueReference: case PackExpansion: if (!Last) Last = Cur; break; case Qualified: case Elaborated: break; } Cur = Cur.getNextTypeLoc(); } }
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(); }
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::getBeginLoc() const { TypeLoc Cur = *this; SourceLocation SavedParenLoc; while (true) { switch (Cur.getTypeLocClass()) { // FIXME: Currently QualifiedTypeLoc does not have a source range // case Qualified: case Elaborated: case DependentName: case DependentTemplateSpecialization: break; case Paren: // Save local source begin, if still unset. if (SavedParenLoc.isInvalid()) SavedParenLoc = Cur.getLocalSourceRange().getBegin(); Cur = Cur.getNextTypeLoc(); assert(!Cur.isNull()); continue; break; case Pointer: case BlockPointer: case MemberPointer: case ObjCObjectPointer: case LValueReference: case RValueReference: case ConstantArray: case DependentSizedArray: case IncompleteArray: case VariableArray: case FunctionNoProto: // Discard previously saved paren loc, if any. SavedParenLoc = SourceLocation(); Cur = Cur.getNextTypeLoc(); assert(!Cur.isNull()); continue; break; case FunctionProto: // Discard previously saved paren loc, if any. SavedParenLoc = SourceLocation(); if (cast<FunctionProtoTypeLoc>(&Cur)->getTypePtr()->hasTrailingReturn()) return Cur.getLocalSourceRange().getBegin(); Cur = Cur.getNextTypeLoc(); assert(!Cur.isNull()); continue; break; default: TypeLoc Next = Cur.getNextTypeLoc(); if (Next.isNull()) break; Cur = Next; continue; } break; } return SavedParenLoc.isValid() ? SavedParenLoc : Cur.getLocalSourceRange().getBegin(); }