[clang] [Clang][NFC] Avoid opening namespace std (PR #95470)

2024-06-14 Thread Nikolas Klauser via cfe-commits

https://github.com/philnik777 closed 
https://github.com/llvm/llvm-project/pull/95470
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][NFC] Avoid opening namespace std (PR #95470)

2024-06-14 Thread Nikolas Klauser via cfe-commits

https://github.com/philnik777 updated 
https://github.com/llvm/llvm-project/pull/95470

>From ee78c1e22b81ef3beb4e28e4ea778ab3a80b1f2d Mon Sep 17 00:00:00 2001
From: Nikolas Klauser 
Date: Thu, 13 Jun 2024 22:24:17 +0200
Subject: [PATCH] [Clang] Avoid opening namespace std

---
 clang/include/clang/Format/Format.h| 4 +---
 clang/include/clang/Frontend/PrecompiledPreamble.h | 4 +---
 clang/include/clang/Frontend/SerializedDiagnosticReader.h  | 7 ++-
 .../Checkers/BlockInCriticalSectionChecker.cpp | 4 +---
 4 files changed, 5 insertions(+), 14 deletions(-)

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 : std::true_type {};
-} // namespace std
+struct std::is_error_code_enum : 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 : std::true_type {};
-} // namespace std
+struct std::is_error_code_enum : std::true_type {};
 
 #endif
diff --git a/clang/include/clang/Frontend/SerializedDiagnosticReader.h 
b/clang/include/clang/Frontend/SerializedDiagnosticReader.h
index 309e0abb14613..f7c2012a7662a 100644
--- a/clang/include/clang/Frontend/SerializedDiagnosticReader.h
+++ b/clang/include/clang/Frontend/SerializedDiagnosticReader.h
@@ -128,11 +128,8 @@ class SerializedDiagnosticReader {
 } // namespace serialized_diags
 } // namespace clang
 
-namespace std {
-
 template <>
-struct is_error_code_enum : std::true_type 
{};
-
-} // namespace std
+struct std::is_error_code_enum
+: 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 {
 
 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::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
 BlockInCriticalSectionChecker::checkDescriptorMatch(const CallEvent &Call,

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][NFC] Avoid opening namespace std (PR #95470)

2024-06-13 Thread Balazs Benics via cfe-commits

https://github.com/steakhal approved this pull request.

LGTM. Please make clang format happy before merging.

https://github.com/llvm/llvm-project/pull/95470
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][NFC] Avoid opening namespace std (PR #95470)

2024-06-13 Thread via cfe-commits

https://github.com/Sirraide approved this pull request.

LGTM

https://github.com/llvm/llvm-project/pull/95470
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][NFC] Avoid opening namespace std (PR #95470)

2024-06-13 Thread via cfe-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff 45964eb9b88c46045e4e84beb4e2135cdeed6855 
f5fc162cd1a6fdef3dcdc3e4c73aedcf67b603df -- clang/include/clang/Format/Format.h 
clang/include/clang/Frontend/PrecompiledPreamble.h 
clang/include/clang/Frontend/SerializedDiagnosticReader.h 
clang/lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/include/clang/Frontend/SerializedDiagnosticReader.h 
b/clang/include/clang/Frontend/SerializedDiagnosticReader.h
index 96d576a63b..f7c2012a76 100644
--- a/clang/include/clang/Frontend/SerializedDiagnosticReader.h
+++ b/clang/include/clang/Frontend/SerializedDiagnosticReader.h
@@ -129,6 +129,7 @@ protected:
 } // namespace clang
 
 template <>
-struct std::is_error_code_enum : 
std::true_type {};
+struct std::is_error_code_enum
+: std::true_type {};
 
 #endif // LLVM_CLANG_FRONTEND_SERIALIZEDDIAGNOSTICREADER_H

``




https://github.com/llvm/llvm-project/pull/95470
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][NFC] Avoid opening namespace std (PR #95470)

2024-06-13 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-clang-modules
@llvm/pr-subscribers-clang-format

@llvm/pr-subscribers-clang-static-analyzer-1

Author: Nikolas Klauser (philnik777)


Changes

Never opening `namespace std` avoids even the possibility of introducing new 
symbols as well as making the code a bit shorter by removing unnecessary boiler 
plate.



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


4 Files Affected:

- (modified) clang/include/clang/Format/Format.h (+1-3) 
- (modified) clang/include/clang/Frontend/PrecompiledPreamble.h (+1-3) 
- (modified) clang/include/clang/Frontend/SerializedDiagnosticReader.h (+1-5) 
- (modified) 
clang/lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp (+1-3) 


``diff
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 : std::true_type {};
-} // namespace std
+struct std::is_error_code_enum : 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 : std::true_type {};
-} // namespace std
+struct std::is_error_code_enum : 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 : std::true_type 
{};
-
-} // namespace std
+struct std::is_error_code_enum : 
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 {
 
 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::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
 BlockInCriticalSectionChecker::checkDescriptorMatch(const CallEvent &Call,

``




https://github.com/llvm/llvm-project/pull/95470
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][NFC] Avoid opening namespace std (PR #95470)

2024-06-13 Thread Nikolas Klauser via cfe-commits

https://github.com/philnik777 created 
https://github.com/llvm/llvm-project/pull/95470

Never opening `namespace std` avoids even the possibility of introducing new 
symbols as well as making the code a bit shorter by removing unnecessary boiler 
plate.



>From f5fc162cd1a6fdef3dcdc3e4c73aedcf67b603df Mon Sep 17 00:00:00 2001
From: Nikolas Klauser 
Date: Thu, 13 Jun 2024 22:24:17 +0200
Subject: [PATCH] [Clang] Avoid opening namespace std

---
 clang/include/clang/Format/Format.h | 4 +---
 clang/include/clang/Frontend/PrecompiledPreamble.h  | 4 +---
 clang/include/clang/Frontend/SerializedDiagnosticReader.h   | 6 +-
 .../Checkers/BlockInCriticalSectionChecker.cpp  | 4 +---
 4 files changed, 4 insertions(+), 14 deletions(-)

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 : std::true_type {};
-} // namespace std
+struct std::is_error_code_enum : 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 : std::true_type {};
-} // namespace std
+struct std::is_error_code_enum : 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 : std::true_type 
{};
-
-} // namespace std
+struct std::is_error_code_enum : 
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 {
 
 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::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
 BlockInCriticalSectionChecker::checkDescriptorMatch(const CallEvent &Call,

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits