[cfe-commits] r166174 - /cfe/trunk/lib/AST/TypeLoc.cpp

Chandler Carruth chandlerc at google.com
Thu Oct 18 01:37:22 PDT 2012


On Thu, Oct 18, 2012 at 1:29 AM, Abramo Bagnara
<abramo.bagnara at bugseng.com>wrote:

> Author: abramo
> Date: Thu Oct 18 03:29:37 2012
> New Revision: 166174
>
> URL: http://llvm.org/viewvc/llvm-project?rev=166174&view=rev
> Log:
> Fixed some corner cases due to implicit int TypeLoc and simplified the
> logic.
>

Did anything ever become of the idea of writing unittests for source
location corner cases like these? (Did I just drop the ball on the email
thread?)


>
> Modified:
>     cfe/trunk/lib/AST/TypeLoc.cpp
>
> Modified: cfe/trunk/lib/AST/TypeLoc.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TypeLoc.cpp?rev=166174&r1=166173&r2=166174&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/AST/TypeLoc.cpp (original)
> +++ cfe/trunk/lib/AST/TypeLoc.cpp Thu Oct 18 03:29:37 2012
> @@ -98,27 +98,38 @@
>
>  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())
> -        return Cur.getLocalSourceRange().getBegin();
> +      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();
> -      assert(!Cur.isNull());
>        continue;
> -
> -    // FIXME: Currently QualifiedTypeLoc does not have a source range
> -    // case Qualified:
> -    case Elaborated:
> -      return Cur.getLocalSourceRange().getBegin();
> -
>      default:
> -      if (Cur.getNextTypeLoc().isNull())
> -        return Cur.getLocalSourceRange().getBegin();
> +      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 {
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20121018/538b820b/attachment.html>


More information about the cfe-commits mailing list