-
Notifications
You must be signed in to change notification settings - Fork 13.4k
[clang][NFC] rename FPOptions.def's macro to FP_OPTION #138374
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-clang Author: Oliver Hunt (ojhunt) ChangesWhile investigating the recent warnings around FEM_Indeterminate I noticed that the macro name for FPOptions.def was given the very generic name This PR renames it to FP_OPTION instead. Full diff: https://github.com/llvm/llvm-project/pull/138374.diff 5 Files Affected:
diff --git a/clang/include/clang/Basic/FPOptions.def b/clang/include/clang/Basic/FPOptions.def
index 90428c3c73c8b..5cb41c92f4af8 100644
--- a/clang/include/clang/Basic/FPOptions.def
+++ b/clang/include/clang/Basic/FPOptions.def
@@ -7,26 +7,26 @@
//===----------------------------------------------------------------------===//
// This file defines the Floating Point language options. Users of this file
-// must define the OPTION macro to make use of this information.
-#ifndef OPTION
-# error Define the OPTION macro to handle floating point language options
+// must define the FP_OPTION macro to make use of this information.
+#ifndef FP_OPTION
+# error Define the FP_OPTION macro to handle floating point language options
#endif
-// OPTION(name, type, width, previousName)
-OPTION(FPContractMode, LangOptions::FPModeKind, 2, First)
-OPTION(RoundingMath, bool, 1, FPContractMode)
-OPTION(ConstRoundingMode, LangOptions::RoundingMode, 3, RoundingMath)
-OPTION(SpecifiedExceptionMode, LangOptions::FPExceptionModeKind, 2, ConstRoundingMode)
-OPTION(AllowFEnvAccess, bool, 1, SpecifiedExceptionMode)
-OPTION(AllowFPReassociate, bool, 1, AllowFEnvAccess)
-OPTION(NoHonorNaNs, bool, 1, AllowFPReassociate)
-OPTION(NoHonorInfs, bool, 1, NoHonorNaNs)
-OPTION(NoSignedZero, bool, 1, NoHonorInfs)
-OPTION(AllowReciprocal, bool, 1, NoSignedZero)
-OPTION(AllowApproxFunc, bool, 1, AllowReciprocal)
-OPTION(FPEvalMethod, LangOptions::FPEvalMethodKind, 2, AllowApproxFunc)
-OPTION(Float16ExcessPrecision, LangOptions::ExcessPrecisionKind, 2, FPEvalMethod)
-OPTION(BFloat16ExcessPrecision, LangOptions::ExcessPrecisionKind, 2, Float16ExcessPrecision)
-OPTION(MathErrno, bool, 1, BFloat16ExcessPrecision)
-OPTION(ComplexRange, LangOptions::ComplexRangeKind, 3, MathErrno)
-#undef OPTION
+// FP_OPTION(name, type, width, previousName)
+FP_OPTION(FPContractMode, LangOptions::FPModeKind, 2, First)
+FP_OPTION(RoundingMath, bool, 1, FPContractMode)
+FP_OPTION(ConstRoundingMode, LangOptions::RoundingMode, 3, RoundingMath)
+FP_OPTION(SpecifiedExceptionMode, LangOptions::FPExceptionModeKind, 2, ConstRoundingMode)
+FP_OPTION(AllowFEnvAccess, bool, 1, SpecifiedExceptionMode)
+FP_OPTION(AllowFPReassociate, bool, 1, AllowFEnvAccess)
+FP_OPTION(NoHonorNaNs, bool, 1, AllowFPReassociate)
+FP_OPTION(NoHonorInfs, bool, 1, NoHonorNaNs)
+FP_OPTION(NoSignedZero, bool, 1, NoHonorInfs)
+FP_OPTION(AllowReciprocal, bool, 1, NoSignedZero)
+FP_OPTION(AllowApproxFunc, bool, 1, AllowReciprocal)
+FP_OPTION(FPEvalMethod, LangOptions::FPEvalMethodKind, 2, AllowApproxFunc)
+FP_OPTION(Float16ExcessPrecision, LangOptions::ExcessPrecisionKind, 2, FPEvalMethod)
+FP_OPTION(BFloat16ExcessPrecision, LangOptions::ExcessPrecisionKind, 2, Float16ExcessPrecision)
+FP_OPTION(MathErrno, bool, 1, BFloat16ExcessPrecision)
+FP_OPTION(ComplexRange, LangOptions::ComplexRangeKind, 3, MathErrno)
+#undef FP_OPTION
diff --git a/clang/include/clang/Basic/LangOptions.h b/clang/include/clang/Basic/LangOptions.h
index 1bfc0d8e88556..a7c2d48fd2274 100644
--- a/clang/include/clang/Basic/LangOptions.h
+++ b/clang/include/clang/Basic/LangOptions.h
@@ -856,7 +856,7 @@ class FPOptions {
// Define a fake option named "First" so that we have a PREVIOUS even for the
// real first option.
static constexpr storage_type FirstShift = 0, FirstWidth = 0;
-#define OPTION(NAME, TYPE, WIDTH, PREVIOUS) \
+#define FP_OPTION(NAME, TYPE, WIDTH, PREVIOUS) \
static constexpr storage_type NAME##Shift = \
PREVIOUS##Shift + PREVIOUS##Width; \
static constexpr storage_type NAME##Width = WIDTH; \
@@ -865,7 +865,7 @@ class FPOptions {
#include "clang/Basic/FPOptions.def"
static constexpr storage_type TotalWidth = 0
-#define OPTION(NAME, TYPE, WIDTH, PREVIOUS) +WIDTH
+#define FP_OPTION(NAME, TYPE, WIDTH, PREVIOUS) +WIDTH
#include "clang/Basic/FPOptions.def"
;
static_assert(TotalWidth <= StorageBitSize, "Too short type for FPOptions");
@@ -974,7 +974,7 @@ class FPOptions {
// We can define most of the accessors automatically:
// TODO: consider enforcing the assertion that value fits within bits
// statically.
-#define OPTION(NAME, TYPE, WIDTH, PREVIOUS) \
+#define FP_OPTION(NAME, TYPE, WIDTH, PREVIOUS) \
TYPE get##NAME() const { \
return static_cast<TYPE>((Value & NAME##Mask) >> NAME##Shift); \
} \
@@ -1085,7 +1085,7 @@ class FPOptionsOverride {
}
bool operator!=(FPOptionsOverride other) const { return !(*this == other); }
-#define OPTION(NAME, TYPE, WIDTH, PREVIOUS) \
+#define FP_OPTION(NAME, TYPE, WIDTH, PREVIOUS) \
bool has##NAME##Override() const { \
return OverrideMask & FPOptions::NAME##Mask; \
} \
diff --git a/clang/lib/AST/JSONNodeDumper.cpp b/clang/lib/AST/JSONNodeDumper.cpp
index 164b3cad4f7aa..8bf7d09166249 100644
--- a/clang/lib/AST/JSONNodeDumper.cpp
+++ b/clang/lib/AST/JSONNodeDumper.cpp
@@ -1864,7 +1864,7 @@ void JSONNodeDumper::visitVerbatimLineComment(
llvm::json::Object JSONNodeDumper::createFPOptions(FPOptionsOverride FPO) {
llvm::json::Object Ret;
-#define OPTION(NAME, TYPE, WIDTH, PREVIOUS) \
+#define FP_OPTION(NAME, TYPE, WIDTH, PREVIOUS) \
if (FPO.has##NAME##Override()) \
Ret.try_emplace(#NAME, static_cast<unsigned>(FPO.get##NAME##Override()));
#include "clang/Basic/FPOptions.def"
diff --git a/clang/lib/AST/TextNodeDumper.cpp b/clang/lib/AST/TextNodeDumper.cpp
index 51f7d17be4158..95c631124ace4 100644
--- a/clang/lib/AST/TextNodeDumper.cpp
+++ b/clang/lib/AST/TextNodeDumper.cpp
@@ -1114,7 +1114,7 @@ const char *TextNodeDumper::getCommandName(unsigned CommandID) {
}
void TextNodeDumper::printFPOptions(FPOptionsOverride FPO) {
-#define OPTION(NAME, TYPE, WIDTH, PREVIOUS) \
+#define FP_OPTION(NAME, TYPE, WIDTH, PREVIOUS) \
if (FPO.has##NAME##Override()) \
OS << " " #NAME "=" << FPO.get##NAME##Override();
#include "clang/Basic/FPOptions.def"
diff --git a/clang/lib/Basic/LangOptions.cpp b/clang/lib/Basic/LangOptions.cpp
index e3037ec819add..6b4ce979483eb 100644
--- a/clang/lib/Basic/LangOptions.cpp
+++ b/clang/lib/Basic/LangOptions.cpp
@@ -219,7 +219,7 @@ FPOptions FPOptions::defaultWithoutTrailingStorage(const LangOptions &LO) {
FPOptionsOverride FPOptions::getChangesSlow(const FPOptions &Base) const {
FPOptions::storage_type OverrideMask = 0;
-#define OPTION(NAME, TYPE, WIDTH, PREVIOUS) \
+#define FP_OPTION(NAME, TYPE, WIDTH, PREVIOUS) \
if (get##NAME() != Base.get##NAME()) \
OverrideMask |= NAME##Mask;
#include "clang/Basic/FPOptions.def"
@@ -227,14 +227,14 @@ FPOptionsOverride FPOptions::getChangesSlow(const FPOptions &Base) const {
}
LLVM_DUMP_METHOD void FPOptions::dump() {
-#define OPTION(NAME, TYPE, WIDTH, PREVIOUS) \
+#define FP_OPTION(NAME, TYPE, WIDTH, PREVIOUS) \
llvm::errs() << "\n " #NAME " " << get##NAME();
#include "clang/Basic/FPOptions.def"
llvm::errs() << "\n";
}
LLVM_DUMP_METHOD void FPOptionsOverride::dump() {
-#define OPTION(NAME, TYPE, WIDTH, PREVIOUS) \
+#define FP_OPTION(NAME, TYPE, WIDTH, PREVIOUS) \
if (has##NAME##Override()) \
llvm::errs() << "\n " #NAME " Override is " << get##NAME##Override();
#include "clang/Basic/FPOptions.def"
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
While investigating the recent warnings around FEM_Indeterminate I noticed that the macro name for FPOptions.def was given the very generic name `OPTION`. This PR renames it to FP_OPTION instead.
f3351a6
to
60eeaf0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but I have only done a very isolated change on this code before.
Righto, I'll wait for @zahiraam and/or @AaronBallman as well |
May be an [NFC] in the title of the PR? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Thanks.
While investigating the recent warnings around FEM_Indeterminate I noticed that the macro name for FPOptions.def was given the very generic name `OPTION`. This PR renames it to FP_OPTION instead.
While investigating the recent warnings around FEM_Indeterminate I noticed that the macro name for FPOptions.def was given the very generic name
OPTION
.This PR renames it to FP_OPTION instead.