Skip to content

Commit 9d1b437

Browse files
committed
Merge remote-tracking branch 'intel_llvm/sycl' into slm_load4_rename
2 parents 2570610 + 5b8f3b0 commit 9d1b437

File tree

5,476 files changed

+262620
-355620
lines changed

Some content is hidden

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

5,476 files changed

+262620
-355620
lines changed

.github/workflows/linux_post_commit.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,15 @@ jobs:
1818
with:
1919
path: src
2020
- name: Install Ubuntu deps
21-
run: sudo apt install -y ninja-build
21+
run: sudo apt install -y ninja-build ccache
22+
- name: Setup Cache
23+
uses: actions/cache@v2
24+
id: cache
25+
with:
26+
path: ${{ github.workspace }}/cache
27+
key: build-${{ runner.os }}-${{ matrix.config }}-${{ github.sha }}
28+
restore-keys: |
29+
build-${{ runner.os }}-${{ matrix.config }}-
2230
- name: Configure
2331
run: |
2432
CONFIG=${{ matrix.config }}
@@ -42,7 +50,10 @@ jobs:
4250
mkdir -p $GITHUB_WORKSPACE/build
4351
cd $GITHUB_WORKSPACE/build
4452
python3 $GITHUB_WORKSPACE/src/buildbot/configure.py -w $GITHUB_WORKSPACE \
45-
-s $GITHUB_WORKSPACE/src -o $GITHUB_WORKSPACE/build -t Release --ci-defaults $ARGS
53+
-s $GITHUB_WORKSPACE/src -o $GITHUB_WORKSPACE/build -t Release \
54+
--ci-defaults $ARGS --cmake-opt="-DLLVM_CCACHE_BUILD=ON" \
55+
--cmake-opt="-DLLVM_CCACHE_DIR=$GITHUB_WORKSPACE/cache" \
56+
--cmake-opt="-DLLVM_CCACHE_MAXSIZE=2G"
4657
- name: Compile
4758
run: |
4859
python3 $GITHUB_WORKSPACE/src/buildbot/compile.py -w $GITHUB_WORKSPACE \

buildbot/dependency.conf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ ocl_cpu_rt_ver=2021.12.6.0.19
44
# https://github.com/intel/llvm/releases/download/2021-WW26/win-oclcpuexp-2021.12.6.0.19_rel.zip
55
ocl_cpu_rt_ver_win=2021.12.6.0.19
66
# Same GPU driver supports Level Zero and OpenCL
7-
# https://github.com/intel/compute-runtime/releases/tag/21.34.20767
8-
ocl_gpu_rt_ver=21.34.20767
7+
# https://github.com/intel/compute-runtime/releases/tag/21.37.20939
8+
ocl_gpu_rt_ver=21.37.20939
99
# Same GPU driver supports Level Zero and OpenCL
1010
# https://downloadmirror.intel.com/648245/igfx_win_100.9864.zip
1111
ocl_gpu_rt_ver_win=30.0.100.9864
@@ -30,7 +30,7 @@ ocloc_ver_win=27.20.100.9168
3030
[DRIVER VERSIONS]
3131
cpu_driver_lin=2021.12.6.0.19
3232
cpu_driver_win=2021.12.6.0.19
33-
gpu_driver_lin=21.34.20767
33+
gpu_driver_lin=21.37.20939
3434
gpu_driver_win=30.0.100.9864
3535
fpga_driver_lin=2021.12.6.0.19
3636
fpga_driver_win=2021.12.6.0.19

clang-tools-extra/clang-include-fixer/IncludeFixer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ clang::TypoCorrection IncludeFixerSemaSource::CorrectTypo(
245245
// parent_path.
246246
// FIXME: Don't rely on source text.
247247
const char *End = Source.end();
248-
while (isIdentifierBody(*End) || *End == ':')
248+
while (isAsciiIdentifierContinue(*End) || *End == ':')
249249
++End;
250250

251251
return std::string(Source.begin(), End);

clang-tools-extra/clang-tidy/abseil/AbseilMatcher.h

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,11 @@ AST_POLYMORPHIC_MATCHER(
4747
if (PrefixPosition == StringRef::npos)
4848
return false;
4949
Path = Path.drop_front(PrefixPosition + AbslPrefix.size());
50-
static const char *AbseilLibraries[] = {"algorithm", "base",
51-
"container", "debugging",
52-
"flags", "hash",
53-
"iterator", "memory",
54-
"meta", "numeric",
55-
"random", "status",
56-
"strings", "synchronization",
57-
"time", "types",
58-
"utility"};
50+
static const char *AbseilLibraries[] = {
51+
"algorithm", "base", "container", "debugging", "flags",
52+
"hash", "iterator", "memory", "meta", "numeric",
53+
"profiling", "random", "status", "strings", "synchronization",
54+
"time", "types", "utility"};
5955
return llvm::any_of(AbseilLibraries, [&](const char *Library) {
6056
return Path.startswith(Library);
6157
});

clang-tools-extra/clang-tidy/add_new_check.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#===-----------------------------------------------------------------------===#
1010

1111
from __future__ import print_function
12+
from __future__ import unicode_literals
1213

1314
import argparse
1415
import io

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,17 @@ static bool isVarThatIsPossiblyChanged(const Decl *Func, const Stmt *LoopStmt,
6565
ObjCIvarRefExpr, ObjCPropertyRefExpr, ObjCMessageExpr>(Cond)) {
6666
// FIXME: Handle MemberExpr.
6767
return true;
68+
} else if (const auto *CE = dyn_cast<CastExpr>(Cond)) {
69+
QualType T = CE->getType();
70+
while (true) {
71+
if (T.isVolatileQualified())
72+
return true;
73+
74+
if (!T->isAnyPointerType() && !T->isReferenceType())
75+
break;
76+
77+
T = T->getPointeeType();
78+
}
6879
}
6980

7081
return false;

clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ add_clang_library(clangTidyCppCoreGuidelinesModule
2626
ProTypeVarargCheck.cpp
2727
SlicingCheck.cpp
2828
SpecialMemberFunctionsCheck.cpp
29+
VirtualClassDestructorCheck.cpp
2930

3031
LINK_LIBS
3132
clangTidy

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include "ProTypeVarargCheck.h"
3636
#include "SlicingCheck.h"
3737
#include "SpecialMemberFunctionsCheck.h"
38+
#include "VirtualClassDestructorCheck.h"
3839

3940
namespace clang {
4041
namespace tidy {
@@ -94,6 +95,8 @@ class CppCoreGuidelinesModule : public ClangTidyModule {
9495
CheckFactories.registerCheck<SlicingCheck>("cppcoreguidelines-slicing");
9596
CheckFactories.registerCheck<misc::UnconventionalAssignOperatorCheck>(
9697
"cppcoreguidelines-c-copy-assignment-signature");
98+
CheckFactories.registerCheck<VirtualClassDestructorCheck>(
99+
"cppcoreguidelines-virtual-class-destructor");
97100
}
98101

99102
ClangTidyOptions getModuleOptions() override {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ static bool isSafeAssignment(const FieldDecl *Field, const Expr *Init,
8383
.empty();
8484
}
8585

86-
static const std::pair<const FieldDecl *, const Expr *>
86+
static std::pair<const FieldDecl *, const Expr *>
8787
isAssignmentToMemberOf(const CXXRecordDecl *Rec, const Stmt *S,
8888
const CXXConstructorDecl *Ctor) {
8989
if (const auto *BO = dyn_cast<BinaryOperator>(S)) {
Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
//===--- VirtualClassDestructorCheck.cpp - clang-tidy -----------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include "VirtualClassDestructorCheck.h"
10+
#include "../utils/LexerUtils.h"
11+
#include "clang/AST/ASTContext.h"
12+
#include "clang/ASTMatchers/ASTMatchFinder.h"
13+
#include "clang/Lex/Lexer.h"
14+
#include <string>
15+
16+
using namespace clang::ast_matchers;
17+
18+
namespace clang {
19+
namespace tidy {
20+
namespace cppcoreguidelines {
21+
22+
void VirtualClassDestructorCheck::registerMatchers(MatchFinder *Finder) {
23+
ast_matchers::internal::Matcher<CXXRecordDecl> InheritsVirtualMethod =
24+
hasAnyBase(hasType(cxxRecordDecl(has(cxxMethodDecl(isVirtual())))));
25+
26+
Finder->addMatcher(
27+
cxxRecordDecl(
28+
anyOf(has(cxxMethodDecl(isVirtual())), InheritsVirtualMethod),
29+
unless(anyOf(
30+
has(cxxDestructorDecl(isPublic(), isVirtual())),
31+
has(cxxDestructorDecl(isProtected(), unless(isVirtual()))))))
32+
.bind("ProblematicClassOrStruct"),
33+
this);
34+
}
35+
36+
static CharSourceRange
37+
getVirtualKeywordRange(const CXXDestructorDecl &Destructor,
38+
const SourceManager &SM, const LangOptions &LangOpts) {
39+
SourceLocation VirtualBeginLoc = Destructor.getBeginLoc();
40+
SourceLocation VirtualEndLoc = VirtualBeginLoc.getLocWithOffset(
41+
Lexer::MeasureTokenLength(VirtualBeginLoc, SM, LangOpts));
42+
43+
/// Range ends with \c StartOfNextToken so that any whitespace after \c
44+
/// virtual is included.
45+
SourceLocation StartOfNextToken =
46+
Lexer::findNextToken(VirtualEndLoc, SM, LangOpts)
47+
.getValue()
48+
.getLocation();
49+
50+
return CharSourceRange::getCharRange(VirtualBeginLoc, StartOfNextToken);
51+
}
52+
53+
static const AccessSpecDecl *
54+
getPublicASDecl(const CXXRecordDecl &StructOrClass) {
55+
for (DeclContext::specific_decl_iterator<AccessSpecDecl>
56+
AS{StructOrClass.decls_begin()},
57+
ASEnd{StructOrClass.decls_end()};
58+
AS != ASEnd; ++AS) {
59+
AccessSpecDecl *ASDecl = *AS;
60+
if (ASDecl->getAccess() == AccessSpecifier::AS_public)
61+
return ASDecl;
62+
}
63+
64+
return nullptr;
65+
}
66+
67+
static FixItHint
68+
generateUserDeclaredDestructor(const CXXRecordDecl &StructOrClass,
69+
const SourceManager &SourceManager) {
70+
std::string DestructorString;
71+
SourceLocation Loc;
72+
bool AppendLineBreak = false;
73+
74+
const AccessSpecDecl *AccessSpecDecl = getPublicASDecl(StructOrClass);
75+
76+
if (!AccessSpecDecl) {
77+
if (StructOrClass.isClass()) {
78+
Loc = StructOrClass.getEndLoc();
79+
DestructorString = "public:";
80+
AppendLineBreak = true;
81+
} else {
82+
Loc = StructOrClass.getBraceRange().getBegin().getLocWithOffset(1);
83+
}
84+
} else {
85+
Loc = AccessSpecDecl->getEndLoc().getLocWithOffset(1);
86+
}
87+
88+
DestructorString = (llvm::Twine(DestructorString) + "\nvirtual ~" +
89+
StructOrClass.getName().str() + "() = default;" +
90+
(AppendLineBreak ? "\n" : ""))
91+
.str();
92+
93+
return FixItHint::CreateInsertion(Loc, DestructorString);
94+
}
95+
96+
static std::string getSourceText(const CXXDestructorDecl &Destructor) {
97+
std::string SourceText;
98+
llvm::raw_string_ostream DestructorStream(SourceText);
99+
Destructor.print(DestructorStream);
100+
return SourceText;
101+
}
102+
103+
static std::string eraseKeyword(std::string &DestructorString,
104+
const std::string &Keyword) {
105+
size_t KeywordIndex = DestructorString.find(Keyword);
106+
if (KeywordIndex != std::string::npos)
107+
DestructorString.erase(KeywordIndex, Keyword.length());
108+
return DestructorString;
109+
}
110+
111+
static FixItHint changePrivateDestructorVisibilityTo(
112+
const std::string &Visibility, const CXXDestructorDecl &Destructor,
113+
const SourceManager &SM, const LangOptions &LangOpts) {
114+
std::string DestructorString =
115+
(llvm::Twine() + Visibility + ":\n" +
116+
(Visibility == "public" && !Destructor.isVirtual() ? "virtual " : ""))
117+
.str();
118+
119+
std::string OriginalDestructor = getSourceText(Destructor);
120+
if (Visibility == "protected" && Destructor.isVirtualAsWritten())
121+
OriginalDestructor = eraseKeyword(OriginalDestructor, "virtual ");
122+
123+
DestructorString =
124+
(llvm::Twine(DestructorString) + OriginalDestructor +
125+
(Destructor.isExplicitlyDefaulted() ? ";\n" : "") + "private:")
126+
.str();
127+
128+
/// Semicolons ending an explicitly defaulted destructor have to be deleted.
129+
/// Otherwise, the left-over semicolon trails the \c private: access
130+
/// specifier.
131+
SourceLocation EndLocation;
132+
if (Destructor.isExplicitlyDefaulted())
133+
EndLocation =
134+
utils::lexer::findNextTerminator(Destructor.getEndLoc(), SM, LangOpts)
135+
.getLocWithOffset(1);
136+
else
137+
EndLocation = Destructor.getEndLoc().getLocWithOffset(1);
138+
139+
auto OriginalDestructorRange =
140+
CharSourceRange::getCharRange(Destructor.getBeginLoc(), EndLocation);
141+
return FixItHint::CreateReplacement(OriginalDestructorRange,
142+
DestructorString);
143+
}
144+
145+
void VirtualClassDestructorCheck::check(
146+
const MatchFinder::MatchResult &Result) {
147+
148+
const auto *MatchedClassOrStruct =
149+
Result.Nodes.getNodeAs<CXXRecordDecl>("ProblematicClassOrStruct");
150+
151+
const CXXDestructorDecl *Destructor = MatchedClassOrStruct->getDestructor();
152+
if (!Destructor)
153+
return;
154+
155+
if (Destructor->getAccess() == AccessSpecifier::AS_private) {
156+
diag(MatchedClassOrStruct->getLocation(),
157+
"destructor of %0 is private and prevents using the type")
158+
<< MatchedClassOrStruct;
159+
diag(MatchedClassOrStruct->getLocation(),
160+
/*FixDescription=*/"make it public and virtual", DiagnosticIDs::Note)
161+
<< changePrivateDestructorVisibilityTo(
162+
"public", *Destructor, *Result.SourceManager, getLangOpts());
163+
diag(MatchedClassOrStruct->getLocation(),
164+
/*FixDescription=*/"make it protected", DiagnosticIDs::Note)
165+
<< changePrivateDestructorVisibilityTo(
166+
"protected", *Destructor, *Result.SourceManager, getLangOpts());
167+
168+
return;
169+
}
170+
171+
// Implicit destructors are public and non-virtual for classes and structs.
172+
bool ProtectedAndVirtual = false;
173+
FixItHint Fix;
174+
175+
if (MatchedClassOrStruct->hasUserDeclaredDestructor()) {
176+
if (Destructor->getAccess() == AccessSpecifier::AS_public) {
177+
Fix = FixItHint::CreateInsertion(Destructor->getLocation(), "virtual ");
178+
} else if (Destructor->getAccess() == AccessSpecifier::AS_protected) {
179+
ProtectedAndVirtual = true;
180+
Fix = FixItHint::CreateRemoval(getVirtualKeywordRange(
181+
*Destructor, *Result.SourceManager, Result.Context->getLangOpts()));
182+
}
183+
} else {
184+
Fix = generateUserDeclaredDestructor(*MatchedClassOrStruct,
185+
*Result.SourceManager);
186+
}
187+
188+
diag(MatchedClassOrStruct->getLocation(),
189+
"destructor of %0 is %select{public and non-virtual|protected and "
190+
"virtual}1")
191+
<< MatchedClassOrStruct << ProtectedAndVirtual;
192+
diag(MatchedClassOrStruct->getLocation(),
193+
"make it %select{public and virtual|protected and non-virtual}0",
194+
DiagnosticIDs::Note)
195+
<< ProtectedAndVirtual << Fix;
196+
}
197+
198+
} // namespace cppcoreguidelines
199+
} // namespace tidy
200+
} // namespace clang
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
//===--- VirtualClassDestructorCheck.h - clang-tidy -------------*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_VIRTUALCLASSDESTRUCTORCHECK_H
10+
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_VIRTUALCLASSDESTRUCTORCHECK_H
11+
12+
#include "../ClangTidyCheck.h"
13+
#include <string>
14+
15+
namespace clang {
16+
namespace tidy {
17+
namespace cppcoreguidelines {
18+
19+
/// Finds base classes whose destructor is neither public and virtual
20+
/// nor protected and non-virtual.
21+
///
22+
/// For the user-facing documentation see:
23+
/// http://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines-virtual-class-destructor.html
24+
class VirtualClassDestructorCheck : public ClangTidyCheck {
25+
public:
26+
VirtualClassDestructorCheck(StringRef Name, ClangTidyContext *Context)
27+
: ClangTidyCheck(Name, Context) {}
28+
29+
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
30+
return LangOpts.CPlusPlus;
31+
}
32+
33+
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
34+
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
35+
};
36+
37+
} // namespace cppcoreguidelines
38+
} // namespace tidy
39+
} // namespace clang
40+
41+
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_VIRTUALCLASSDESTRUCTORCHECK_H

clang-tools-extra/clang-tidy/google/IntegerTypesCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ void IntegerTypesCheck::check(const MatchFinder::MatchResult &Result) {
129129
const StringRef Port = "unsigned short port";
130130
const char *Data = Result.SourceManager->getCharacterData(Loc);
131131
if (!std::strncmp(Data, Port.data(), Port.size()) &&
132-
!isIdentifierBody(Data[Port.size()]))
132+
!isAsciiIdentifierContinue(Data[Port.size()]))
133133
return;
134134

135135
std::string Replacement =

clang-tools-extra/clang-tidy/readability/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ add_clang_library(clangTidyReadabilityModule
77
AvoidConstParamsInDecls.cpp
88
BracesAroundStatementsCheck.cpp
99
ConstReturnTypeCheck.cpp
10+
ContainerDataPointerCheck.cpp
1011
ContainerSizeEmptyCheck.cpp
1112
ConvertMemberFunctionsToStatic.cpp
1213
DeleteNullPointerCheck.cpp

0 commit comments

Comments
 (0)