Skip to content

Commit ce9035f

Browse files
authored
Revert "[libc] Migrate to using LIBC_NAMESPACE_DECL for namespace declaration" (#98593)
Reverts #98075 bots are broken
1 parent 37d3f44 commit ce9035f

File tree

2,327 files changed

+4678
-7567
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,327 files changed

+4678
-7567
lines changed

libc/benchmarks/LibcDefaultImplementations.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
#include "LibcFunctionPrototypes.h"
2-
#include "src/__support/macros/config.h"
32
#include "llvm/ADT/ArrayRef.h"
43
#include <cstddef>
54

6-
namespace LIBC_NAMESPACE_DECL {
5+
namespace LIBC_NAMESPACE {
76

87
extern void *memcpy(void *__restrict, const void *__restrict, size_t);
98
extern void *memmove(void *, const void *, size_t);
@@ -12,7 +11,7 @@ extern void bzero(void *, size_t);
1211
extern int memcmp(const void *, const void *, size_t);
1312
extern int bcmp(const void *, const void *, size_t);
1413

15-
} // namespace LIBC_NAMESPACE_DECL
14+
} // namespace LIBC_NAMESPACE
1615

1716
// List of implementations to test.
1817

libc/benchmarks/LibcMemoryBenchmarkMain.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include "LibcBenchmark.h"
1111
#include "LibcMemoryBenchmark.h"
1212
#include "MemorySizeDistributions.h"
13-
#include "src/__support/macros/config.h"
1413
#include "llvm/Support/CommandLine.h"
1514
#include "llvm/Support/ErrorHandling.h"
1615
#include "llvm/Support/FileSystem.h"
@@ -22,7 +21,7 @@
2221
#include <cstring>
2322
#include <unistd.h>
2423

25-
namespace LIBC_NAMESPACE_DECL {
24+
namespace LIBC_NAMESPACE {
2625

2726
extern void *memcpy(void *__restrict, const void *__restrict, size_t);
2827
extern void *memmove(void *, const void *, size_t);
@@ -31,7 +30,7 @@ extern void bzero(void *, size_t);
3130
extern int memcmp(const void *, const void *, size_t);
3231
extern int bcmp(const void *, const void *, size_t);
3332

34-
} // namespace LIBC_NAMESPACE_DECL
33+
} // namespace LIBC_NAMESPACE
3534

3635
namespace llvm {
3736
namespace libc_benchmarks {

libc/benchmarks/automemcpy/lib/CodeGen.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
// function at the end of the file.
3737

3838
#include "automemcpy/CodeGen.h"
39-
#include "src/__support/macros/config.h"
4039
#include <cassert>
4140
#include <llvm/ADT/STLExtras.h>
4241
#include <llvm/ADT/StringSet.h>
@@ -543,11 +542,11 @@ static void Serialize(raw_ostream &Stream,
543542
Stream << "using llvm::libc_benchmarks::MemmoveConfiguration;\n";
544543
Stream << "using llvm::libc_benchmarks::MemsetConfiguration;\n";
545544
Stream << "\n";
546-
Stream << "namespace LIBC_NAMESPACE_DECL {\n";
545+
Stream << "namespace LIBC_NAMESPACE {\n";
547546
Stream << "\n";
548547
codegen::functions::Serialize(Stream, Descriptors);
549548
Stream << "\n";
550-
Stream << "} // namespace LIBC_NAMESPACE_DECL\n";
549+
Stream << "} // namespace LIBC_NAMESPACE\n";
551550
Stream << "\n";
552551
Stream << "namespace llvm {\n";
553552
Stream << "namespace automemcpy {\n";

libc/benchmarks/automemcpy/unittests/CodeGenTest.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
#include "automemcpy/CodeGen.h"
1010
#include "automemcpy/RandomFunctionGenerator.h"
11-
#include "src/__support/macros/config.h"
1211
#include "gmock/gmock.h"
1312
#include "gtest/gtest.h"
1413
#include <optional>
@@ -64,7 +63,7 @@ using llvm::libc_benchmarks::MemcpyConfiguration;
6463
using llvm::libc_benchmarks::MemmoveConfiguration;
6564
using llvm::libc_benchmarks::MemsetConfiguration;
6665
67-
namespace LIBC_NAMESPACE_DECL {
66+
namespace LIBC_NAMESPACE {
6867
6968
static void memcpy_0xE00E29EE73994E2B(char *__restrict dst, const char *__restrict src, size_t size) {
7069
using namespace LIBC_NAMESPACE::x86;
@@ -135,7 +134,7 @@ static void bzero_0x475977492C218AD4(char * dst, size_t size) {
135134
return splat_set<Align<_32,Arg::Dst>::Then<Loop<_32>>>(dst, 0, size);
136135
}
137136
138-
} // namespace LIBC_NAMESPACE_DECL
137+
} // namespace LIBC_NAMESPACE
139138
140139
namespace llvm {
141140
namespace automemcpy {

libc/benchmarks/gpu/BenchmarkLogger.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@
33
#include "src/__support/CPP/string_view.h"
44
#include "src/__support/OSUtil/io.h" // write_to_stderr
55
#include "src/__support/big_int.h" // is_big_int
6-
#include "src/__support/macros/config.h"
76
#include "src/__support/macros/properties/types.h" // LIBC_TYPES_HAS_INT128
87
#include "src/__support/uint128.h"
98

109
#include <stdint.h>
1110

12-
namespace LIBC_NAMESPACE_DECL {
11+
namespace LIBC_NAMESPACE {
1312
namespace benchmarks {
1413

1514
// cpp::string_view specialization
@@ -95,4 +94,4 @@ template BenchmarkLogger &BenchmarkLogger::operator<< <UInt<320>>(UInt<320>);
9594
BenchmarkLogger log;
9695

9796
} // namespace benchmarks
98-
} // namespace LIBC_NAMESPACE_DECL
97+
} // namespace LIBC_NAMESPACE

libc/benchmarks/gpu/BenchmarkLogger.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99
#ifndef LLVM_LIBC_BENCHMARKS_GPU_BENCHMARKLOGGER_H
1010
#define LLVM_LIBC_BENCHMARKS_GPU_BENCHMARKLOGGER_H
1111

12-
#include "src/__support/macros/config.h"
13-
14-
namespace LIBC_NAMESPACE_DECL {
12+
namespace LIBC_NAMESPACE {
1513
namespace benchmarks {
1614

1715
// A class to log to standard output in the context of hermetic tests.
@@ -24,6 +22,6 @@ struct BenchmarkLogger {
2422
extern BenchmarkLogger log;
2523

2624
} // namespace benchmarks
27-
} // namespace LIBC_NAMESPACE_DECL
25+
} // namespace LIBC_NAMESPACE
2826

2927
#endif /* LLVM_LIBC_BENCHMARKS_GPU_BENCHMARKLOGGER_H */

libc/benchmarks/gpu/LibcGpuBenchmark.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55
#include "src/__support/FPUtil/sqrt.h"
66
#include "src/__support/GPU/utils.h"
77
#include "src/__support/fixedvector.h"
8-
#include "src/__support/macros/config.h"
98
#include "src/time/gpu/time_utils.h"
109

11-
namespace LIBC_NAMESPACE_DECL {
10+
namespace LIBC_NAMESPACE {
1211
namespace benchmarks {
1312

1413
FixedVector<Benchmark *, 64> benchmarks;
@@ -136,4 +135,4 @@ BenchmarkResult benchmark(const BenchmarkOptions &options,
136135
};
137136

138137
} // namespace benchmarks
139-
} // namespace LIBC_NAMESPACE_DECL
138+
} // namespace LIBC_NAMESPACE

libc/benchmarks/gpu/LibcGpuBenchmark.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@
66
#include "src/__support/CPP/functional.h"
77
#include "src/__support/CPP/limits.h"
88
#include "src/__support/CPP/string_view.h"
9-
#include "src/__support/macros/config.h"
109
#include "src/time/clock.h"
1110

1211
#include <stdint.h>
1312

14-
namespace LIBC_NAMESPACE_DECL {
13+
namespace LIBC_NAMESPACE {
1514

1615
namespace benchmarks {
1716

@@ -100,7 +99,7 @@ class Benchmark {
10099
const cpp::string_view get_name() const { return name; }
101100
};
102101
} // namespace benchmarks
103-
} // namespace LIBC_NAMESPACE_DECL
102+
} // namespace LIBC_NAMESPACE
104103

105104
#define BENCHMARK(SuiteName, TestName, Func) \
106105
LIBC_NAMESPACE::benchmarks::Benchmark SuiteName##_##TestName##_Instance( \

libc/benchmarks/gpu/timing/amdgpu/timing.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
else \
2626
asm("" ::"v"(VARIABLE))
2727

28-
namespace LIBC_NAMESPACE_DECL {
28+
namespace LIBC_NAMESPACE {
2929

3030
// Returns the overhead associated with calling the profiling region. This
3131
// allows us to substract the constant-time overhead from the latency to
@@ -107,6 +107,6 @@ template <typename F, typename T1, typename T2>
107107
return stop - start;
108108
}
109109

110-
} // namespace LIBC_NAMESPACE_DECL
110+
} // namespace LIBC_NAMESPACE
111111

112112
#endif // LLVM_LIBC_UTILS_GPU_TIMING_AMDGPU

libc/benchmarks/gpu/timing/nvptx/timing.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
#include <stdint.h>
1818

19-
namespace LIBC_NAMESPACE_DECL {
19+
namespace LIBC_NAMESPACE {
2020

2121
// Returns the overhead associated with calling the profiling region. This
2222
// allows us to substract the constant-time overhead from the latency to
@@ -94,6 +94,6 @@ static LIBC_INLINE uint64_t latency(F f, T1 t1, T2 t2) {
9494

9595
return stop - start;
9696
}
97-
} // namespace LIBC_NAMESPACE_DECL
97+
} // namespace LIBC_NAMESPACE
9898

9999
#endif // LLVM_LIBC_UTILS_GPU_TIMING_NVPTX

libc/cmake/modules/LLVMLibCObjectRules.cmake

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,11 @@ function(create_object_library fq_target_name)
9393
endif()
9494
endif()
9595

96-
list(APPEND fq_deps_list libc.src.__support.macros.config)
97-
list(REMOVE_DUPLICATES fq_deps_list)
98-
add_dependencies(${fq_target_name} ${fq_deps_list})
99-
# Add deps as link libraries to inherit interface compile and link options.
100-
target_link_libraries(${fq_target_name} PUBLIC ${fq_deps_list})
96+
if(fq_deps_list)
97+
add_dependencies(${fq_target_name} ${fq_deps_list})
98+
# Add deps as link libraries to inherit interface compile and link options.
99+
target_link_libraries(${fq_target_name} PUBLIC ${fq_deps_list})
100+
endif()
101101

102102
set_target_properties(
103103
${fq_target_name}

libc/config/linux/app.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@
99
#ifndef LLVM_LIBC_CONFIG_LINUX_APP_H
1010
#define LLVM_LIBC_CONFIG_LINUX_APP_H
1111

12-
#include "src/__support/macros/config.h"
1312
#include "src/__support/macros/properties/architectures.h"
1413

1514
#include <stdint.h>
1615

17-
namespace LIBC_NAMESPACE_DECL {
16+
namespace LIBC_NAMESPACE {
1817

1918
// Data structure to capture properties of the linux/ELF TLS image.
2019
struct TLSImage {
@@ -105,6 +104,6 @@ void cleanup_tls(uintptr_t tls_addr, uintptr_t tls_size);
105104
// Set the thread pointer for the current thread.
106105
bool set_thread_ptr(uintptr_t val);
107106

108-
} // namespace LIBC_NAMESPACE_DECL
107+
} // namespace LIBC_NAMESPACE
109108

110109
#endif // LLVM_LIBC_CONFIG_LINUX_APP_H

libc/docs/dev/clang_tidy_checks.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,17 @@ implementation-in-namespace
3636
---------------------------
3737

3838
It is part of our implementation standards that all implementation pieces live
39-
under the ``LIBC_NAMESPACE_DECL`` namespace. This prevents pollution of the
40-
global namespace. Without a formal check to ensure this, an implementation
41-
might compile and pass unit tests, but not produce a usable libc function.
39+
under the ``LIBC_NAMESPACE`` namespace. This prevents pollution of the global
40+
namespace. Without a formal check to ensure this, an implementation might
41+
compile and pass unit tests, but not produce a usable libc function.
4242

4343
This check that ensures any function call resolves to a function within the
44-
``LIBC_NAMESPACE_DECL`` namespace.
44+
``LIBC_NAMESPACE`` namespace.
4545

4646
.. code-block:: c++
4747

4848
// Correct: implementation inside the correct namespace.
49-
namespace LIBC_NAMESPACE_DECL {
49+
namespace LIBC_NAMESPACE {
5050
void LLVM_LIBC_ENTRYPOINT(strcpy)(char *dest, const char *src) {}
5151
// Namespaces within LIBC_NAMESPACE namespace are allowed.
5252
namespace inner{
@@ -87,7 +87,7 @@ are always external and can be intercepted.
8787

8888
.. code-block:: c++
8989

90-
namespace LIBC_NAMESPACE_DECL {
90+
namespace LIBC_NAMESPACE {
9191

9292
// Allow calls with the fully qualified name.
9393
LIBC_NAMESPACE::strlen("hello");
@@ -104,4 +104,4 @@ are always external and can be intercepted.
104104
// Allow calling into specific global functions (explained above)
105105
::malloc(10);
106106

107-
} // namespace LIBC_NAMESPACE_DECL
107+
} // namespace LIBC_NAMESPACE

libc/fuzzing/__support/hashtable_fuzz.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@
1212
#include "include/llvm-libc-types/ENTRY.h"
1313
#include "src/__support/CPP/string_view.h"
1414
#include "src/__support/HashTable/table.h"
15-
#include "src/__support/macros/config.h"
1615

17-
namespace LIBC_NAMESPACE_DECL {
16+
namespace LIBC_NAMESPACE {
1817

1918
// A fuzzing payload starts with
2019
// - uint16_t: initial capacity for table A
@@ -180,4 +179,4 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
180179
return 0;
181180
}
182181

183-
} // namespace LIBC_NAMESPACE_DECL
182+
} // namespace LIBC_NAMESPACE

libc/src/__support/CPP/algorithm.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@
1313
#define LLVM_LIBC_SRC___SUPPORT_CPP_ALGORITHM_H
1414

1515
#include "src/__support/macros/attributes.h" // LIBC_INLINE
16-
#include "src/__support/macros/config.h"
1716

18-
namespace LIBC_NAMESPACE_DECL {
17+
namespace LIBC_NAMESPACE {
1918
namespace cpp {
2019

2120
template <class T> LIBC_INLINE constexpr const T &max(const T &a, const T &b) {
@@ -42,6 +41,6 @@ LIBC_INLINE constexpr bool all_of(InputIt first, InputIt last, UnaryPred p) {
4241
}
4342

4443
} // namespace cpp
45-
} // namespace LIBC_NAMESPACE_DECL
44+
} // namespace LIBC_NAMESPACE
4645

4746
#endif // LLVM_LIBC_SRC___SUPPORT_CPP_ALGORITHM_H

libc/src/__support/CPP/array.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@
1111

1212
#include "src/__support/CPP/iterator.h" // reverse_iterator
1313
#include "src/__support/macros/attributes.h"
14-
#include "src/__support/macros/config.h"
1514
#include <stddef.h> // For size_t.
1615

17-
namespace LIBC_NAMESPACE_DECL {
16+
namespace LIBC_NAMESPACE {
1817
namespace cpp {
1918

2019
template <class T, size_t N> struct array {
@@ -75,6 +74,6 @@ template <class T, size_t N> struct array {
7574
};
7675

7776
} // namespace cpp
78-
} // namespace LIBC_NAMESPACE_DECL
77+
} // namespace LIBC_NAMESPACE
7978

8079
#endif // LLVM_LIBC_SRC___SUPPORT_CPP_ARRAY_H

libc/src/__support/CPP/atomic.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,11 @@
1010
#define LLVM_LIBC_SRC___SUPPORT_CPP_ATOMIC_H
1111

1212
#include "src/__support/macros/attributes.h"
13-
#include "src/__support/macros/config.h"
1413
#include "src/__support/macros/properties/architectures.h"
1514

1615
#include "type_traits.h"
1716

18-
namespace LIBC_NAMESPACE_DECL {
17+
namespace LIBC_NAMESPACE {
1918
namespace cpp {
2019

2120
enum class MemoryOrder : int {
@@ -212,6 +211,6 @@ LIBC_INLINE void atomic_signal_fence([[maybe_unused]] MemoryOrder mem_ord) {
212211
}
213212

214213
} // namespace cpp
215-
} // namespace LIBC_NAMESPACE_DECL
214+
} // namespace LIBC_NAMESPACE
216215

217216
#endif // LLVM_LIBC_SRC___SUPPORT_CPP_ATOMIC_H

libc/src/__support/CPP/bit.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,11 @@
1414
#include "src/__support/CPP/limits.h" // numeric_limits
1515
#include "src/__support/CPP/type_traits.h"
1616
#include "src/__support/macros/attributes.h"
17-
#include "src/__support/macros/config.h"
1817
#include "src/__support/macros/sanitizer.h"
1918

2019
#include <stdint.h>
2120

22-
namespace LIBC_NAMESPACE_DECL {
23-
namespace cpp {
21+
namespace LIBC_NAMESPACE::cpp {
2422

2523
#if __has_builtin(__builtin_memcpy_inline)
2624
#define LLVM_LIBC_HAS_BUILTIN_MEMCPY_INLINE
@@ -292,7 +290,6 @@ ADD_SPECIALIZATION(unsigned long long, __builtin_popcountll)
292290
#endif // __builtin_popcountg
293291
#undef ADD_SPECIALIZATION
294292

295-
} // namespace cpp
296-
} // namespace LIBC_NAMESPACE_DECL
293+
} // namespace LIBC_NAMESPACE::cpp
297294

298295
#endif // LLVM_LIBC_SRC___SUPPORT_CPP_BIT_H

0 commit comments

Comments
 (0)