-
Notifications
You must be signed in to change notification settings - Fork 12.3k
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
[Clang][NFC] Avoid opening namespace std #95470
Conversation
|
@llvm/pr-subscribers-clang @llvm/pr-subscribers-clang-static-analyzer-1 Author: Nikolas Klauser (philnik777) ChangesNever opening Full diff: https://github.com/llvm/llvm-project/pull/95470.diff 4 Files Affected:
diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h
index eb6647038403d..3900f6496f06a 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -5430,9 +5430,7 @@ bool isClangFormatOff(StringRef Comment);
} // end namespace format
} // end namespace clang
-namespace std {
template <>
-struct is_error_code_enum<clang::format::ParseError> : std::true_type {};
-} // namespace std
+struct std::is_error_code_enum<clang::format::ParseError> : std::true_type {};
#endif // LLVM_CLANG_FORMAT_FORMAT_H
diff --git a/clang/include/clang/Frontend/PrecompiledPreamble.h b/clang/include/clang/Frontend/PrecompiledPreamble.h
index 798870bf24fe1..624df004bf89e 100644
--- a/clang/include/clang/Frontend/PrecompiledPreamble.h
+++ b/clang/include/clang/Frontend/PrecompiledPreamble.h
@@ -256,9 +256,7 @@ class BuildPreambleErrorCategory final : public std::error_category {
std::error_code make_error_code(BuildPreambleError Error);
} // namespace clang
-namespace std {
template <>
-struct is_error_code_enum<clang::BuildPreambleError> : std::true_type {};
-} // namespace std
+struct std::is_error_code_enum<clang::BuildPreambleError> : std::true_type {};
#endif
diff --git a/clang/include/clang/Frontend/SerializedDiagnosticReader.h b/clang/include/clang/Frontend/SerializedDiagnosticReader.h
index 309e0abb14613..96d576a63b9f2 100644
--- a/clang/include/clang/Frontend/SerializedDiagnosticReader.h
+++ b/clang/include/clang/Frontend/SerializedDiagnosticReader.h
@@ -128,11 +128,7 @@ class SerializedDiagnosticReader {
} // namespace serialized_diags
} // namespace clang
-namespace std {
-
template <>
-struct is_error_code_enum<clang::serialized_diags::SDError> : std::true_type {};
-
-} // namespace std
+struct std::is_error_code_enum<clang::serialized_diags::SDError> : std::true_type {};
#endif // LLVM_CLANG_FRONTEND_SERIALIZEDDIAGNOSTICREADER_H
diff --git a/clang/lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp
index 92347f8fafc00..40f7e9cede1f1 100644
--- a/clang/lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp
@@ -202,13 +202,12 @@ class BlockInCriticalSectionChecker : public Checker<check::PostCall> {
REGISTER_LIST_WITH_PROGRAMSTATE(ActiveCritSections, CritSectionMarker)
-namespace std {
// Iterator traits for ImmutableList data structure
// that enable the use of STL algorithms.
// TODO: Move these to llvm::ImmutableList when overhauling immutable data
// structures for proper iterator concept support.
template <>
-struct iterator_traits<
+struct std::iterator_traits<
typename llvm::ImmutableList<CritSectionMarker>::iterator> {
using iterator_category = std::forward_iterator_tag;
using value_type = CritSectionMarker;
@@ -216,7 +215,6 @@ struct iterator_traits<
using reference = CritSectionMarker &;
using pointer = CritSectionMarker *;
};
-} // namespace std
std::optional<MutexDescriptor>
BlockInCriticalSectionChecker::checkDescriptorMatch(const CallEvent &Call,
|
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
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
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. Please make clang format happy before merging.
f5fc162 to
ee78c1e
Compare
Never opening
namespace stdavoids even the possibility of introducing new symbols as well as making the code a bit shorter by removing unnecessary boiler plate.