示例#1
0
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();
}
示例#2
0
文件: TypeLoc.cpp 项目: avakar/clang
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();
  }
}
示例#3
0
文件: TypeLoc.cpp 项目: colgur/clang
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();
}
示例#4
0
文件: TypeLoc.cpp 项目: colgur/clang
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();
}