Skip to content

Commit 52e1517

Browse files
committed
LLVM and SPIRV-LLVM-Translator pulldown (WW43)
LLVM: llvm/llvm-project@f193bcc SPIRV-LLVM-Translator: KhronosGroup/SPIRV-LLVM-Translator@4f3641e
2 parents 5229089 + 0f66d70 commit 52e1517

File tree

3,343 files changed

+204428
-240385
lines changed

Some content is hidden

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

3,343 files changed

+204428
-240385
lines changed

.mailmap

Lines changed: 1 addition & 0 deletions

clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ AST_MATCHER(Decl, isFromStdNamespaceOrSystemHeader) {
2424
if (const auto *D = Node.getDeclContext()->getEnclosingNamespaceContext())
2525
if (D->isStdNamespace())
2626
return true;
27+
if (Node.getLocation().isInvalid())
28+
return false;
2729
return Node.getASTContext().getSourceManager().isInSystemHeader(
2830
Node.getLocation());
2931
}

clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,6 @@ class CppCoreGuidelinesModule : public ClangTidyModule {
106106
Opts["cppcoreguidelines-non-private-member-variables-in-classes."
107107
"IgnoreClassesWithAllMemberVariablesBeingPublic"] = "true";
108108

109-
Opts["cppcoreguidelines-explicit-virtual-functions."
110-
"IgnoreDestructors"] = "true";
111-
112109
return Options;
113110
}
114111
};

clang-tools-extra/clang-tidy/cppcoreguidelines/VirtualClassDestructorCheck.cpp

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,29 @@ namespace clang {
1919
namespace tidy {
2020
namespace cppcoreguidelines {
2121

22+
AST_MATCHER(CXXRecordDecl, hasPublicVirtualOrProtectedNonVirtualDestructor) {
23+
// We need to call Node.getDestructor() instead of matching a
24+
// CXXDestructorDecl. Otherwise, tests will fail for class templates, since
25+
// the primary template (not the specialization) always gets a non-virtual
26+
// CXXDestructorDecl in the AST. https://bugs.llvm.org/show_bug.cgi?id=51912
27+
const CXXDestructorDecl *Destructor = Node.getDestructor();
28+
if (!Destructor)
29+
return false;
30+
31+
return (((Destructor->getAccess() == AccessSpecifier::AS_public) &&
32+
Destructor->isVirtual()) ||
33+
((Destructor->getAccess() == AccessSpecifier::AS_protected) &&
34+
!Destructor->isVirtual()));
35+
}
36+
2237
void VirtualClassDestructorCheck::registerMatchers(MatchFinder *Finder) {
2338
ast_matchers::internal::Matcher<CXXRecordDecl> InheritsVirtualMethod =
2439
hasAnyBase(hasType(cxxRecordDecl(has(cxxMethodDecl(isVirtual())))));
2540

2641
Finder->addMatcher(
2742
cxxRecordDecl(
2843
anyOf(has(cxxMethodDecl(isVirtual())), InheritsVirtualMethod),
29-
unless(anyOf(
30-
has(cxxDestructorDecl(isPublic(), isVirtual())),
31-
has(cxxDestructorDecl(isProtected(), unless(isVirtual()))))))
44+
unless(hasPublicVirtualOrProtectedNonVirtualDestructor()))
3245
.bind("ProblematicClassOrStruct"),
3346
this);
3447
}

clang-tools-extra/clangd/FindTarget.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,8 @@ struct TargetFinder {
507507
// DeclRefExpr).
508508
if (Arg.getKind() == TemplateArgument::Template ||
509509
Arg.getKind() == TemplateArgument::TemplateExpansion) {
510-
if (TemplateDecl *TD = Arg.getAsTemplate().getAsTemplateDecl()) {
510+
if (TemplateDecl *TD =
511+
Arg.getAsTemplateOrTemplatePattern().getAsTemplateDecl()) {
511512
report(TD, Flags);
512513
}
513514
}

clang-tools-extra/clangd/IncludeCleaner.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,15 @@ struct ReferencedFiles {
121121
if (!Macros.insert(FID).second)
122122
return;
123123
const auto &Exp = SM.getSLocEntry(FID).getExpansion();
124-
add(Exp.getSpellingLoc());
125-
add(Exp.getExpansionLocStart());
126-
add(Exp.getExpansionLocEnd());
124+
// For token pasting operator in macros, spelling and expansion locations
125+
// can be within a temporary buffer that Clang creates (scratch space or
126+
// ScratchBuffer). That is not a real file we can include.
127+
if (!SM.isWrittenInScratchSpace(Exp.getSpellingLoc()))
128+
add(Exp.getSpellingLoc());
129+
if (!SM.isWrittenInScratchSpace(Exp.getExpansionLocStart()))
130+
add(Exp.getExpansionLocStart());
131+
if (!SM.isWrittenInScratchSpace(Exp.getExpansionLocEnd()))
132+
add(Exp.getExpansionLocEnd());
127133
}
128134
};
129135

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,15 @@ TEST_F(TargetDeclTest, Types) {
341341
EXPECT_DECLS("TemplateSpecializationTypeLoc", "template <typename> class T");
342342
Flags.clear();
343343

344+
Code = R"cpp(
345+
template<template<typename> class ...T>
346+
class C {
347+
C<[[T...]]> foo;
348+
};
349+
)cpp";
350+
EXPECT_DECLS("TemplateArgumentLoc", {"template <typename> class ...T"});
351+
Flags.clear();
352+
344353
Code = R"cpp(
345354
struct S{};
346355
S X;

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

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,47 @@ TEST(IncludeCleaner, GetUnusedHeaders) {
167167
UnorderedElementsAre("\"unused.h\"", "\"dir/unused.h\""));
168168
}
169169

170+
TEST(IncludeCleaner, ScratchBuffer) {
171+
TestTU TU;
172+
TU.Filename = "foo.cpp";
173+
TU.Code = R"cpp(
174+
#include "macro_spelling_in_scratch_buffer.h"
175+
176+
using flags::FLAGS_FOO;
177+
178+
int concat(a, b) = 42;
179+
)cpp";
180+
// The pasting operator in combination with DEFINE_FLAG will create
181+
// ScratchBuffer with `flags::FLAGS_FOO` that will have FileID but not
182+
// FileEntry.
183+
TU.AdditionalFiles["macro_spelling_in_scratch_buffer.h"] = R"cpp(
184+
#define DEFINE_FLAG(X) \
185+
namespace flags { \
186+
int FLAGS_##X; \
187+
} \
188+
189+
DEFINE_FLAG(FOO)
190+
191+
#define ab x
192+
#define concat(x, y) x##y
193+
)cpp";
194+
ParsedAST AST = TU.build();
195+
auto &SM = AST.getSourceManager();
196+
auto &Includes = AST.getIncludeStructure();
197+
auto ReferencedFiles = findReferencedFiles(findReferencedLocations(AST), SM);
198+
auto Entry = SM.getFileManager().getFile(
199+
testPath("macro_spelling_in_scratch_buffer.h"));
200+
ASSERT_TRUE(Entry);
201+
auto FID = SM.translateFile(*Entry);
202+
// No "<scratch space>" FID.
203+
EXPECT_THAT(ReferencedFiles, UnorderedElementsAre(FID));
204+
// Should not crash due to <scratch space> "files" missing from include
205+
// structure.
206+
EXPECT_THAT(
207+
getUnused(Includes, translateToHeaderIDs(ReferencedFiles, Includes, SM)),
208+
::testing::IsEmpty());
209+
}
210+
170211
} // namespace
171212
} // namespace clangd
172213
} // namespace clang

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ New check aliases
113113
Changes in existing checks
114114
^^^^^^^^^^^^^^^^^^^^^^^^^^
115115

116+
- Removed default setting `cppcoreguidelines-explicit-virtual-functions.IgnoreDestructors = "true"`,
117+
to match the current state of the C++ Core Guidelines.
118+
119+
116120
Removed checks
117121
^^^^^^^^^^^^^^
118122

clang-tools-extra/docs/clang-tidy/checks/bugprone-unused-return-value.rst

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,25 @@ Options
1010

1111
.. option:: CheckedFunctions
1212

13-
Semicolon-separated list of functions to check. Defaults to
14-
``::std::async;::std::launder;::std::remove;::std::remove_if;::std::unique;::std::unique_ptr::release;::std::basic_string::empty;::std::vector::empty``.
15-
This means that the calls to following functions are checked by default:
13+
Semicolon-separated list of functions to check. The function is checked if
14+
the name and scope matches, with any arguments.
15+
By default the following functions are checked:
16+
``std::async, std::launder, std::remove, std::remove_if, std::unique,
17+
std::unique_ptr::release, std::basic_string::empty, std::vector::empty,
18+
std::back_inserter, std::distance, std::find, std::find_if, std::inserter,
19+
std::lower_bound, std::make_pair, std::map::count, std::map::find,
20+
std::map::lower_bound, std::multimap::equal_range,
21+
std::multimap::upper_bound, std::set::count, std::set::find, std::setfill,
22+
std::setprecision, std::setw, std::upper_bound, std::vector::at,
23+
bsearch, ferror, feof, isalnum, isalpha, isblank, iscntrl, isdigit, isgraph,
24+
islower, isprint, ispunct, isspace, isupper, iswalnum, iswprint, iswspace,
25+
isxdigit, memchr, memcmp, strcmp, strcoll, strncmp, strpbrk, strrchr,
26+
strspn, strstr, wcscmp, access, bind, connect, difftime, dlsym, fnmatch,
27+
getaddrinfo, getopt, htonl, htons, iconv_open, inet_addr, isascii, isatty,
28+
mmap, newlocale, openat, pathconf, pthread_equal, pthread_getspecific,
29+
pthread_mutex_trylock, readdir, readlink, recvmsg, regexec, scandir,
30+
semget, setjmp, shm_open, shmget, sigismember, strcasecmp, strsignal,
31+
ttyname``
1632

1733
- ``std::async()``. Not using the return value makes the call synchronous.
1834
- ``std::launder()``. Not using the return value usually means that the

clang-tools-extra/test/clang-tidy/checkers/bugprone-argument-comment.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,3 +151,8 @@ void test() {
151151
my_system_header_function(/*not_arg=*/1);
152152
}
153153
} // namespace system_header
154+
155+
void testInvalidSlocCxxConstructExpr() {
156+
__builtin_va_list __args;
157+
// __builtin_va_list has no defination in any source file
158+
}

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-virtual-class-destructor.cpp

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,3 +202,73 @@ struct NonOverridingDerivedStruct : ProtectedNonVirtualBaseStruct {
202202
void m();
203203
};
204204
// inherits virtual method
205+
206+
namespace Bugzilla_51912 {
207+
// Fixes https://bugs.llvm.org/show_bug.cgi?id=51912
208+
209+
// Forward declarations
210+
// CHECK-MESSAGES-NOT: :[[@LINE+1]]:8: warning: destructor of 'ForwardDeclaredStruct' is public and non-virtual [cppcoreguidelines-virtual-class-destructor]
211+
struct ForwardDeclaredStruct;
212+
213+
struct ForwardDeclaredStruct : PublicVirtualBaseStruct {
214+
};
215+
216+
// Normal Template
217+
// CHECK-MESSAGES-NOT: :[[@LINE+2]]:8: warning: destructor of 'TemplatedDerived' is public and non-virtual [cppcoreguidelines-virtual-class-destructor]
218+
template <typename T>
219+
struct TemplatedDerived : PublicVirtualBaseStruct {
220+
};
221+
222+
TemplatedDerived<int> InstantiationWithInt;
223+
224+
// Derived from template, base has virtual dtor
225+
// CHECK-MESSAGES-NOT: :[[@LINE+2]]:8: warning: destructor of 'DerivedFromTemplateVirtualBaseStruct' is public and non-virtual [cppcoreguidelines-virtual-class-destructor]
226+
template <typename T>
227+
struct DerivedFromTemplateVirtualBaseStruct : T {
228+
virtual void foo();
229+
};
230+
231+
DerivedFromTemplateVirtualBaseStruct<PublicVirtualBaseStruct> InstantiationWithPublicVirtualBaseStruct;
232+
233+
// Derived from template, base has *not* virtual dtor
234+
// CHECK-MESSAGES: :[[@LINE+8]]:8: warning: destructor of 'DerivedFromTemplateNonVirtualBaseStruct' is public and non-virtual [cppcoreguidelines-virtual-class-destructor]
235+
// CHECK-MESSAGES: :[[@LINE+7]]:8: note: make it public and virtual
236+
// CHECK-MESSAGES: :[[@LINE+6]]:8: warning: destructor of 'DerivedFromTemplateNonVirtualBaseStruct<PublicNonVirtualBaseStruct>' is public and non-virtual [cppcoreguidelines-virtual-class-destructor]
237+
// CHECK-FIXES: struct DerivedFromTemplateNonVirtualBaseStruct : T {
238+
// CHECK-FIXES-NEXT: virtual ~DerivedFromTemplateNonVirtualBaseStruct() = default;
239+
// CHECK-FIXES-NEXT: virtual void foo();
240+
// CHECK-FIXES-NEXT: };
241+
template <typename T>
242+
struct DerivedFromTemplateNonVirtualBaseStruct : T {
243+
virtual void foo();
244+
};
245+
246+
DerivedFromTemplateNonVirtualBaseStruct<PublicNonVirtualBaseStruct> InstantiationWithPublicNonVirtualBaseStruct;
247+
248+
// Derived from template, base has virtual dtor, to be used in a typedef
249+
// CHECK-MESSAGES-NOT: :[[@LINE+2]]:8: warning: destructor of 'DerivedFromTemplateVirtualBaseStruct2' is public and non-virtual [cppcoreguidelines-virtual-class-destructor]
250+
template <typename T>
251+
struct DerivedFromTemplateVirtualBaseStruct2 : T {
252+
virtual void foo();
253+
};
254+
255+
using DerivedFromTemplateVirtualBaseStruct2Typedef = DerivedFromTemplateVirtualBaseStruct2<PublicVirtualBaseStruct>;
256+
DerivedFromTemplateVirtualBaseStruct2Typedef InstantiationWithPublicVirtualBaseStruct2;
257+
258+
// Derived from template, base has *not* virtual dtor, to be used in a typedef
259+
// CHECK-MESSAGES: :[[@LINE+8]]:8: warning: destructor of 'DerivedFromTemplateNonVirtualBaseStruct2' is public and non-virtual [cppcoreguidelines-virtual-class-destructor]
260+
// CHECK-MESSAGES: :[[@LINE+7]]:8: note: make it public and virtual
261+
// CHECK-MESSAGES: :[[@LINE+6]]:8: warning: destructor of 'DerivedFromTemplateNonVirtualBaseStruct2<PublicNonVirtualBaseStruct>' is public and non-virtual [cppcoreguidelines-virtual-class-destructor]
262+
// CHECK-FIXES: struct DerivedFromTemplateNonVirtualBaseStruct2 : T {
263+
// CHECK-FIXES-NEXT: virtual ~DerivedFromTemplateNonVirtualBaseStruct2() = default;
264+
// CHECK-FIXES-NEXT: virtual void foo();
265+
// CHECK-FIXES-NEXT: };
266+
template <typename T>
267+
struct DerivedFromTemplateNonVirtualBaseStruct2 : T {
268+
virtual void foo();
269+
};
270+
271+
using DerivedFromTemplateNonVirtualBaseStruct2Typedef = DerivedFromTemplateNonVirtualBaseStruct2<PublicNonVirtualBaseStruct>;
272+
DerivedFromTemplateNonVirtualBaseStruct2Typedef InstantiationWithPublicNonVirtualBaseStruct2;
273+
274+
} // namespace Bugzilla_51912

clang-tools-extra/test/clang-tidy/checkers/modernize-use-override.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %check_clang_tidy %s modernize-use-override %t -- -- -fexceptions
1+
// RUN: %check_clang_tidy %s modernize-use-override,cppcoreguidelines-explicit-virtual-functions %t -- -- -fexceptions
22

33
#define ABSTRACT = 0
44

@@ -52,7 +52,7 @@ struct Base {
5252
struct SimpleCases : public Base {
5353
public:
5454
virtual ~SimpleCases();
55-
// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: prefer using 'override' or (rarely) 'final' instead of 'virtual' [modernize-use-override]
55+
// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: prefer using 'override' or (rarely) 'final' instead of 'virtual'
5656
// CHECK-FIXES: {{^}} ~SimpleCases() override;
5757

5858
void a();

clang/docs/Block-ABI-Apple.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

clang/docs/LanguageExtensions.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3166,7 +3166,7 @@ the same purpose. The preprocessor symbols ``__SEG_FS`` and ``__SEG_GS``
31663166
indicate their support.
31673167
31683168
PowerPC Language Extensions
3169-
------------------------------
3169+
---------------------------
31703170
31713171
Set the Floating Point Rounding Mode
31723172
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

clang/docs/Makefile.sphinx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,6 @@ html:
5050
@# Kind of a hack, but HTML-formatted docs are on the way out anyway.
5151
@echo "Copying legacy HTML-formatted docs into $(BUILDDIR)/html"
5252
@cp -a *.html $(BUILDDIR)/html
53-
@# FIXME: What we really need is a way to specify redirects, so that
54-
@# we can just redirect to a reST'ified version of this document.
55-
@# PR14714 is tracking the issue of redirects.
56-
@cp -a Block-ABI-Apple.txt $(BUILDDIR)/html
5753
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
5854

5955
dirhtml:

clang/docs/ReleaseNotes.rst

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ Modified Compiler Flags
8383
- RISC-V SiFive S54 (``sifive-s54``).
8484
- RISC-V SiFive S76 (``sifive-s76``).
8585

86+
- Support has been added for the following architectures (``-march`` identifiers in parentheses):
87+
88+
- Armv9-A (``armv9-a``).
89+
- Armv9.1-A (``armv9.1-a``).
90+
- Armv9.2-A (``armv9.2-a``).
91+
8692
Removed Compiler Flags
8793
-------------------------
8894

@@ -104,6 +110,13 @@ Attribute Changes in Clang
104110
attribute is handled instead, e.g. in ``handleDeclAttribute``.
105111
(This was changed in order to better support attributes in code completion).
106112

113+
- __has_cpp_attribute, __has_c_attribute, __has_attribute, and __has_declspec
114+
will now macro expand their argument. This causes a change in behavior for
115+
code using ``__has_cpp_attribute(__clang__::attr)`` (and same for
116+
``__has_c_attribute``) where it would previously expand to ``0`` for all
117+
attributes, but will now issue an error due to the expansion of the
118+
predefined ``__clang__`` macro.
119+
107120
Windows Support
108121
---------------
109122

@@ -116,6 +129,9 @@ Windows Support
116129
C Language Changes in Clang
117130
---------------------------
118131

132+
- The value of ``__STDC_VERSION__`` has been bumped to ``202000L`` when passing
133+
``-std=c2x`` so that it can be distinguished from C17 mode. This value is
134+
expected to change again when C23 is published.
119135
- Wide multi-characters literals such as ``L'ab'`` that would previously be interpreted as ``L'b'``
120136
are now ill-formed in all language modes. The motivation for this change is outlined in
121137
`P2362 <wg21.link/P2362>`_.
@@ -171,6 +187,12 @@ X86 Support in Clang
171187

172188
- Support for ``AVX512-FP16`` instructions has been added.
173189

190+
Arm and AArch64 Support in Clang
191+
--------------------------------
192+
193+
- Support has been added for the following processors (command-line identifiers in parentheses):
194+
- Arm Cortex-A510 (``cortex-a510``)
195+
174196
Internal API Changes
175197
--------------------
176198

@@ -184,7 +206,11 @@ Build System Changes
184206
AST Matchers
185207
------------
186208

187-
- ...
209+
- ``TypeLoc`` AST Matchers are now available. These matchers provide helpful
210+
utilities for matching ``TypeLoc`` nodes, such as the ``pointerTypeLoc``
211+
matcher or the ``hasReturnTypeLoc`` matcher. The addition of these matchers
212+
was made possible by changes to the handling of ``TypeLoc`` nodes that
213+
allows them to enjoy the same static type checking as other AST node kinds.
188214

189215
clang-format
190216
------------

0 commit comments

Comments
 (0)