This is an archive of the discontinued LLVM Phabricator instance.

Define __FLT_EVAL_METHOD__ when input source is stdin.
AbandonedPublic

Authored by zahiraam on Apr 19 2022, 7:05 AM.

Details

Summary

When the input source is stdin, the FLT_EVAL_METHOD macro is not set.
This patch defines it.

Diff Detail

Event Timeline

zahiraam created this revision.Apr 19 2022, 7:05 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 19 2022, 7:05 AM
Herald added a subscriber: dschuff. · View Herald Transcript
zahiraam requested review of this revision.Apr 19 2022, 7:05 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 19 2022, 7:05 AM
Herald added a subscriber: aheejin. · View Herald Transcript
aaron.ballman added inline comments.Apr 19 2022, 9:51 AM
clang/lib/Frontend/FrontendAction.cpp
845–855

I'm confused as to why we want to predefine this macro *only* when the input source is stdin? So I'm not certain I understand why this change is desired.

e.g., https://godbolt.org/z/E8Y67381r (note how there's no __FLT_EVAL_METHOD__ defined there)

zahiraam added inline comments.
clang/lib/Frontend/FrontendAction.cpp
845–855

I was offering a solution to the issue raised by @glandium in https://reviews.llvm.org/D109239. I thought that the issue was only when the source is stdin, but obviously not. The default setting should happen under no condition.

aaron.ballman added inline comments.Apr 19 2022, 10:23 AM
clang/lib/Frontend/FrontendAction.cpp
845–855

There have been a lot of reviews over this stuff, so I may be remembering incorrectly... but I thought it was a conscious decision to *not* predefine __FLT_EVAL_METHOD__ because that value changes depending on pragmas in the TU. I thought the way that macro worked was that we registered it as a macro and we figure out its value at expansion time.

(The original report confused me into thinking that __FLT_EVAL_METHOD__ was behaving as though it was never defined, so expansion would never result in a correct value except when the eval method is 0.)

zahiraam added inline comments.Apr 19 2022, 10:42 AM
clang/lib/Frontend/FrontendAction.cpp
845–855

Yes, you are remembering correctly. I looked at older comments and it's something that was intended. We didn't want to pre-define it, until it is set at expansion.

aaron.ballman added inline comments.Apr 19 2022, 11:17 AM
clang/lib/Frontend/FrontendAction.cpp
845–855

Thank you for double-checking! I would recommend that you abandon this change, and instead make an NFC change to https://clang.llvm.org/docs/UsersManual.html#a-note-about-flt-eval-method to make it clear that this macro does not appear when dumping preprocessor macro definitions but is instead resolved when expanding it as a macro definition.

zahiraam added inline comments.Apr 19 2022, 11:39 AM
clang/lib/Frontend/FrontendAction.cpp
845–855

Good idea! I seem to be regularly falling into forgetting this.

zahiraam abandoned this revision.Apr 19 2022, 11:39 AM