Skip to content

Commit e4b7866

Browse files
author
Alexander Batashev
committed
Merge remote-tracking branch 'upstream/sycl' into global_constructors_wrapper
* upstream/sycl: (1021 commits) [SYCL] Enable async_work_group_copy for scalar and vector bool types (intel#2582) [SYCL] Fix element type in handler::copy (intel#2590) [NFC][SYCL] Remove unnecessary if condition (intel#2585) [SYCL][NFC] Fix SYCL lit test execution on a system w/o GPU (intel#2584) [SYCL] Add error handling for non-uniform work group size case (intel#2569) [SYCL][ESIMD] Preserve undef initializer for globals in ESIMDLowerVecArg pass (intel#2555) [SYCL] Make Level-Zero events visible on the host (intel#2576) [Driver][SYCL][NFC] Add help information for -Wno-sycl-strict (intel#2570) [SYCL] Relax test to work in Win32 environment. (intel#2580) [SYCL] Emit suppressed warnings from SYCL headers (intel#2575) [SYCL][NFC] Cover more classes with ABI tests (intel#2577) [SYCL][ESIMD] Update ESIMD tests and add raw send support. (intel#2482) [SYCL] Make ESIMD on-device tests require linux,gpu,opencl. (intel#2560) [SYCL] Release commands with no dependencies after they're enqueued (intel#2492) [SYCL] Add multi-device and multi-platform support for SYCL_DEVICE_ALLOWLIST (intel#2483) [SYCL] Try to enqueue host command depencies (intel#2561) [SYCL][ESIMD][NFC] Align namespace name with the spec guidelines (intel#2573) [SYCL][NFC] Add class layout ABI tests for memory objects (intel#2559) [SYCL] Change adress space for global variables (intel#2534) [NFC][SYCL] Fix comment. (intel#2541) ...
2 parents f9a0263 + bb78d2c commit e4b7866

File tree

2,562 files changed

+471581
-31466
lines changed

Some content is hidden

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

2,562 files changed

+471581
-31466
lines changed

.git-blame-ignore-revs

+6
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,9 @@ d8f0e6caa91e230a486c948ab643174e40bdf215
3434

3535
# Cleanup __config indention. NFC.
3636
2b772b930e097ed6f06d698a51e291c7fd318baa
37+
38+
# Fixing whitespace problems
39+
94b2dd0998230c758abd92c99d3700c971f7a31a
40+
41+
# Wiped out some non-ascii characters that snuck into the copyright.
42+
5b08a8a43254ed30bd953e869b0fd9fc1e8b82d0

buildbot/dependency.conf

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ ocl_cpu_rt_ver=2020.11.8.0.27
44
# https://github.com/intel/llvm/releases/download/2020-WW36/win-oclcpuexp-2020.11.8.0.27_rel.zip
55
ocl_cpu_rt_ver_win=2020.11.8.0.27
66
# Same GPU driver supports Level Zero and OpenCL:
7-
# https://github.com/intel/compute-runtime/releases/tag/20.35.17767
8-
ocl_gpu_rt_ver=20.35.17767
7+
# https://github.com/intel/compute-runtime/releases/tag/20.37.17906
8+
ocl_gpu_rt_ver=20.37.17906
99
# Same GPU driver supports Level Zero and OpenCL:
1010
# https://downloadmirror.intel.com/29879/a08/igfx_win10_100.8778.zip
1111
ocl_gpu_rt_ver_win=27.20.100.8778
@@ -24,7 +24,7 @@ fpga_ver_win=20200811_000006
2424
[DRIVER VERSIONS]
2525
cpu_driver_lin=2020.11.8.0.27
2626
cpu_driver_win=2020.11.8.0.27
27-
gpu_driver_lin=20.35.17767
27+
gpu_driver_lin=20.37.17906
2828
gpu_driver_win=27.20.100.8778
2929
fpga_driver_lin=2020.11.8.0.27
3030
fpga_driver_win=2020.11.8.0.27

clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ void StringFindStartswithCheck::check(const MatchFinder::MatchResult &Result) {
106106
// Create a preprocessor #include FixIt hint (CreateIncludeInsertion checks
107107
// whether this already exists).
108108
Diagnostic << IncludeInserter.createIncludeInsertion(
109-
Source.getFileID(ComparisonExpr->getBeginLoc()), AbseilStringsMatchHeader,
110-
false);
109+
Source.getFileID(ComparisonExpr->getBeginLoc()),
110+
AbseilStringsMatchHeader);
111111
}
112112

113113
void StringFindStartswithCheck::registerPPCallbacks(

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

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ add_clang_library(clangTidyCppCoreGuidelinesModule
1313
NarrowingConversionsCheck.cpp
1414
NoMallocCheck.cpp
1515
OwningMemoryCheck.cpp
16+
PreferMemberInitializerCheck.cpp
1617
ProBoundsArrayToPointerDecayCheck.cpp
1718
ProBoundsConstantArrayIndexCheck.cpp
1819
ProBoundsPointerArithmeticCheck.cpp

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

+3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "NarrowingConversionsCheck.h"
2323
#include "NoMallocCheck.h"
2424
#include "OwningMemoryCheck.h"
25+
#include "PreferMemberInitializerCheck.h"
2526
#include "ProBoundsArrayToPointerDecayCheck.h"
2627
#include "ProBoundsConstantArrayIndexCheck.h"
2728
#include "ProBoundsPointerArithmeticCheck.h"
@@ -66,6 +67,8 @@ class CppCoreGuidelinesModule : public ClangTidyModule {
6667
"cppcoreguidelines-non-private-member-variables-in-classes");
6768
CheckFactories.registerCheck<OwningMemoryCheck>(
6869
"cppcoreguidelines-owning-memory");
70+
CheckFactories.registerCheck<PreferMemberInitializerCheck>(
71+
"cppcoreguidelines-prefer-member-initializer");
6972
CheckFactories.registerCheck<ProBoundsArrayToPointerDecayCheck>(
7073
"cppcoreguidelines-pro-bounds-array-to-pointer-decay");
7174
CheckFactories.registerCheck<ProBoundsConstantArrayIndexCheck>(

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ InitVariablesCheck::InitVariablesCheck(StringRef Name,
2828
: ClangTidyCheck(Name, Context),
2929
IncludeInserter(Options.getLocalOrGlobal("IncludeStyle",
3030
utils::IncludeSorter::IS_LLVM)),
31-
MathHeader(Options.get("MathHeader", "math.h")) {}
31+
MathHeader(Options.get("MathHeader", "<math.h>")) {}
3232

3333
void InitVariablesCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
3434
Options.store(Opts, "IncludeStyle", IncludeInserter.getStyle());
@@ -103,7 +103,7 @@ void InitVariablesCheck::check(const MatchFinder::MatchResult &Result) {
103103
InitializationString);
104104
if (AddMathInclude) {
105105
Diagnostic << IncludeInserter.createIncludeInsertion(
106-
Source.getFileID(MatchedDecl->getBeginLoc()), MathHeader, false);
106+
Source.getFileID(MatchedDecl->getBeginLoc()), MathHeader);
107107
}
108108
}
109109
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,246 @@
1+
//===--- PreferMemberInitializerCheck.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 "PreferMemberInitializerCheck.h"
10+
#include "clang/AST/ASTContext.h"
11+
#include "clang/ASTMatchers/ASTMatchFinder.h"
12+
#include "clang/Lex/Lexer.h"
13+
14+
using namespace clang::ast_matchers;
15+
16+
namespace clang {
17+
namespace tidy {
18+
namespace cppcoreguidelines {
19+
20+
static bool isControlStatement(const Stmt *S) {
21+
return isa<IfStmt, SwitchStmt, ForStmt, WhileStmt, DoStmt, ReturnStmt,
22+
GotoStmt, CXXTryStmt, CXXThrowExpr>(S);
23+
}
24+
25+
static bool isNoReturnCallStatement(const Stmt *S) {
26+
const auto *Call = dyn_cast<CallExpr>(S);
27+
if (!Call)
28+
return false;
29+
30+
const FunctionDecl *Func = Call->getDirectCallee();
31+
if (!Func)
32+
return false;
33+
34+
return Func->isNoReturn();
35+
}
36+
37+
static bool isLiteral(const Expr *E) {
38+
return isa<StringLiteral, CharacterLiteral, IntegerLiteral, FloatingLiteral,
39+
CXXBoolLiteralExpr, CXXNullPtrLiteralExpr>(E);
40+
}
41+
42+
static bool isUnaryExprOfLiteral(const Expr *E) {
43+
if (const auto *UnOp = dyn_cast<UnaryOperator>(E))
44+
return isLiteral(UnOp->getSubExpr());
45+
return false;
46+
}
47+
48+
static bool shouldBeDefaultMemberInitializer(const Expr *Value) {
49+
if (isLiteral(Value) || isUnaryExprOfLiteral(Value))
50+
return true;
51+
52+
if (const auto *DRE = dyn_cast<DeclRefExpr>(Value))
53+
return isa<EnumConstantDecl>(DRE->getDecl());
54+
55+
return false;
56+
}
57+
58+
static const std::pair<const FieldDecl *, const Expr *>
59+
isAssignmentToMemberOf(const RecordDecl *Rec, const Stmt *S) {
60+
if (const auto *BO = dyn_cast<BinaryOperator>(S)) {
61+
if (BO->getOpcode() != BO_Assign)
62+
return std::make_pair(nullptr, nullptr);
63+
64+
const auto *ME = dyn_cast<MemberExpr>(BO->getLHS()->IgnoreParenImpCasts());
65+
if (!ME)
66+
return std::make_pair(nullptr, nullptr);
67+
68+
const auto *Field = dyn_cast<FieldDecl>(ME->getMemberDecl());
69+
if (!Field)
70+
return std::make_pair(nullptr, nullptr);
71+
72+
if (isa<CXXThisExpr>(ME->getBase()))
73+
return std::make_pair(Field, BO->getRHS()->IgnoreParenImpCasts());
74+
} else if (const auto *COCE = dyn_cast<CXXOperatorCallExpr>(S)) {
75+
if (COCE->getOperator() != OO_Equal)
76+
return std::make_pair(nullptr, nullptr);
77+
78+
const auto *ME =
79+
dyn_cast<MemberExpr>(COCE->getArg(0)->IgnoreParenImpCasts());
80+
if (!ME)
81+
return std::make_pair(nullptr, nullptr);
82+
83+
const auto *Field = dyn_cast<FieldDecl>(ME->getMemberDecl());
84+
if (!Field)
85+
return std::make_pair(nullptr, nullptr);
86+
87+
if (isa<CXXThisExpr>(ME->getBase()))
88+
return std::make_pair(Field, COCE->getArg(1)->IgnoreParenImpCasts());
89+
}
90+
91+
return std::make_pair(nullptr, nullptr);
92+
}
93+
94+
PreferMemberInitializerCheck::PreferMemberInitializerCheck(
95+
StringRef Name, ClangTidyContext *Context)
96+
: ClangTidyCheck(Name, Context),
97+
IsUseDefaultMemberInitEnabled(
98+
Context->isCheckEnabled("modernize-use-default-member-init")),
99+
UseAssignment(OptionsView("modernize-use-default-member-init",
100+
Context->getOptions().CheckOptions)
101+
.get("UseAssignment", false)) {}
102+
103+
void PreferMemberInitializerCheck::storeOptions(
104+
ClangTidyOptions::OptionMap &Opts) {
105+
Options.store(Opts, "UseAssignment", UseAssignment);
106+
}
107+
108+
void PreferMemberInitializerCheck::registerMatchers(MatchFinder *Finder) {
109+
Finder->addMatcher(
110+
cxxConstructorDecl(hasBody(compoundStmt()), unless(isInstantiated()))
111+
.bind("ctor"),
112+
this);
113+
}
114+
115+
void PreferMemberInitializerCheck::check(
116+
const MatchFinder::MatchResult &Result) {
117+
const auto *Ctor = Result.Nodes.getNodeAs<CXXConstructorDecl>("ctor");
118+
const auto *Body = cast<CompoundStmt>(Ctor->getBody());
119+
120+
const CXXRecordDecl *Class = Ctor->getParent();
121+
SourceLocation InsertPos;
122+
bool FirstToCtorInits = true;
123+
124+
for (const Stmt *S : Body->body()) {
125+
if (S->getBeginLoc().isMacroID()) {
126+
StringRef MacroName =
127+
Lexer::getImmediateMacroName(S->getBeginLoc(), *Result.SourceManager,
128+
getLangOpts());
129+
if (MacroName.contains_lower("assert"))
130+
return;
131+
}
132+
if (isControlStatement(S))
133+
return;
134+
135+
if (isNoReturnCallStatement(S))
136+
return;
137+
138+
if (const auto *CondOp = dyn_cast<ConditionalOperator>(S)) {
139+
if (isNoReturnCallStatement(CondOp->getLHS()) ||
140+
isNoReturnCallStatement(CondOp->getRHS()))
141+
return;
142+
}
143+
144+
const FieldDecl *Field;
145+
const Expr *InitValue;
146+
std::tie(Field, InitValue) = isAssignmentToMemberOf(Class, S);
147+
if (Field) {
148+
if (IsUseDefaultMemberInitEnabled && getLangOpts().CPlusPlus11 &&
149+
Ctor->isDefaultConstructor() &&
150+
(getLangOpts().CPlusPlus20 || !Field->isBitField()) &&
151+
(!isa<RecordDecl>(Class->getDeclContext()) ||
152+
!cast<RecordDecl>(Class->getDeclContext())->isUnion()) &&
153+
shouldBeDefaultMemberInitializer(InitValue)) {
154+
auto Diag =
155+
diag(S->getBeginLoc(), "%0 should be initialized in an in-class"
156+
" default member initializer")
157+
<< Field;
158+
159+
SourceLocation FieldEnd =
160+
Lexer::getLocForEndOfToken(Field->getSourceRange().getEnd(), 0,
161+
*Result.SourceManager, getLangOpts());
162+
Diag << FixItHint::CreateInsertion(FieldEnd,
163+
UseAssignment ? " = " : "{")
164+
<< FixItHint::CreateInsertionFromRange(
165+
FieldEnd,
166+
CharSourceRange(InitValue->getSourceRange(), true))
167+
<< FixItHint::CreateInsertion(FieldEnd, UseAssignment ? "" : "}");
168+
169+
SourceLocation SemiColonEnd =
170+
Lexer::findNextToken(S->getEndLoc(), *Result.SourceManager,
171+
getLangOpts())
172+
->getEndLoc();
173+
CharSourceRange StmtRange =
174+
CharSourceRange::getCharRange(S->getBeginLoc(), SemiColonEnd);
175+
176+
Diag << FixItHint::CreateRemoval(StmtRange);
177+
} else {
178+
auto Diag =
179+
diag(S->getBeginLoc(), "%0 should be initialized in a member"
180+
" initializer of the constructor")
181+
<< Field;
182+
183+
bool AddComma = false;
184+
if (!Ctor->getNumCtorInitializers() && FirstToCtorInits) {
185+
SourceLocation BodyPos = Ctor->getBody()->getBeginLoc();
186+
SourceLocation NextPos = Ctor->getBeginLoc();
187+
do {
188+
InsertPos = NextPos;
189+
NextPos = Lexer::findNextToken(NextPos, *Result.SourceManager,
190+
getLangOpts())
191+
->getLocation();
192+
} while (NextPos != BodyPos);
193+
InsertPos = Lexer::getLocForEndOfToken(
194+
InsertPos, 0, *Result.SourceManager, getLangOpts());
195+
196+
Diag << FixItHint::CreateInsertion(InsertPos, " : ");
197+
} else {
198+
bool Found = false;
199+
for (const auto *Init : Ctor->inits()) {
200+
if (Init->isMemberInitializer()) {
201+
if (Result.SourceManager->isBeforeInTranslationUnit(
202+
Field->getLocation(), Init->getMember()->getLocation())) {
203+
InsertPos = Init->getSourceLocation();
204+
Found = true;
205+
break;
206+
}
207+
}
208+
}
209+
210+
if (!Found) {
211+
if (Ctor->getNumCtorInitializers()) {
212+
InsertPos = Lexer::getLocForEndOfToken(
213+
(*Ctor->init_rbegin())->getSourceRange().getEnd(), 0,
214+
*Result.SourceManager, getLangOpts());
215+
}
216+
Diag << FixItHint::CreateInsertion(InsertPos, ", ");
217+
} else {
218+
AddComma = true;
219+
}
220+
}
221+
Diag << FixItHint::CreateInsertion(InsertPos, Field->getName())
222+
<< FixItHint::CreateInsertion(InsertPos, "(")
223+
<< FixItHint::CreateInsertionFromRange(
224+
InsertPos,
225+
CharSourceRange(InitValue->getSourceRange(), true))
226+
<< FixItHint::CreateInsertion(InsertPos, ")");
227+
if (AddComma)
228+
Diag << FixItHint::CreateInsertion(InsertPos, ", ");
229+
230+
SourceLocation SemiColonEnd =
231+
Lexer::findNextToken(S->getEndLoc(), *Result.SourceManager,
232+
getLangOpts())
233+
->getEndLoc();
234+
CharSourceRange StmtRange =
235+
CharSourceRange::getCharRange(S->getBeginLoc(), SemiColonEnd);
236+
237+
Diag << FixItHint::CreateRemoval(StmtRange);
238+
FirstToCtorInits = false;
239+
}
240+
}
241+
}
242+
}
243+
244+
} // namespace cppcoreguidelines
245+
} // namespace tidy
246+
} // namespace clang
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
//===--- PreferMemberInitializerCheck.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_PREFERMEMBERINITIALIZERCHECK_H
10+
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_PREFERMEMBERINITIALIZERCHECK_H
11+
12+
#include "../ClangTidyCheck.h"
13+
14+
namespace clang {
15+
namespace tidy {
16+
namespace cppcoreguidelines {
17+
18+
/// Finds member initializations in the constructor body which can be placed
19+
/// into the initialization list instead.
20+
///
21+
/// For the user-facing documentation see:
22+
/// http://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines-prefer-member-initializer.html
23+
class PreferMemberInitializerCheck : public ClangTidyCheck {
24+
public:
25+
PreferMemberInitializerCheck(StringRef Name, ClangTidyContext *Context);
26+
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
27+
return LangOpts.CPlusPlus;
28+
}
29+
void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
30+
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
31+
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
32+
33+
const bool IsUseDefaultMemberInitEnabled;
34+
const bool UseAssignment;
35+
};
36+
37+
} // namespace cppcoreguidelines
38+
} // namespace tidy
39+
} // namespace clang
40+
41+
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_PREFERMEMBERINITIALIZERCHECK_H

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,7 @@ void ProBoundsConstantArrayIndexCheck::check(
8585
IndexRange.getBegin().getLocWithOffset(-1)),
8686
", ")
8787
<< FixItHint::CreateReplacement(Matched->getEndLoc(), ")")
88-
<< Inserter.createMainFileIncludeInsertion(GslHeader,
89-
/*IsAngled=*/false);
88+
<< Inserter.createMainFileIncludeInsertion(GslHeader);
9089
}
9190
return;
9291
}

0 commit comments

Comments
 (0)