Skip to content

Commit e9f19c2

Browse files
committed
Merge main into amd-gfx
2 parents d906933 + 92fc4b4 commit e9f19c2

File tree

1,088 files changed

+79373
-91295
lines changed

Some content is hidden

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

1,088 files changed

+79373
-91295
lines changed

.git-blame-ignore-revs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,6 @@ f6d557ee34b6bbdb1dc32f29e34b4a4a8ad35e81
7070

7171
# [libc++] Replace uses of _VSTD:: by std:: (#74331)
7272
77a00c0d546cd4aa8311b5b9031ae9ea8cdb050c
73+
74+
# [libc++] Format the code base (#74334)
75+
9783f28cbb155e4a8d49c12e1c60ce14dcfaf0c7

.gitattributes

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
libcxx/src/**/*.cpp merge=libcxx-reformat
2+
libcxx/include/**/*.h merge=libcxx-reformat
3+
4+
# Explicitly handle files with no extension
5+
libcxx/include/__availability merge=libcxx-reformat
6+
libcxx/include/__bit_reference merge=libcxx-reformat
7+
libcxx/include/__config merge=libcxx-reformat
8+
libcxx/include/__hash_table merge=libcxx-reformat
9+
libcxx/include/__locale merge=libcxx-reformat
10+
libcxx/include/__node_handle merge=libcxx-reformat
11+
libcxx/include/__split_buffer merge=libcxx-reformat
12+
libcxx/include/__std_clang_module merge=libcxx-reformat
13+
libcxx/include/__threading_support merge=libcxx-reformat
14+
libcxx/include/__tree merge=libcxx-reformat
15+
libcxx/include/__verbose_abort merge=libcxx-reformat
16+
libcxx/include/algorithm merge=libcxx-reformat
17+
libcxx/include/any merge=libcxx-reformat
18+
libcxx/include/array merge=libcxx-reformat
19+
libcxx/include/atomic merge=libcxx-reformat
20+
libcxx/include/barrier merge=libcxx-reformat
21+
libcxx/include/bit merge=libcxx-reformat
22+
libcxx/include/bitset merge=libcxx-reformat
23+
libcxx/include/cassert merge=libcxx-reformat
24+
libcxx/include/ccomplex merge=libcxx-reformat
25+
libcxx/include/cctype merge=libcxx-reformat
26+
libcxx/include/cerrno merge=libcxx-reformat
27+
libcxx/include/cfenv merge=libcxx-reformat
28+
libcxx/include/cfloat merge=libcxx-reformat
29+
libcxx/include/charconv merge=libcxx-reformat
30+
libcxx/include/chrono merge=libcxx-reformat
31+
libcxx/include/cinttypes merge=libcxx-reformat
32+
libcxx/include/ciso646 merge=libcxx-reformat
33+
libcxx/include/climits merge=libcxx-reformat
34+
libcxx/include/clocale merge=libcxx-reformat
35+
libcxx/include/cmath merge=libcxx-reformat
36+
libcxx/include/codecvt merge=libcxx-reformat
37+
libcxx/include/compare merge=libcxx-reformat
38+
libcxx/include/complex merge=libcxx-reformat
39+
libcxx/include/concepts merge=libcxx-reformat
40+
libcxx/include/condition_variable merge=libcxx-reformat
41+
libcxx/include/coroutine merge=libcxx-reformat
42+
libcxx/include/csetjmp merge=libcxx-reformat
43+
libcxx/include/csignal merge=libcxx-reformat
44+
libcxx/include/cstdarg merge=libcxx-reformat
45+
libcxx/include/cstdbool merge=libcxx-reformat
46+
libcxx/include/cstddef merge=libcxx-reformat
47+
libcxx/include/cstdint merge=libcxx-reformat
48+
libcxx/include/cstdio merge=libcxx-reformat
49+
libcxx/include/cstdlib merge=libcxx-reformat
50+
libcxx/include/cstring merge=libcxx-reformat
51+
libcxx/include/ctgmath merge=libcxx-reformat
52+
libcxx/include/ctime merge=libcxx-reformat
53+
libcxx/include/cuchar merge=libcxx-reformat
54+
libcxx/include/cwchar merge=libcxx-reformat
55+
libcxx/include/cwctype merge=libcxx-reformat
56+
libcxx/include/deque merge=libcxx-reformat
57+
libcxx/include/exception merge=libcxx-reformat
58+
libcxx/include/execution merge=libcxx-reformat
59+
libcxx/include/expected merge=libcxx-reformat
60+
libcxx/include/experimental/__config merge=libcxx-reformat
61+
libcxx/include/experimental/__memory merge=libcxx-reformat
62+
libcxx/include/experimental/deque merge=libcxx-reformat
63+
libcxx/include/experimental/forward_list merge=libcxx-reformat
64+
libcxx/include/experimental/iterator merge=libcxx-reformat
65+
libcxx/include/experimental/list merge=libcxx-reformat
66+
libcxx/include/experimental/map merge=libcxx-reformat
67+
libcxx/include/experimental/memory merge=libcxx-reformat
68+
libcxx/include/experimental/memory_resource merge=libcxx-reformat
69+
libcxx/include/experimental/propagate_const merge=libcxx-reformat
70+
libcxx/include/experimental/regex merge=libcxx-reformat
71+
libcxx/include/experimental/set merge=libcxx-reformat
72+
libcxx/include/experimental/simd merge=libcxx-reformat
73+
libcxx/include/experimental/string merge=libcxx-reformat
74+
libcxx/include/experimental/type_traits merge=libcxx-reformat
75+
libcxx/include/experimental/unordered_map merge=libcxx-reformat
76+
libcxx/include/experimental/unordered_set merge=libcxx-reformat
77+
libcxx/include/experimental/utility merge=libcxx-reformat
78+
libcxx/include/experimental/vector merge=libcxx-reformat
79+
libcxx/include/ext/__hash merge=libcxx-reformat
80+
libcxx/include/ext/hash_map merge=libcxx-reformat
81+
libcxx/include/ext/hash_set merge=libcxx-reformat
82+
libcxx/include/filesystem merge=libcxx-reformat
83+
libcxx/include/format merge=libcxx-reformat
84+
libcxx/include/forward_list merge=libcxx-reformat
85+
libcxx/include/fstream merge=libcxx-reformat
86+
libcxx/include/functional merge=libcxx-reformat
87+
libcxx/include/future merge=libcxx-reformat
88+
libcxx/include/initializer_list merge=libcxx-reformat
89+
libcxx/include/iomanip merge=libcxx-reformat
90+
libcxx/include/ios merge=libcxx-reformat
91+
libcxx/include/iosfwd merge=libcxx-reformat
92+
libcxx/include/iostream merge=libcxx-reformat
93+
libcxx/include/istream merge=libcxx-reformat
94+
libcxx/include/iterator merge=libcxx-reformat
95+
libcxx/include/latch merge=libcxx-reformat
96+
libcxx/include/limits merge=libcxx-reformat
97+
libcxx/include/list merge=libcxx-reformat
98+
libcxx/include/locale merge=libcxx-reformat
99+
libcxx/include/map merge=libcxx-reformat
100+
libcxx/include/mdspan merge=libcxx-reformat
101+
libcxx/include/memory merge=libcxx-reformat
102+
libcxx/include/memory_resource merge=libcxx-reformat
103+
libcxx/include/mutex merge=libcxx-reformat
104+
libcxx/include/new merge=libcxx-reformat
105+
libcxx/include/numbers merge=libcxx-reformat
106+
libcxx/include/numeric merge=libcxx-reformat
107+
libcxx/include/optional merge=libcxx-reformat
108+
libcxx/include/ostream merge=libcxx-reformat
109+
libcxx/include/print merge=libcxx-reformat
110+
libcxx/include/queue merge=libcxx-reformat
111+
libcxx/include/random merge=libcxx-reformat
112+
libcxx/include/ranges merge=libcxx-reformat
113+
libcxx/include/ratio merge=libcxx-reformat
114+
libcxx/include/regex merge=libcxx-reformat
115+
libcxx/include/scoped_allocator merge=libcxx-reformat
116+
libcxx/include/semaphore merge=libcxx-reformat
117+
libcxx/include/set merge=libcxx-reformat
118+
libcxx/include/shared_mutex merge=libcxx-reformat
119+
libcxx/include/source_location merge=libcxx-reformat
120+
libcxx/include/span merge=libcxx-reformat
121+
libcxx/include/sstream merge=libcxx-reformat
122+
libcxx/include/stack merge=libcxx-reformat
123+
libcxx/include/stdexcept merge=libcxx-reformat
124+
libcxx/include/stop_token merge=libcxx-reformat
125+
libcxx/include/streambuf merge=libcxx-reformat
126+
libcxx/include/string merge=libcxx-reformat
127+
libcxx/include/string_view merge=libcxx-reformat
128+
libcxx/include/strstream merge=libcxx-reformat
129+
libcxx/include/syncstream merge=libcxx-reformat
130+
libcxx/include/system_error merge=libcxx-reformat
131+
libcxx/include/thread merge=libcxx-reformat
132+
libcxx/include/tuple merge=libcxx-reformat
133+
libcxx/include/type_traits merge=libcxx-reformat
134+
libcxx/include/typeindex merge=libcxx-reformat
135+
libcxx/include/typeinfo merge=libcxx-reformat
136+
libcxx/include/unordered_map merge=libcxx-reformat
137+
libcxx/include/unordered_set merge=libcxx-reformat
138+
libcxx/include/utility merge=libcxx-reformat
139+
libcxx/include/valarray merge=libcxx-reformat
140+
libcxx/include/variant merge=libcxx-reformat
141+
libcxx/include/vector merge=libcxx-reformat
142+
libcxx/include/version merge=libcxx-reformat

.mailmap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Martin Storsjö <[email protected]>
4343
Med Ismail Bennani <[email protected]> <[email protected]>
4444
Med Ismail Bennani <[email protected]> <[email protected]>
4545
Ramkumar Ramachandra <[email protected]> <[email protected]>
46+
Ramkumar Ramachandra <[email protected]> <[email protected]>
4647
Saleem Abdulrasool <[email protected]>
4748
4849
Wang Pengcheng <[email protected]>

clang-tools-extra/clangd/CompileCommands.cpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
#include "llvm/Support/MemoryBuffer.h"
2929
#include "llvm/Support/Path.h"
3030
#include "llvm/Support/Program.h"
31-
#include "llvm/TargetParser/Host.h"
3231
#include <iterator>
3332
#include <optional>
3433
#include <string>
@@ -187,12 +186,6 @@ static std::string resolveDriver(llvm::StringRef Driver, bool FollowSymlink,
187186

188187
} // namespace
189188

190-
CommandMangler::CommandMangler() {
191-
Tokenizer = llvm::Triple(llvm::sys::getProcessTriple()).isOSWindows()
192-
? llvm::cl::TokenizeWindowsCommandLine
193-
: llvm::cl::TokenizeGNUCommandLine;
194-
}
195-
196189
CommandMangler CommandMangler::detect() {
197190
CommandMangler Result;
198191
Result.ClangPath = detectClangPath();
@@ -213,14 +206,6 @@ void CommandMangler::operator()(tooling::CompileCommand &Command,
213206
if (Cmd.empty())
214207
return;
215208

216-
// FS used for expanding response files.
217-
// FIXME: ExpandResponseFiles appears not to provide the usual
218-
// thread-safety guarantees, as the access to FS is not locked!
219-
// For now, use the real FS, which is known to be threadsafe (if we don't
220-
// use/change working directory, which ExpandResponseFiles doesn't).
221-
auto FS = llvm::vfs::getRealFileSystem();
222-
tooling::addExpandedResponseFiles(Cmd, Command.Directory, Tokenizer, *FS);
223-
224209
auto &OptTable = clang::driver::getDriverOptTable();
225210
// OriginalArgs needs to outlive ArgList.
226211
llvm::SmallVector<const char *, 16> OriginalArgs;

clang-tools-extra/clangd/CompileCommands.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,8 @@ struct CommandMangler {
5151
llvm::StringRef TargetFile) const;
5252

5353
private:
54-
CommandMangler();
55-
5654
Memoize<llvm::StringMap<std::string>> ResolvedDrivers;
5755
Memoize<llvm::StringMap<std::string>> ResolvedDriversNoFollow;
58-
llvm::cl::TokenizerCallback Tokenizer;
5956
};
6057

6158
// Removes args from a command-line in a semantically-aware way.

clang-tools-extra/clangd/GlobalCompilationDatabase.cpp

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@
1818
#include "clang/Tooling/CompilationDatabase.h"
1919
#include "clang/Tooling/CompilationDatabasePluginRegistry.h"
2020
#include "clang/Tooling/JSONCompilationDatabase.h"
21+
#include "clang/Tooling/Tooling.h"
2122
#include "llvm/ADT/PointerIntPair.h"
2223
#include "llvm/ADT/STLExtras.h"
2324
#include "llvm/ADT/ScopeExit.h"
2425
#include "llvm/ADT/SmallString.h"
2526
#include "llvm/ADT/StringMap.h"
2627
#include "llvm/Support/Path.h"
2728
#include "llvm/Support/VirtualFileSystem.h"
29+
#include "llvm/TargetParser/Host.h"
2830
#include <atomic>
2931
#include <chrono>
3032
#include <condition_variable>
@@ -244,7 +246,16 @@ static std::unique_ptr<tooling::CompilationDatabase>
244246
parseJSON(PathRef Path, llvm::StringRef Data, std::string &Error) {
245247
if (auto CDB = tooling::JSONCompilationDatabase::loadFromBuffer(
246248
Data, Error, tooling::JSONCommandLineSyntax::AutoDetect)) {
247-
return tooling::inferMissingCompileCommands(std::move(CDB));
249+
// FS used for expanding response files.
250+
// FIXME: ExpandResponseFilesDatabase appears not to provide the usual
251+
// thread-safety guarantees, as the access to FS is not locked!
252+
// For now, use the real FS, which is known to be threadsafe (if we don't
253+
// use/change working directory, which ExpandResponseFilesDatabase doesn't).
254+
// NOTE: response files have to be expanded before inference because
255+
// inference needs full command line to check/fix driver mode and file type.
256+
auto FS = llvm::vfs::getRealFileSystem();
257+
return tooling::inferMissingCompileCommands(
258+
expandResponseFiles(std::move(CDB), std::move(FS)));
248259
}
249260
return nullptr;
250261
}
@@ -744,6 +755,22 @@ OverlayCDB::getCompileCommand(PathRef File) const {
744755
if (It != Commands.end())
745756
Cmd = It->second;
746757
}
758+
if (Cmd) {
759+
// FS used for expanding response files.
760+
// FIXME: ExpandResponseFiles appears not to provide the usual
761+
// thread-safety guarantees, as the access to FS is not locked!
762+
// For now, use the real FS, which is known to be threadsafe (if we don't
763+
// use/change working directory, which ExpandResponseFiles doesn't).
764+
auto FS = llvm::vfs::getRealFileSystem();
765+
auto Tokenizer = llvm::Triple(llvm::sys::getProcessTriple()).isOSWindows()
766+
? llvm::cl::TokenizeWindowsCommandLine
767+
: llvm::cl::TokenizeGNUCommandLine;
768+
// Compile command pushed via LSP protocol may have response files that need
769+
// to be expanded before further processing. For CDB for files it happens in
770+
// the main CDB when reading it from the JSON file.
771+
tooling::addExpandedResponseFiles(Cmd->CommandLine, Cmd->Directory,
772+
Tokenizer, *FS);
773+
}
747774
if (!Cmd)
748775
Cmd = DelegatingCDB::getCompileCommand(File);
749776
if (!Cmd)

clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -209,21 +209,6 @@ TEST(CommandMangler, ConfigEdits) {
209209
ElementsAre(_, "--driver-mode=g++", "--hello", "--", "FOO.CC"));
210210
}
211211

212-
TEST(CommandMangler, ExpandedResponseFiles) {
213-
SmallString<1024> Path;
214-
int FD;
215-
ASSERT_FALSE(llvm::sys::fs::createTemporaryFile("args", "", FD, Path));
216-
llvm::raw_fd_ostream OutStream(FD, true);
217-
OutStream << "-Wall";
218-
OutStream.close();
219-
220-
auto Mangler = CommandMangler::forTests();
221-
tooling::CompileCommand Cmd;
222-
Cmd.CommandLine = {"clang", ("@" + Path).str(), "foo.cc"};
223-
Mangler(Cmd, "foo.cc");
224-
EXPECT_THAT(Cmd.CommandLine, ElementsAre(_, "-Wall", "--", "foo.cc"));
225-
}
226-
227212
static std::string strip(llvm::StringRef Arg, llvm::StringRef Argv) {
228213
llvm::SmallVector<llvm::StringRef> Parts;
229214
llvm::SplitString(Argv, Parts);

clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,21 @@ TEST_F(OverlayCDBTest, Adjustments) {
163163
"-DFallback", "-DAdjust_baz.cc"));
164164
}
165165

166+
TEST_F(OverlayCDBTest, ExpandedResponseFiles) {
167+
SmallString<1024> Path;
168+
int FD;
169+
ASSERT_FALSE(llvm::sys::fs::createTemporaryFile("args", "", FD, Path));
170+
llvm::raw_fd_ostream OutStream(FD, true);
171+
OutStream << "-Wall";
172+
OutStream.close();
173+
174+
OverlayCDB CDB(Base.get(), {"-DFallback"});
175+
auto Override = cmd(testPath("foo.cc"), ("@" + Path).str());
176+
CDB.setCompileCommand(testPath("foo.cc"), Override);
177+
EXPECT_THAT(CDB.getCompileCommand(testPath("foo.cc"))->CommandLine,
178+
Contains("-Wall"));
179+
}
180+
166181
TEST(GlobalCompilationDatabaseTest, DiscoveryWithNestedCDBs) {
167182
const char *const CDBOuter =
168183
R"cdb(
@@ -421,6 +436,45 @@ TEST_F(OverlayCDBTest, GetProjectInfo) {
421436
EXPECT_EQ(DB.getProjectInfo(File)->SourceRoot, testRoot());
422437
EXPECT_EQ(DB.getProjectInfo(Header)->SourceRoot, testRoot());
423438
}
439+
440+
TEST(GlobalCompilationDatabaseTest, InferenceWithResponseFile) {
441+
MockFS FS;
442+
auto Command = [&](llvm::StringRef Relative) {
443+
DirectoryBasedGlobalCompilationDatabase::Options Opts(FS);
444+
return DirectoryBasedGlobalCompilationDatabase(Opts)
445+
.getCompileCommand(testPath(Relative))
446+
.value_or(tooling::CompileCommand())
447+
.CommandLine;
448+
};
449+
EXPECT_THAT(Command("foo.cc"), IsEmpty());
450+
451+
// Have to use real FS for response file.
452+
SmallString<1024> Path;
453+
int FD;
454+
ASSERT_FALSE(llvm::sys::fs::createTemporaryFile("args", "", FD, Path));
455+
llvm::raw_fd_ostream OutStream(FD, true);
456+
OutStream << "-DXYZZY";
457+
OutStream.close();
458+
459+
const char *const CDB =
460+
R"cdb(
461+
[
462+
{
463+
"file": "{0}/foo.cc",
464+
"command": "clang @{1} {0}/foo.cc",
465+
"directory": "{0}",
466+
}
467+
]
468+
)cdb";
469+
FS.Files[testPath("compile_commands.json")] =
470+
llvm::formatv(CDB, llvm::sys::path::convert_to_slash(testRoot()),
471+
llvm::sys::path::convert_to_slash(Path));
472+
473+
// File from CDB.
474+
EXPECT_THAT(Command("foo.cc"), Contains("-DXYZZY"));
475+
// File not in CDB, use inference.
476+
EXPECT_THAT(Command("foo.h"), Contains("-DXYZZY"));
477+
}
424478
} // namespace
425479

426480
// Friend test has access to internals.

clang/docs/ReleaseNotes.rst

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,6 @@ C Language Changes
199199
- ``structs``, ``unions``, and ``arrays`` that are const may now be used as
200200
constant expressions. This change is more consistent with the behavior of
201201
GCC.
202-
- Clang now supports the C-only attribute ``counted_by``. When applied to a
203-
struct's flexible array member, it points to the struct field that holds the
204-
number of elements in the flexible array member. This information can improve
205-
the results of the array bound sanitizer and the
206-
``__builtin_dynamic_object_size`` builtin.
207202
- Enums will now be represented in TBAA metadata using their actual underlying
208203
integer type. Previously they were treated as chars, which meant they could
209204
alias with all other types.

0 commit comments

Comments
 (0)