Skip to content
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

[libc++] Use explicit #include instead of transitive #include #115420

Merged
merged 3 commits into from
Nov 8, 2024

Conversation

winner245
Copy link
Contributor

@winner245 winner245 commented Nov 8, 2024

This benchmark test currently uses std::unique_ptr without explicitly #include <memory>. I think we should not rely on transitive inclusion.

@winner245 winner245 requested a review from a team as a code owner November 8, 2024 04:33
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Nov 8, 2024
@winner245 winner245 changed the title Use explicit #include instead of transitive #include [NFC] Use explicit #include instead of transitive #include Nov 8, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Nov 8, 2024

@llvm/pr-subscribers-libcxx

Author: Peng Liu (winner245)

Changes

The benchmark test currently uses std::unique_ptr without explicitly including <memory>. I think we should not rely on transitive inclusion.


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

1 Files Affected:

  • (modified) libcxx/test/benchmarks/vector_operations.bench.cpp (+1)
diff --git a/libcxx/test/benchmarks/vector_operations.bench.cpp b/libcxx/test/benchmarks/vector_operations.bench.cpp
index b0dffe35ec6e14..119f9e16dadc6e 100644
--- a/libcxx/test/benchmarks/vector_operations.bench.cpp
+++ b/libcxx/test/benchmarks/vector_operations.bench.cpp
@@ -14,6 +14,7 @@
 #include <deque>
 #include <functional>
 #include <vector>
+#include <memory>
 
 #include "benchmark/benchmark.h"
 

@@ -14,6 +14,7 @@
#include <deque>
#include <functional>
#include <vector>
#include <memory>
Copy link
Contributor

Choose a reason for hiding this comment

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

Currently this file also uses std::string without explictly including <string>. Perhaps we should add #include <string> together.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for your reminder. I'll also add that.

Comment on lines 14 to 18
#include <deque>
#include <functional>
#include <vector>
#include <string>
#include <memory>
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
#include <deque>
#include <functional>
#include <vector>
#include <string>
#include <memory>
#include <deque>
#include <functional>
#include <memory>
#include <string>
#include <vector>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. I've adjusted the order of headers as per your suggestion.

@ldionne ldionne changed the title [NFC] Use explicit #include instead of transitive #include [libc++] Use explicit #include instead of transitive #include Nov 8, 2024
@philnik777 philnik777 merged commit 7844257 into llvm:main Nov 8, 2024
56 of 61 checks passed
@winner245 winner245 deleted the winner245/explicit_include branch November 8, 2024 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants