Skip to content

Commit 3433f63

Browse files
authored
Merge branch 'main' into main
2 parents c32e613 + d5d6f60 commit 3433f63

File tree

310 files changed

+10307
-4557
lines changed

Some content is hidden

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

310 files changed

+10307
-4557
lines changed

clang-tools-extra/clang-tidy/altera/SingleWorkItemBarrierCheck.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ namespace clang::tidy::altera {
1616

1717
void SingleWorkItemBarrierCheck::registerMatchers(MatchFinder *Finder) {
1818
// Find any function that calls barrier but does not call an ID function.
19-
// hasAttr(attr::Kind::OpenCLKernel) restricts it to only kernel functions.
19+
// hasAttr(attr::Kind::DeviceKernel) restricts it to only kernel functions.
2020
// FIXME: Have it accept all functions but check for a parameter that gets an
2121
// ID from one of the four ID functions.
2222
Finder->addMatcher(
2323
// Find function declarations...
2424
functionDecl(
25-
// That are OpenCL kernels...
26-
hasAttr(attr::Kind::OpenCLKernel),
25+
// That are device kernels...
26+
hasAttr(attr::Kind::DeviceKernel),
2727
// And call a barrier function (either 1.x or 2.x version)...
2828
forEachDescendant(callExpr(callee(functionDecl(hasAnyName(
2929
"barrier", "work_group_barrier"))))

clang-tools-extra/clangd/ModulesBuilder.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -430,10 +430,10 @@ class CachingProjectModules : public ProjectModules {
430430
/// Collect the directly and indirectly required module names for \param
431431
/// ModuleName in topological order. The \param ModuleName is guaranteed to
432432
/// be the last element in \param ModuleNames.
433-
llvm::SmallVector<StringRef> getAllRequiredModules(PathRef RequiredSource,
434-
CachingProjectModules &MDB,
435-
StringRef ModuleName) {
436-
llvm::SmallVector<llvm::StringRef> ModuleNames;
433+
llvm::SmallVector<std::string> getAllRequiredModules(PathRef RequiredSource,
434+
CachingProjectModules &MDB,
435+
StringRef ModuleName) {
436+
llvm::SmallVector<std::string> ModuleNames;
437437
llvm::StringSet<> ModuleNamesSet;
438438

439439
auto VisitDeps = [&](StringRef ModuleName, auto Visitor) -> void {
@@ -444,7 +444,7 @@ llvm::SmallVector<StringRef> getAllRequiredModules(PathRef RequiredSource,
444444
if (ModuleNamesSet.insert(RequiredModuleName).second)
445445
Visitor(RequiredModuleName, Visitor);
446446

447-
ModuleNames.push_back(ModuleName);
447+
ModuleNames.push_back(ModuleName.str());
448448
};
449449
VisitDeps(ModuleName, VisitDeps);
450450

@@ -494,28 +494,30 @@ llvm::Error ModulesBuilder::ModulesBuilderImpl::getOrBuildModuleFile(
494494
// Get Required modules in topological order.
495495
auto ReqModuleNames = getAllRequiredModules(RequiredSource, MDB, ModuleName);
496496
for (llvm::StringRef ReqModuleName : ReqModuleNames) {
497-
if (BuiltModuleFiles.isModuleUnitBuilt(ModuleName))
497+
if (BuiltModuleFiles.isModuleUnitBuilt(ReqModuleName))
498498
continue;
499499

500500
if (auto Cached = Cache.getModule(ReqModuleName)) {
501501
if (IsModuleFileUpToDate(Cached->getModuleFilePath(), BuiltModuleFiles,
502502
TFS.view(std::nullopt))) {
503-
log("Reusing module {0} from {1}", ModuleName,
503+
log("Reusing module {0} from {1}", ReqModuleName,
504504
Cached->getModuleFilePath());
505505
BuiltModuleFiles.addModuleFile(std::move(Cached));
506506
continue;
507507
}
508508
Cache.remove(ReqModuleName);
509509
}
510510

511+
std::string ReqFileName =
512+
MDB.getSourceForModuleName(ReqModuleName, RequiredSource);
511513
llvm::Expected<ModuleFile> MF = buildModuleFile(
512-
ModuleName, ModuleUnitFileName, getCDB(), TFS, BuiltModuleFiles);
514+
ReqModuleName, ReqFileName, getCDB(), TFS, BuiltModuleFiles);
513515
if (llvm::Error Err = MF.takeError())
514516
return Err;
515517

516-
log("Built module {0} to {1}", ModuleName, MF->getModuleFilePath());
518+
log("Built module {0} to {1}", ReqModuleName, MF->getModuleFilePath());
517519
auto BuiltModuleFile = std::make_shared<const ModuleFile>(std::move(*MF));
518-
Cache.add(ModuleName, BuiltModuleFile);
520+
Cache.add(ReqModuleName, BuiltModuleFile);
519521
BuiltModuleFiles.addModuleFile(std::move(BuiltModuleFile));
520522
}
521523

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

clang-tools-extra/docs/clang-tidy/checks/bugprone/return-const-ref-from-parameter.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ on the control flow of the function, an overload where all problematic
4242

4343
This issue can also be resolved by adding ``[[clang::lifetimebound]]``. Clang
4444
enable ``-Wdangling`` warning by default which can detect mis-uses of the
45-
annotated function. See `lifetimebound attribute <https://clang.llvm.org/docs/AttributeReference.html#id11>`_
45+
annotated function. See `lifetimebound attribute <https://clang.llvm.org/docs/AttributeReference.html#lifetimebound>`_
4646
for details.
4747

4848
.. code-block:: c++

clang/docs/LibClang.rst

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Libclang tutorial
55
=================
66
The C Interface to Clang provides a relatively small API that exposes facilities for parsing source code into an abstract syntax tree (AST), loading already-parsed ASTs, traversing the AST, associating physical source locations with elements within the AST, and other facilities that support Clang-based development tools.
7-
This C interface to Clang will never provide all of the information representation stored in Clang's C++ AST, nor should it: the intent is to maintain an API that is relatively stable from one release to the next, providing only the basic functionality needed to support development tools.
7+
This C interface to Clang will never provide all of the information representation stored in Clang's C++ AST, nor should it: the intent is to maintain an API that is :ref:`relatively stable <Stability>` from one release to the next, providing only the basic functionality needed to support development tools.
88
The entire C interface of libclang is available in the file `Index.h`_
99

1010
Essential types overview
@@ -358,3 +358,49 @@ Complete example code
358358
359359
360360
.. _Index.h: https://github.com/llvm/llvm-project/blob/main/clang/include/clang-c/Index.h
361+
362+
.. _Stability:
363+
364+
ABI and API Stability
365+
---------------------
366+
367+
The C interfaces in libclang are intended to be relatively stable. This allows
368+
a programmer to use libclang without having to worry as much about Clang
369+
upgrades breaking existing code. However, the library is not unchanging. For
370+
example, the library will gain new interfaces over time as needs arise,
371+
existing APIs may be deprecated for eventual removal, etc. Also, the underlying
372+
implementation of the facilities by Clang may change behavior as bugs are
373+
fixed, features get implemented, etc.
374+
375+
The library should be ABI and API stable over time, but ABI- and API-breaking
376+
changes can happen in the following (non-exhaustive) situations:
377+
378+
* Adding new enumerator to an enumeration (can be ABI-breaking in C++).
379+
* Removing an explicitly deprecated API after a suitably long deprecation
380+
period.
381+
* Using implementation details, such as names or comments that say something
382+
is "private", "reserved", "internal", etc.
383+
* Bug fixes and changes to Clang's internal implementation happen routinely and
384+
will change the behavior of callers.
385+
* Rarely, bug fixes to libclang itself.
386+
387+
The library has version macros (``CINDEX_VERSION_MAJOR``,
388+
``CINDEX_VERSION_MINOR``, and ``CINDEX_VERSION``) which can be used to test for
389+
specific library versions at compile time. The ``CINDEX_VERSION_MAJOR`` macro
390+
is only incremented if there are major source- or ABI-breaking changes. Except
391+
for removing an explicitly deprecated API, the changes listed above are not
392+
considered major source- or ABI-breaking changes. Historically, the value this
393+
macro expands to has not changed, but may be incremented in the future should
394+
the need arise. The ``CINDEX_VERSION_MINOR`` macro is incremented as new APIs
395+
are added. The ``CINDEX_VERSION`` macro expands to a value based on the major
396+
and minor version macros.
397+
398+
In an effort to allow the library to be modified as new needs arise, the
399+
following situations are explicitly unsupported:
400+
401+
* Loading different library versions into the same executable and passing
402+
objects between the libraries; despite general ABI stability, different
403+
versions of the library may use different implementation details that are not
404+
compatible across library versions.
405+
* For the same reason as above, serializing objects from one version of the
406+
library and deserializing with a different version is also not supported.

clang/docs/ReleaseNotes.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,8 @@ Bug Fixes in This Version
685685
- Fixed an assertion failure in serialization of constexpr structs containing unions. (#GH140130)
686686
- Fixed duplicate entries in TableGen that caused the wrong attribute to be selected. (GH#140701)
687687
- Fixed type mismatch error when 'builtin-elementwise-math' arguments have different qualifiers, this should be well-formed. (#GH141397)
688+
- Constant evaluation now correctly runs the destructor of a variable declared in
689+
the second clause of a C-style ``for`` loop. (#GH139818)
688690

689691
Bug Fixes to Compiler Builtins
690692
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -830,6 +832,7 @@ Bug Fixes to C++ Support
830832
- Clang modules now allow a module and its user to differ on TrivialAutoVarInit*
831833
- Fixed an access checking bug when initializing non-aggregates in default arguments (#GH62444), (#GH83608)
832834
- Fixed a pack substitution bug in deducing class template partial specializations. (#GH53609)
835+
- Fixed a crash when constant evaluating some explicit object member assignment operators. (#GH142835)
833836

834837
Bug Fixes to AST Handling
835838
^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -1049,7 +1052,7 @@ Sanitizers
10491052
----------
10501053

10511054
- ``-fsanitize=vptr`` is no longer a part of ``-fsanitize=undefined``.
1052-
- Sanitizer ignorelists now support the syntax ``src:*=sanitize``,
1055+
- Sanitizer ignorelists now support the syntax ``src:*=sanitize``,
10531056
``type:*=sanitize``, ``fun:*=sanitize``, ``global:*=sanitize``,
10541057
and ``mainfile:*=sanitize``.
10551058

clang/docs/UsersManual.rst

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2300,12 +2300,14 @@ are listed below.
23002300
.. option:: -f[no-]unique-source-file-names
23012301

23022302
When enabled, allows the compiler to assume that each object file
2303-
passed to the linker has been compiled using a unique source file
2304-
path. This is useful for reducing link times when doing ThinLTO
2305-
in combination with whole-program devirtualization or CFI.
2303+
passed to the linker has a unique identifier. The identifier for
2304+
an object file is either the source file path or the value of the
2305+
argument `-funique-source-file-identifier` if specified. This is
2306+
useful for reducing link times when doing ThinLTO in combination with
2307+
whole-program devirtualization or CFI.
23062308

2307-
The full source path passed to the compiler must be unique. This
2308-
means that, for example, the following is a usage error:
2309+
The full source path or identifier passed to the compiler must be
2310+
unique. This means that, for example, the following is a usage error:
23092311

23102312
.. code-block:: console
23112313
@@ -2327,6 +2329,11 @@ are listed below.
23272329
A misuse of this flag may result in a duplicate symbol error at
23282330
link time.
23292331

2332+
.. option:: -funique-source-file-identifier=IDENTIFIER
2333+
2334+
Used with `-funique-source-file-names` to specify a source file
2335+
identifier.
2336+
23302337
.. option:: -fforce-emit-vtables
23312338

23322339
In order to improve devirtualization, forces emitting of vtables even in

clang/include/clang/AST/GlobalDecl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ class GlobalDecl {
164164
}
165165

166166
static KernelReferenceKind getDefaultKernelReference(const FunctionDecl *D) {
167-
return (D->hasAttr<OpenCLKernelAttr>() || D->getLangOpts().CUDAIsDevice)
167+
return (D->hasAttr<DeviceKernelAttr>() || D->getLangOpts().CUDAIsDevice)
168168
? KernelReferenceKind::Kernel
169169
: KernelReferenceKind::Stub;
170170
}

0 commit comments

Comments
 (0)