Skip to content

Commit 4184d33

Browse files
authored
[Clang][NFC] Avoid opening namespace std (llvm#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.
1 parent 53c93a3 commit 4184d33

File tree

4 files changed

+5
-14
lines changed

4 files changed

+5
-14
lines changed

clang/include/clang/Format/Format.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5430,9 +5430,7 @@ bool isClangFormatOff(StringRef Comment);
54305430
} // end namespace format
54315431
} // end namespace clang
54325432

5433-
namespace std {
54345433
template <>
5435-
struct is_error_code_enum<clang::format::ParseError> : std::true_type {};
5436-
} // namespace std
5434+
struct std::is_error_code_enum<clang::format::ParseError> : std::true_type {};
54375435

54385436
#endif // LLVM_CLANG_FORMAT_FORMAT_H

clang/include/clang/Frontend/PrecompiledPreamble.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,7 @@ class BuildPreambleErrorCategory final : public std::error_category {
256256
std::error_code make_error_code(BuildPreambleError Error);
257257
} // namespace clang
258258

259-
namespace std {
260259
template <>
261-
struct is_error_code_enum<clang::BuildPreambleError> : std::true_type {};
262-
} // namespace std
260+
struct std::is_error_code_enum<clang::BuildPreambleError> : std::true_type {};
263261

264262
#endif

clang/include/clang/Frontend/SerializedDiagnosticReader.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,8 @@ class SerializedDiagnosticReader {
128128
} // namespace serialized_diags
129129
} // namespace clang
130130

131-
namespace std {
132-
133131
template <>
134-
struct is_error_code_enum<clang::serialized_diags::SDError> : std::true_type {};
135-
136-
} // namespace std
132+
struct std::is_error_code_enum<clang::serialized_diags::SDError>
133+
: std::true_type {};
137134

138135
#endif // LLVM_CLANG_FRONTEND_SERIALIZEDDIAGNOSTICREADER_H

clang/lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,21 +202,19 @@ class BlockInCriticalSectionChecker : public Checker<check::PostCall> {
202202

203203
REGISTER_LIST_WITH_PROGRAMSTATE(ActiveCritSections, CritSectionMarker)
204204

205-
namespace std {
206205
// Iterator traits for ImmutableList data structure
207206
// that enable the use of STL algorithms.
208207
// TODO: Move these to llvm::ImmutableList when overhauling immutable data
209208
// structures for proper iterator concept support.
210209
template <>
211-
struct iterator_traits<
210+
struct std::iterator_traits<
212211
typename llvm::ImmutableList<CritSectionMarker>::iterator> {
213212
using iterator_category = std::forward_iterator_tag;
214213
using value_type = CritSectionMarker;
215214
using difference_type = std::ptrdiff_t;
216215
using reference = CritSectionMarker &;
217216
using pointer = CritSectionMarker *;
218217
};
219-
} // namespace std
220218

221219
std::optional<MutexDescriptor>
222220
BlockInCriticalSectionChecker::checkDescriptorMatch(const CallEvent &Call,

0 commit comments

Comments
 (0)