r241564 - Don't rely on the use of non-POD types within unions.

Douglas Gregor dgregor at apple.com
Tue Jul 7 08:55:23 PDT 2015


> On Jul 7, 2015, at 2:45 AM, Yaron Keren <yaron.keren at gmail.com> wrote:
> 
> Hi Douglas,
> 
> One of these Objective C patches breaks Visual C++ compilation, see
> 
>  http://lab.llvm.org:8011/builders/clang-x86-win2008-selfhost/builds/1803/steps/build%20stage%201/logs/stdio <http://lab.llvm.org:8011/builders/clang-x86-win2008-selfhost/builds/1803/steps/build%20stage%201/logs/stdio>
> 
> [592/1207] Building CXX object tools\clang\lib\Parse\CMakeFiles\clangParse.dir\ParseAST.cpp.obj
> FAILED: C:\PROGRA~2\MICROS~1.0\VC\bin\cl.exe   /nologo /TP -wd4146 -wd4180 -wd4244 -wd4258 -wd4267 -wd4291 -wd4345 -wd4351 -wd4355 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4800 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4324 -w14062 -we4238 -Itools\clang\lib\Parse -IC:\buildbot\slave-config\clang-x86-win2008-selfhost\llvm\tools\clang\lib\Parse -IC:\buildbot\slave-config\clang-x86-win2008-selfhost\llvm\tools\clang\include -Itools\clang\include -Iinclude -IC:\buildbot\slave-config\clang-x86-win2008-selfhost\llvm\include    -UNDEBUG /EHs-c- /GR- /showIncludes -DCLANG_ENABLE_ARCMT -DCLANG_ENABLE_OBJC_REWRITER -DCLANG_ENABLE_STATIC_ANALYZER -DGTEST_HAS_RTTI=0 -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_GNU_SOURCE -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS /Fotools\clang\lib\Parse\CMakeFiles\clangParse.dir\ParseCXXInlineMethods.cpp.obj /Fdtools\clang\lib\Parse\CMakeFiles\clangParse.dir\ /FS -c C:\buildbot\slave-config\clang-x86-win2008-selfhost\llvm\tools\clang\lib\Parse\ParseCXXInlineMethods.cpp
> C:\buildbot\slave-config\clang-x86-win2008-selfhost\llvm\tools\clang\include\clang/AST/DeclObjC.h(613) : error C2620: 'clang::ObjCTypeParamList::Brackets' : illegal union member; type 'clang::SourceRange' has a user-defined constructor or non-trivial default constructor
> C:\buildbot\slave-config\clang-x86-win2008-selfhost\llvm\tools\clang\include\clang/AST/DeclObjC.h(664) : error C2065: 'Brackets' : undeclared identifier
> C:\buildbot\slave-config\clang-x86-win2008-selfhost\llvm\tools\clang\include\clang/AST/DeclObjC.h(664) : error C2228: left of '.getBegin' must have class/struct/union
>         type is 'unknown-type
You replied to the fix that addressed the MSVC compilation issue.

	- Doug

> 
> Yaron
> 
> 
> 2015-07-07 9:20 GMT+03:00 Douglas Gregor <dgregor at apple.com <mailto:dgregor at apple.com>>:
> Author: dgregor
> Date: Tue Jul  7 01:20:46 2015
> New Revision: 241564
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=241564&view=rev <http://llvm.org/viewvc/llvm-project?rev=241564&view=rev>
> Log:
> Don't rely on the use of non-POD types within unions.
> 
> They aren't universally supported and we're not getting any benefit
> from using them.
> 
> Modified:
>     cfe/trunk/include/clang/AST/DeclObjC.h
>     cfe/trunk/lib/AST/DeclObjC.cpp
> 
> Modified: cfe/trunk/include/clang/AST/DeclObjC.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=241564&r1=241563&r2=241564&view=diff <http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=241564&r1=241563&r2=241564&view=diff>
> ==============================================================================
> --- cfe/trunk/include/clang/AST/DeclObjC.h (original)
> +++ cfe/trunk/include/clang/AST/DeclObjC.h Tue Jul  7 01:20:46 2015
> @@ -610,7 +610,10 @@ public:
>  class ObjCTypeParamList {
>    union {
>      /// Location of the left and right angle brackets.
> -    SourceRange Brackets;
> +    struct {
> +      unsigned Begin;
> +      unsigned End;
> +    } Brackets;
> 
>      // Used only for alignment.
>      ObjCTypeParamDecl *AlignmentHack;
> @@ -661,9 +664,15 @@ public:
>      return *(end() - 1);
>    }
> 
> -  SourceLocation getLAngleLoc() const { return Brackets.getBegin(); }
> -  SourceLocation getRAngleLoc() const { return Brackets.getEnd(); }
> -  SourceRange getSourceRange() const { return Brackets; }
> +  SourceLocation getLAngleLoc() const {
> +    return SourceLocation::getFromRawEncoding(Brackets.Begin);
> +  }
> +  SourceLocation getRAngleLoc() const {
> +    return SourceLocation::getFromRawEncoding(Brackets.End);
> +  }
> +  SourceRange getSourceRange() const {
> +    return SourceRange(getLAngleLoc(), getRAngleLoc());
> +  }
> 
>    /// Gather the default set of type arguments to be substituted for
>    /// these type parameters when dealing with an unspecialized type.
> 
> Modified: cfe/trunk/lib/AST/DeclObjC.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclObjC.cpp?rev=241564&r1=241563&r2=241564&view=diff <http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclObjC.cpp?rev=241564&r1=241563&r2=241564&view=diff>
> ==============================================================================
> --- cfe/trunk/lib/AST/DeclObjC.cpp (original)
> +++ cfe/trunk/lib/AST/DeclObjC.cpp Tue Jul  7 01:20:46 2015
> @@ -1251,8 +1251,10 @@ SourceRange ObjCTypeParamDecl::getSource
>  ObjCTypeParamList::ObjCTypeParamList(SourceLocation lAngleLoc,
>                                       ArrayRef<ObjCTypeParamDecl *> typeParams,
>                                       SourceLocation rAngleLoc)
> -  : Brackets(lAngleLoc, rAngleLoc), NumParams(typeParams.size())
> +  : NumParams(typeParams.size())
>  {
> +  Brackets.Begin = lAngleLoc.getRawEncoding();
> +  Brackets.End = rAngleLoc.getRawEncoding();
>    std::copy(typeParams.begin(), typeParams.end(), begin());
>  }
> 
> 
> 
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu <mailto:cfe-commits at cs.uiuc.edu>
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits <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/20150707/ee3748f6/attachment.html>


More information about the cfe-commits mailing list