r175711 - CIndex.cpp: Appease g++-4.4. "if (Optional<unsigned> Minor = In.getMinor())" did not work as expected.

David Blaikie dblaikie at gmail.com
Wed Feb 20 18:53:55 PST 2013


On Wed, Feb 20, 2013 at 6:32 PM, NAKAMURA Takumi <geek4civic at gmail.com>wrote:

> Author: chapuni
> Date: Wed Feb 20 20:32:34 2013
> New Revision: 175711
>
> URL: http://llvm.org/viewvc/llvm-project?rev=175711&view=rev
> Log:
> CIndex.cpp: Appease g++-4.4. "if (Optional<unsigned> Minor =
> In.getMinor())" did not work as expected.
>

Thanks for the fix - could you explain how it broke? (I looked at a few bot
logs but couldn't quite figure it out)

Would be useful to know because there's many other examples of similar code
(declaring Optionals in if conditions)


>
> Modified:
>     cfe/trunk/tools/libclang/CIndex.cpp
>
> Modified: cfe/trunk/tools/libclang/CIndex.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=175711&r1=175710&r2=175711&view=diff
>
> ==============================================================================
> --- cfe/trunk/tools/libclang/CIndex.cpp (original)
> +++ cfe/trunk/tools/libclang/CIndex.cpp Wed Feb 20 20:32:34 2013
> @@ -5741,12 +5741,14 @@ static CXVersion convertVersion(VersionT
>
>    Out.Major = In.getMajor();
>
> -  if (Optional<unsigned> Minor = In.getMinor())
> +  Optional<unsigned> Minor = In.getMinor();
> +  if (Minor.hasValue())
>      Out.Minor = *Minor;
>    else
>      return Out;
>
> -  if (Optional<unsigned> Subminor = In.getSubminor())
> +  Optional<unsigned> Subminor = In.getSubminor();
> +  if (Subminor.hasValue())
>      Out.Subminor = *Subminor;
>
>    return Out;
>
>
> _______________________________________________
> 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/20130220/33f984b5/attachment.html>


More information about the cfe-commits mailing list