r243255 - [Targets] Define _M_AMD64 and _M_X64 to a more appropriate value

David Majnemer david.majnemer at gmail.com
Mon Jul 27 00:50:44 PDT 2015


On Sun, Jul 26, 2015 at 11:27 PM, Sean Silva <chisophugis at gmail.com> wrote:

>
>
> On Sun, Jul 26, 2015 at 6:06 PM, David Majnemer <david.majnemer at gmail.com>
> wrote:
>
>>
>>
>> On Sunday, July 26, 2015, Sean Silva <chisophugis at gmail.com> wrote:
>>
>>>
>>>
>>> On Sun, Jul 26, 2015 at 4:17 PM, David Majnemer <
>>> david.majnemer at gmail.com> wrote:
>>>
>>>> Author: majnemer
>>>> Date: Sun Jul 26 18:17:29 2015
>>>> New Revision: 243255
>>>>
>>>> URL: http://llvm.org/viewvc/llvm-project?rev=243255&view=rev
>>>> Log:
>>>> [Targets] Define _M_AMD64 and _M_X64 to a more appropriate value
>>>>
>>>> We used to define them to 1, we should have defined them to 100.
>>>>
>>>
>>> Why?
>>>
>>
>> Because that's what they do and I see no particular reason to be
>> gratuitously different.
>>
>> Do you have a link or something that you could cite in the code here?
>>>
>>
>> No, it was found by inspection.
>>
>
> Could you maybe add a comment "// MSVC seems to set them to these values.
> Tested with MSVC <version>."
> Or something like that?
>

I don't think comments like "MSVC seems to set them to these values" are
particularly enlightening.  Behavior compatible with MSVC is the norm, not
the exception.  Our comments generally point out cases where our
compatibility is subpar, stuff like _MSC_BUILD always being set to 1 or
when there is an air of mystery behind some flag bits in an RTTI data
structure.  I think the reader should assume that if clang unconditionally
defines a macro to some value, we did so because it was the compatible
thing to do.


>
> -- Sean Silva
>
>
>>
>>
>>>
>>>
>>
>>> -- Sean Silva
>>>
>>>
>>>>
>>>> Modified:
>>>>     cfe/trunk/lib/Basic/Targets.cpp
>>>>     cfe/trunk/test/Preprocessor/predefined-macros.c
>>>>
>>>> Modified: cfe/trunk/lib/Basic/Targets.cpp
>>>> URL:
>>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=243255&r1=243254&r2=243255&view=diff
>>>>
>>>> ==============================================================================
>>>> --- cfe/trunk/lib/Basic/Targets.cpp (original)
>>>> +++ cfe/trunk/lib/Basic/Targets.cpp Sun Jul 26 18:17:29 2015
>>>> @@ -4000,8 +4000,8 @@ public:
>>>>                          MacroBuilder &Builder) const override {
>>>>      WindowsX86_64TargetInfo::getTargetDefines(Opts, Builder);
>>>>      WindowsX86_64TargetInfo::getVisualStudioDefines(Opts, Builder);
>>>> -    Builder.defineMacro("_M_X64");
>>>> -    Builder.defineMacro("_M_AMD64");
>>>> +    Builder.defineMacro("_M_X64", "100");
>>>> +    Builder.defineMacro("_M_AMD64", "100");
>>>>    }
>>>>  };
>>>>
>>>>
>>>> Modified: cfe/trunk/test/Preprocessor/predefined-macros.c
>>>> URL:
>>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/predefined-macros.c?rev=243255&r1=243254&r2=243255&view=diff
>>>>
>>>> ==============================================================================
>>>> --- cfe/trunk/test/Preprocessor/predefined-macros.c (original)
>>>> +++ cfe/trunk/test/Preprocessor/predefined-macros.c Sun Jul 26 18:17:29
>>>> 2015
>>>> @@ -18,8 +18,8 @@
>>>>  // CHECK-MS64: #define _INTEGRAL_MAX_BITS 64
>>>>  // CHECK-MS64: #define _MSC_EXTENSIONS 1
>>>>  // CHECK-MS64: #define _MSC_VER 1300
>>>> -// CHECK-MS64: #define _M_AMD64 1
>>>> -// CHECK-MS64: #define _M_X64 1
>>>> +// CHECK-MS64: #define _M_AMD64 100
>>>> +// CHECK-MS64: #define _M_X64 100
>>>>  // CHECK-MS64: #define _WIN64 1
>>>>  // CHECK-MS64-NOT: #define __STRICT_ANSI__
>>>>  // CHECK-MS64-NOT: GCC
>>>>
>>>>
>>>> _______________________________________________
>>>> 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/20150727/b827409f/attachment.html>


More information about the cfe-commits mailing list