Skip to content

Commit 34bf114

Browse files
authored
Merge tag 'llvmorg-20.1.8' into emscripten-libs-20
Merge tag 'llvmorg-20.1.8' into emscripten-libs-20
2 parents a995a8b + 86111d6 commit 34bf114

File tree

251 files changed

+6331
-1054
lines changed

Some content is hidden

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

251 files changed

+6331
-1054
lines changed

clang-tools-extra/clang-tidy/tool/run-clang-tidy.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def find_compilation_database(path: str) -> str:
8787

8888

8989
def get_tidy_invocation(
90-
f: str,
90+
f: Optional[str],
9191
clang_tidy_binary: str,
9292
checks: str,
9393
tmpdir: Optional[str],
@@ -147,7 +147,8 @@ def get_tidy_invocation(
147147
start.append(f"--warnings-as-errors={warnings_as_errors}")
148148
if allow_no_checks:
149149
start.append("--allow-no-checks")
150-
start.append(f)
150+
if f:
151+
start.append(f)
151152
return start
152153

153154

@@ -490,7 +491,7 @@ async def main() -> None:
490491

491492
try:
492493
invocation = get_tidy_invocation(
493-
"",
494+
None,
494495
clang_tidy_binary,
495496
args.checks,
496497
None,

clang-tools-extra/clangd/InlayHints.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "llvm/ADT/StringExtras.h"
3434
#include "llvm/ADT/StringRef.h"
3535
#include "llvm/ADT/Twine.h"
36+
#include "llvm/ADT/identity.h"
3637
#include "llvm/Support/Casting.h"
3738
#include "llvm/Support/ErrorHandling.h"
3839
#include "llvm/Support/FormatVariadic.h"
@@ -368,7 +369,11 @@ static FunctionProtoTypeLoc getPrototypeLoc(Expr *Fn) {
368369
}
369370

370371
if (auto F = Target.getAs<FunctionProtoTypeLoc>()) {
371-
return F;
372+
// In some edge cases the AST can contain a "trivial" FunctionProtoTypeLoc
373+
// which has null parameters. Avoid these as they don't contain useful
374+
// information.
375+
if (llvm::all_of(F.getParams(), llvm::identity<ParmVarDecl *>()))
376+
return F;
372377
}
373378

374379
return {};

clang-tools-extra/clangd/ModulesBuilder.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -360,9 +360,9 @@ void ModuleFileCache::remove(StringRef ModuleName) {
360360
/// Collect the directly and indirectly required module names for \param
361361
/// ModuleName in topological order. The \param ModuleName is guaranteed to
362362
/// be the last element in \param ModuleNames.
363-
llvm::SmallVector<StringRef> getAllRequiredModules(ProjectModules &MDB,
363+
llvm::SmallVector<std::string> getAllRequiredModules(ProjectModules &MDB,
364364
StringRef ModuleName) {
365-
llvm::SmallVector<llvm::StringRef> ModuleNames;
365+
llvm::SmallVector<std::string> ModuleNames;
366366
llvm::StringSet<> ModuleNamesSet;
367367

368368
auto VisitDeps = [&](StringRef ModuleName, auto Visitor) -> void {
@@ -373,7 +373,7 @@ llvm::SmallVector<StringRef> getAllRequiredModules(ProjectModules &MDB,
373373
if (ModuleNamesSet.insert(RequiredModuleName).second)
374374
Visitor(RequiredModuleName, Visitor);
375375

376-
ModuleNames.push_back(ModuleName);
376+
ModuleNames.push_back(ModuleName.str());
377377
};
378378
VisitDeps(ModuleName, VisitDeps);
379379

@@ -418,28 +418,30 @@ llvm::Error ModulesBuilder::ModulesBuilderImpl::getOrBuildModuleFile(
418418
// Get Required modules in topological order.
419419
auto ReqModuleNames = getAllRequiredModules(MDB, ModuleName);
420420
for (llvm::StringRef ReqModuleName : ReqModuleNames) {
421-
if (BuiltModuleFiles.isModuleUnitBuilt(ModuleName))
421+
if (BuiltModuleFiles.isModuleUnitBuilt(ReqModuleName))
422422
continue;
423423

424424
if (auto Cached = Cache.getModule(ReqModuleName)) {
425425
if (IsModuleFileUpToDate(Cached->getModuleFilePath(), BuiltModuleFiles,
426426
TFS.view(std::nullopt))) {
427-
log("Reusing module {0} from {1}", ModuleName,
427+
log("Reusing module {0} from {1}", ReqModuleName,
428428
Cached->getModuleFilePath());
429429
BuiltModuleFiles.addModuleFile(std::move(Cached));
430430
continue;
431431
}
432432
Cache.remove(ReqModuleName);
433433
}
434434

435+
std::string ReqFileName =
436+
MDB.getSourceForModuleName(ReqModuleName);
435437
llvm::Expected<ModuleFile> MF = buildModuleFile(
436-
ModuleName, ModuleUnitFileName, getCDB(), TFS, BuiltModuleFiles);
438+
ReqModuleName, ReqFileName, getCDB(), TFS, BuiltModuleFiles);
437439
if (llvm::Error Err = MF.takeError())
438440
return Err;
439441

440-
log("Built module {0} to {1}", ModuleName, MF->getModuleFilePath());
442+
log("Built module {0} to {1}", ReqModuleName, MF->getModuleFilePath());
441443
auto BuiltModuleFile = std::make_shared<const ModuleFile>(std::move(*MF));
442-
Cache.add(ModuleName, BuiltModuleFile);
444+
Cache.add(ReqModuleName, BuiltModuleFile);
443445
BuiltModuleFiles.addModuleFile(std::move(BuiltModuleFile));
444446
}
445447

clang-tools-extra/clangd/ProjectModules.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class ProjectModules {
4242
llvm::unique_function<void(tooling::CompileCommand &, PathRef) const>;
4343

4444
virtual std::vector<std::string> getRequiredModules(PathRef File) = 0;
45-
virtual PathRef
45+
virtual std::string
4646
getSourceForModuleName(llvm::StringRef ModuleName,
4747
PathRef RequiredSrcFile = PathRef()) = 0;
4848

clang-tools-extra/clangd/ScanningProjectModules.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class ModuleDependencyScanner {
6666
///
6767
/// TODO: We should handle the case that there are multiple source files
6868
/// declaring the same module.
69-
PathRef getSourceForModuleName(llvm::StringRef ModuleName) const;
69+
std::string getSourceForModuleName(llvm::StringRef ModuleName) const;
7070

7171
/// Return the direct required modules. Indirect required modules are not
7272
/// included.
@@ -140,7 +140,7 @@ void ModuleDependencyScanner::globalScan(
140140
GlobalScanned = true;
141141
}
142142

143-
PathRef ModuleDependencyScanner::getSourceForModuleName(
143+
std::string ModuleDependencyScanner::getSourceForModuleName(
144144
llvm::StringRef ModuleName) const {
145145
assert(
146146
GlobalScanned &&
@@ -189,7 +189,7 @@ class ScanningAllProjectModules : public ProjectModules {
189189

190190
/// RequiredSourceFile is not used intentionally. See the comments of
191191
/// ModuleDependencyScanner for detail.
192-
PathRef
192+
std::string
193193
getSourceForModuleName(llvm::StringRef ModuleName,
194194
PathRef RequiredSourceFile = PathRef()) override {
195195
Scanner.globalScan(Mangler);
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# A smoke test to check that a simple dependency chain for modules can work.
2+
#
3+
# FIXME: The test fails on Windows; see comments on https://github.com/llvm/llvm-project/pull/142828
4+
# UNSUPPORTED: system-windows
5+
#
6+
# RUN: rm -fr %t
7+
# RUN: mkdir -p %t
8+
# RUN: split-file %s %t
9+
#
10+
# RUN: sed -e "s|DIR|%/t|g" %t/compile_commands.json.tmpl > %t/compile_commands.json.tmp
11+
# RUN: sed -e "s|CLANG_CC|%clang|g" %t/compile_commands.json.tmp > %t/compile_commands.json
12+
# RUN: sed -e "s|DIR|%/t|g" %t/definition.jsonrpc.tmpl > %t/definition.jsonrpc.tmp
13+
#
14+
# On Windows, we need the URI in didOpen to look like "uri":"file:///C:/..."
15+
# (with the extra slash in the front), so we add it here.
16+
# RUN: sed -E -e 's|"file://([A-Z]):/|"file:///\1:/|g' %/t/definition.jsonrpc.tmp > %/t/definition.jsonrpc
17+
#
18+
# RUN: clangd -experimental-modules-support -lit-test < %t/definition.jsonrpc \
19+
# RUN: | FileCheck -strict-whitespace %t/definition.jsonrpc
20+
21+
#--- A-frag.cppm
22+
export module A:frag;
23+
export void printA() {}
24+
25+
#--- A.cppm
26+
export module A;
27+
export import :frag;
28+
29+
#--- Use.cpp
30+
import A;
31+
void foo() {
32+
print
33+
}
34+
35+
#--- compile_commands.json.tmpl
36+
[
37+
{
38+
"directory": "DIR",
39+
"command": "CLANG_CC -fprebuilt-module-path=DIR -std=c++20 -o DIR/main.cpp.o -c DIR/Use.cpp",
40+
"file": "DIR/Use.cpp"
41+
},
42+
{
43+
"directory": "DIR",
44+
"command": "CLANG_CC -std=c++20 DIR/A.cppm --precompile -o DIR/A.pcm",
45+
"file": "DIR/A.cppm"
46+
},
47+
{
48+
"directory": "DIR",
49+
"command": "CLANG_CC -std=c++20 DIR/A-frag.cppm --precompile -o DIR/A-frag.pcm",
50+
"file": "DIR/A-frag.cppm"
51+
}
52+
]
53+
54+
#--- definition.jsonrpc.tmpl
55+
{
56+
"jsonrpc": "2.0",
57+
"id": 0,
58+
"method": "initialize",
59+
"params": {
60+
"processId": 123,
61+
"rootPath": "clangd",
62+
"capabilities": {
63+
"textDocument": {
64+
"completion": {
65+
"completionItem": {
66+
"snippetSupport": true
67+
}
68+
}
69+
}
70+
},
71+
"trace": "off"
72+
}
73+
}
74+
---
75+
{
76+
"jsonrpc": "2.0",
77+
"method": "textDocument/didOpen",
78+
"params": {
79+
"textDocument": {
80+
"uri": "file://DIR/Use.cpp",
81+
"languageId": "cpp",
82+
"version": 1,
83+
"text": "import A;\nvoid foo() {\n print\n}\n"
84+
}
85+
}
86+
}
87+
88+
# CHECK: "message"{{.*}}printA{{.*}}(fix available)
89+
90+
---
91+
{"jsonrpc":"2.0","id":1,"method":"textDocument/completion","params":{"textDocument":{"uri":"file://DIR/Use.cpp"},"context":{"triggerKind":1},"position":{"line":2,"character":6}}}
92+
---
93+
{"jsonrpc":"2.0","id":2,"method":"shutdown"}
94+
---
95+
{"jsonrpc":"2.0","method":"exit"}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -997,11 +997,16 @@ TEST(ParameterHints, FunctionPointer) {
997997
f3_t f3;
998998
using f4_t = void(__stdcall *)(int param);
999999
f4_t f4;
1000+
__attribute__((noreturn)) f4_t f5;
10001001
void bar() {
10011002
f1($f1[[42]]);
10021003
f2($f2[[42]]);
10031004
f3($f3[[42]]);
10041005
f4($f4[[42]]);
1006+
// This one runs into an edge case in clang's type model
1007+
// and we can't extract the parameter name. But at least
1008+
// we shouldn't crash.
1009+
f5(42);
10051010
}
10061011
)cpp",
10071012
ExpectedHint{"param: ", "f1"}, ExpectedHint{"param: ", "f2"},

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,9 @@ Improvements to clang-tidy
190190
- Fixed bug in :program:`clang-tidy` by which `HeaderFilterRegex` did not take
191191
effect when passed via the `.clang-tidy` file.
192192

193+
- Fixed bug in :program:`run_clang_tidy.py` where the program would not
194+
correctly display the checks enabled by the top-level `.clang-tidy` file.
195+
193196
New checks
194197
^^^^^^^^^^
195198

clang/docs/ReleaseNotes.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,9 @@ C++2c Feature Support
314314

315315
- Implemented `P3176R1 The Oxford variadic comma <https://wg21.link/P3176R1>`_
316316

317+
- The error produced when doing arithmetic operations on enums of different types
318+
can be disabled with ``-Wno-enum-enum-conversion``. (#GH92340)
319+
317320
C++23 Feature Support
318321
^^^^^^^^^^^^^^^^^^^^^
319322
- Removed the restriction to literal types in constexpr functions in C++23 mode.
@@ -909,6 +912,8 @@ Bug Fixes in This Version
909912
being deleted has a potentially throwing destructor (#GH118660).
910913
- Clang now outputs correct values when #embed data contains bytes with negative
911914
signed char values (#GH102798).
915+
- Fix crash due to unknown references and pointer implementation and handling of
916+
base classes. (GH139452)
912917

913918
Bug Fixes to Compiler Builtins
914919
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -1113,6 +1118,7 @@ Miscellaneous Clang Crashes Fixed
11131118

11141119
- Fixed a crash when an unscoped enumeration declared by an opaque-enum-declaration within a class template
11151120
with a dependent underlying type is subject to integral promotion. (#GH117960)
1121+
- Fix code completion crash involving PCH serialzied templates. (#GH139019)
11161122

11171123
OpenACC Specific Changes
11181124
------------------------
@@ -1267,6 +1273,8 @@ RISC-V Support
12671273
- The option ``-mcmodel=large`` for the large code model is supported.
12681274
- Bump RVV intrinsic to version 1.0, the spec: https://github.com/riscv-non-isa/rvv-intrinsic-doc/releases/tag/v1.0.0-rc4
12691275

1276+
- `Zicsr` / `Zifencei` are allowed to be duplicated in the presence of `g` in `-march`.
1277+
12701278
CUDA/HIP Language Changes
12711279
^^^^^^^^^^^^^^^^^^^^^^^^^
12721280
- Fixed a bug about overriding a constexpr pure-virtual member function with a non-constexpr virtual member function which causes compilation failure when including standard C++ header `format`.
@@ -1465,6 +1473,9 @@ Crash and bug fixes
14651473
- The ``unix.BlockInCriticalSection`` now recognizes the ``lock()`` member function
14661474
as expected, even if it's inherited from a base class. Fixes (#GH104241).
14671475

1476+
- Fixed a crash when C++20 parenthesized initializer lists are used. This issue
1477+
was causing a crash in clang-tidy. (#GH136041)
1478+
14681479
Improvements
14691480
^^^^^^^^^^^^
14701481

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7567,9 +7567,13 @@ def warn_arith_conv_mixed_enum_types_cxx20 : Warning<
75677567
"%sub{select_arith_conv_kind}0 "
75687568
"different enumeration types%diff{ ($ and $)|}1,2 is deprecated">,
75697569
InGroup<DeprecatedEnumEnumConversion>;
7570-
def err_conv_mixed_enum_types_cxx26 : Error<
7570+
7571+
def err_conv_mixed_enum_types: Error <
75717572
"invalid %sub{select_arith_conv_kind}0 "
75727573
"different enumeration types%diff{ ($ and $)|}1,2">;
7574+
def zzzz_warn_conv_mixed_enum_types_cxx26 : Warning <
7575+
err_conv_mixed_enum_types.Summary>,
7576+
InGroup<EnumEnumConversion>, DefaultError;
75737577

75747578
def warn_arith_conv_mixed_anon_enum_types : Warning<
75757579
warn_arith_conv_mixed_enum_types.Summary>,

0 commit comments

Comments
 (0)