Skip to content

Commit 3ae29e2

Browse files
committed
Merge from 'main' to 'sycl-web' (87 commits)
CONFLICT (content): Merge conflict in openmp/libomptarget/test/lit.cfg
2 parents fc5268f + 49efb08 commit 3ae29e2

File tree

541 files changed

+11910
-5563
lines changed

Some content is hidden

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

541 files changed

+11910
-5563
lines changed

.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: 3 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.
@@ -691,6 +686,9 @@ Bug Fixes in This Version
691686
- Fix an issue where clang doesn't respect detault template arguments that
692687
are added in a later redeclaration for CTAD.
693688
Fixes (#69987 <https://github.com/llvm/llvm-project/issues/69987>`_)
689+
- Fix an issue where CTAD fails for explicit type conversion.
690+
Fixes (#64347 <https://github.com/llvm/llvm-project/issues/64347>`_)
691+
694692

695693
Bug Fixes to Compiler Builtins
696694
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

clang/include/clang/AST/Decl.h

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,8 @@ class NamedDecl : public Decl {
359359
///
360360
/// \param IsKnownNewer \c true if this declaration is known to be newer
361361
/// than \p OldD (for instance, if this declaration is newly-created).
362-
bool declarationReplaces(NamedDecl *OldD, bool IsKnownNewer = true) const;
362+
bool declarationReplaces(const NamedDecl *OldD,
363+
bool IsKnownNewer = true) const;
363364

364365
/// Determine whether this declaration has linkage.
365366
bool hasLinkage() const;
@@ -4333,30 +4334,6 @@ class RecordDecl : public TagDecl {
43334334
return field_begin() == field_end();
43344335
}
43354336

4336-
FieldDecl *getLastField() {
4337-
FieldDecl *FD = nullptr;
4338-
for (FieldDecl *Field : fields())
4339-
FD = Field;
4340-
return FD;
4341-
}
4342-
const FieldDecl *getLastField() const {
4343-
return const_cast<RecordDecl *>(this)->getLastField();
4344-
}
4345-
4346-
template <typename Functor>
4347-
const FieldDecl *findFieldIf(Functor &Pred) const {
4348-
for (const Decl *D : decls()) {
4349-
if (const auto *FD = dyn_cast<FieldDecl>(D); FD && Pred(FD))
4350-
return FD;
4351-
4352-
if (const auto *RD = dyn_cast<RecordDecl>(D))
4353-
if (const FieldDecl *FD = RD->findFieldIf(Pred))
4354-
return FD;
4355-
}
4356-
4357-
return nullptr;
4358-
}
4359-
43604337
/// Note that the definition of this type is now complete.
43614338
virtual void completeDefinition();
43624339

clang/include/clang/AST/DeclBase.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include "clang/AST/SelectorLocationsKind.h"
2020
#include "clang/Basic/IdentifierTable.h"
2121
#include "clang/Basic/LLVM.h"
22-
#include "clang/Basic/LangOptions.h"
2322
#include "clang/Basic/SourceLocation.h"
2423
#include "clang/Basic/Specifiers.h"
2524
#include "llvm/ADT/ArrayRef.h"
@@ -489,15 +488,6 @@ class alignas(8) Decl {
489488
// Return true if this is a FileContext Decl.
490489
bool isFileContextDecl() const;
491490

492-
/// Whether it resembles a flexible array member. This is a static member
493-
/// because we want to be able to call it with a nullptr. That allows us to
494-
/// perform non-Decl specific checks based on the object's type and strict
495-
/// flex array level.
496-
static bool isFlexibleArrayMemberLike(
497-
ASTContext &Context, const Decl *D, QualType Ty,
498-
LangOptions::StrictFlexArraysLevelKind StrictFlexArraysLevel,
499-
bool IgnoreTemplateOrMacroSubstitution);
500-
501491
ASTContext &getASTContext() const LLVM_READONLY;
502492

503493
/// Helper to get the language options from the ASTContext.

clang/include/clang/Basic/Attr.td

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5396,24 +5396,6 @@ def AvailableOnlyInDefaultEvalMethod : InheritableAttr {
53965396
let Documentation = [Undocumented];
53975397
}
53985398

5399-
def CountedBy : InheritableAttr {
5400-
let Spellings = [Clang<"counted_by">];
5401-
let Subjects = SubjectList<[Field]>;
5402-
let Args = [IdentifierArgument<"CountedByField">];
5403-
let Documentation = [CountedByDocs];
5404-
let LangOpts = [COnly];
5405-
// FIXME: This is ugly. Let using a DeclArgument would be nice, but a Decl
5406-
// isn't yet available due to the fact that we're still parsing the
5407-
// structure. Maybe that code could be changed sometime in the future.
5408-
code AdditionalMembers = [{
5409-
private:
5410-
SourceRange CountedByFieldLoc;
5411-
public:
5412-
SourceRange getCountedByFieldLoc() const { return CountedByFieldLoc; }
5413-
void setCountedByFieldLoc(SourceRange Loc) { CountedByFieldLoc = Loc; }
5414-
}];
5415-
}
5416-
54175399
def PreferredType: InheritableAttr {
54185400
let Spellings = [Clang<"preferred_type">];
54195401
let Subjects = SubjectList<[BitField], ErrorDiag>;

clang/include/clang/Basic/AttrDocs.td

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -9204,72 +9204,6 @@ attribute, they default to the value ``65535``.
92049204
}];
92059205
}
92069206

9207-
def CountedByDocs : Documentation {
9208-
let Category = DocCatField;
9209-
let Content = [{
9210-
Clang supports the ``counted_by`` attribute on the flexible array member of a
9211-
structure in C. The argument for the attribute is the name of a field member in
9212-
the same structure holding the count of elements in the flexible array. This
9213-
information can be used to improve the results of the array bound sanitizer and
9214-
the ``__builtin_dynamic_object_size`` builtin.
9215-
9216-
For example, the following code:
9217-
9218-
.. code-block:: c
9219-
9220-
struct bar;
9221-
9222-
struct foo {
9223-
size_t count;
9224-
char other;
9225-
struct bar *array[] __attribute__((counted_by(count)));
9226-
};
9227-
9228-
specifies that the flexible array member ``array`` has the number of elements
9229-
allocated for it stored in ``count``. This establishes a relationship between
9230-
``array`` and ``count``. Specifically, ``p->array`` must have at least
9231-
``p->count`` number of elements available. It's the user's responsibility to
9232-
ensure that this relationship is maintained through changes to the structure.
9233-
9234-
In the following example, the allocated array erroneously has fewer elements
9235-
than what's specified by ``p->count``. This would result in an out-of-bounds
9236-
access not being detected.
9237-
9238-
.. code-block:: c
9239-
9240-
#define SIZE_INCR 42
9241-
9242-
struct foo *p;
9243-
9244-
void foo_alloc(size_t count) {
9245-
p = malloc(MAX(sizeof(struct foo),
9246-
offsetof(struct foo, array[0]) + count * sizeof(struct bar *)));
9247-
p->count = count + SIZE_INCR;
9248-
}
9249-
9250-
The next example updates ``p->count``, breaking the relationship requirement
9251-
that ``p->array`` must have at least ``p->count`` number of elements available:
9252-
9253-
.. code-block:: c
9254-
9255-
#define SIZE_INCR 42
9256-
9257-
struct foo *p;
9258-
9259-
void foo_alloc(size_t count) {
9260-
p = malloc(MAX(sizeof(struct foo),
9261-
offsetof(struct foo, array[0]) + count * sizeof(struct bar *)));
9262-
p->count = count;
9263-
}
9264-
9265-
void use_foo(int index) {
9266-
p->count += SIZE_INCR + 1; /* 'count' is now larger than the number of elements of 'array'. */
9267-
p->array[index] = 0; /* the sanitizer can't properly check if this is an out-of-bounds access. */
9268-
}
9269-
9270-
}];
9271-
}
9272-
92739207
def CoroOnlyDestroyWhenCompleteDocs : Documentation {
92749208
let Category = DocCatDecl;
92759209
let Content = [{

0 commit comments

Comments
 (0)