Skip to content

[support][nfc] MD5: Undef macros after use #132132

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

Merged
merged 1 commit into from
Mar 21, 2025
Merged

Conversation

Hardcode84
Copy link
Contributor

I'm experimenting with amalgamating Support lib into single cpp and leaking a bunch of 1-letter macros is not nice.

I'm experimenting with amalgamating Support lib into single cpp and leaking a bunch of 1-letter macros is not nice.
@llvmbot
Copy link
Member

llvmbot commented Mar 20, 2025

@llvm/pr-subscribers-llvm-support

Author: Ivan Butygin (Hardcode84)

Changes

I'm experimenting with amalgamating Support lib into single cpp and leaking a bunch of 1-letter macros is not nice.


Full diff: https://github.com/llvm/llvm-project/pull/132132.diff

1 Files Affected:

  • (modified) llvm/lib/Support/MD5.cpp (+8)
diff --git a/llvm/lib/Support/MD5.cpp b/llvm/lib/Support/MD5.cpp
index ef7f559adf064..3bff4e177f781 100644
--- a/llvm/lib/Support/MD5.cpp
+++ b/llvm/lib/Support/MD5.cpp
@@ -296,3 +296,11 @@ MD5::MD5Result MD5::hash(ArrayRef<uint8_t> Data) {
 
   return Res;
 }
+
+#undef F
+#undef G
+#undef H
+#undef I
+#undef STEP
+#undef SET
+#undef GET

@@ -296,3 +296,11 @@ MD5::MD5Result MD5::hash(ArrayRef<uint8_t> Data) {

return Res;
}

#undef F
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it would be reasonable to upgrade these macros to constexpr functions instead.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, but I don't think this is a blocker

Copy link
Contributor Author

@Hardcode84 Hardcode84 Mar 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Searching them on github gives a lot of hits, so they were probably copypasted from some common place: https://github.com/search?q=%23define+F%28x%2C+y%2C+z%29+%28%28z%29+%5E+%28%28x%29+%26+%28%28y%29+%5E+%28z%29%29%29%29&type=code

@Hardcode84 Hardcode84 requested review from kuhar and dwblaikie March 21, 2025 01:47
Copy link
Member

@kuhar kuhar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but it would be nice not to use macros at all

@@ -296,3 +296,11 @@ MD5::MD5Result MD5::hash(ArrayRef<uint8_t> Data) {

return Res;
}

#undef F
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, but I don't think this is a blocker

@Hardcode84 Hardcode84 merged commit 969ac10 into llvm:main Mar 21, 2025
13 checks passed
@Hardcode84 Hardcode84 deleted the undef-md5 branch March 21, 2025 02:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants