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
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
<compnerd@compnerd.org> <abdulras@fb.com>
2626
<compnerd@compnerd.org> <abdulras@google.com>
27+
<hans@hanshq.net> <hans@chromium.org>
2728
<i@maskray.me> <maskray@google.com>
2829
<JCTremoulet@gmail.com> <jotrem@microsoft.com>
2930
<qiucofan@cn.ibm.com> <qiucf@cn.ibm.com>

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

0 commit comments

Comments
 (0)