Skip to content

Commit b3bc848

Browse files
committed
Merge remote-tracking branch 'upstream/sycl' into glyons/offset
2 parents 56167e1 + e35466b commit b3bc848

File tree

5,452 files changed

+289597
-109197
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,452 files changed

+289597
-109197
lines changed

buildbot/dependency.conf

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
[VERSIONS]
2-
# https://github.com/intel/llvm/releases/download/2020-WW31/oclcpuexp-2020.10.7.0.15_rel.tar.gz
3-
ocl_cpu_rt_ver=2020.10.7.0.15
4-
# https://github.com/intel/llvm/releases/download/2020-WW31/win-oclcpuexp-2020.10.7.0.15_rel.zip
5-
ocl_cpu_rt_ver_win=2020.10.7.0.15
2+
# https://github.com/intel/llvm/releases/download/2020-WW36/oclcpuexp-2020.11.8.0.27_rel.tar.gz
3+
ocl_cpu_rt_ver=2020.11.8.0.27
4+
# https://github.com/intel/llvm/releases/download/2020-WW36/win-oclcpuexp-2020.11.8.0.27_rel.zip
5+
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.29.17408
8-
ocl_gpu_rt_ver=20.29.17408
7+
# https://github.com/intel/compute-runtime/releases/tag/20.35.17767
8+
ocl_gpu_rt_ver=20.35.17767
99
# Same GPU driver supports Level Zero and OpenCL:
10-
# https://downloadmirror.intel.com/29674/a08/igfx_win10_100.8336.zip
11-
ocl_gpu_rt_ver_win=27.20.100.8336
10+
# https://downloadmirror.intel.com/29817/a08/igfx_win10_100.8673.zip
11+
ocl_gpu_rt_ver_win=27.20.100.8673
1212
intel_sycl_ver=build
1313
# https://github.com/oneapi-src/oneTBB/releases/download/v2021.1-beta08/oneapi-tbb-2021.1-beta08-lin.tgz
14-
tbb_ver=2021.1.8.515
14+
tbb_ver=2021.1.9.636
1515
# https://github.com/oneapi-src/oneTBB/releases/download/v2021.1-beta08/oneapi-tbb-2021.1-beta08-win.zip
16-
tbb_ver_win=2021.1.8.514
17-
# https://github.com/intel/llvm/releases/download/2020-WW31/fpgaemu-2020.10.7.0.15_rel.tar.gz
18-
ocl_fpga_emu_ver=2020.10.7.0.15
19-
# https://github.com/intel/llvm/releases/download/2020-WW31/win-fpgaemu-2020.10.7.0.15_rel.zip
20-
ocl_fpga_emu_ver_win=2020.10.7.0.15
21-
fpga_ver=20200701_000002
22-
fpga_ver_win=20200701_000002
16+
tbb_ver_win=2021.1.9.636
17+
# https://github.com/intel/llvm/releases/download/2020-WW36/fpgaemu-2020.11.8.0.27_rel.tar.gz
18+
ocl_fpga_emu_ver=2020.11.8.0.27
19+
# https://github.com/intel/llvm/releases/download/2020-WW36/win-fpgaemu-2020.11.8.0.27_rel.zip
20+
ocl_fpga_emu_ver_win=2020.11.8.0.27
21+
fpga_ver=20200811_000001
22+
fpga_ver_win=20200811_000006
2323

2424
[DRIVER VERSIONS]
25-
cpu_driver_lin=2020.10.7.0.15
26-
cpu_driver_win=2020.10.7.0.15
27-
gpu_driver_lin=20.29.17408
28-
gpu_driver_win=27.20.100.8336
29-
fpga_driver_lin=2020.10.7.0.15
30-
fpga_driver_win=2020.10.7.0.15
25+
cpu_driver_lin=2020.11.8.0.27
26+
cpu_driver_win=2020.11.8.0.27
27+
gpu_driver_lin=20.35.17767
28+
gpu_driver_win=27.20.100.8673
29+
fpga_driver_lin=2020.11.8.0.27
30+
fpga_driver_win=2020.11.8.0.27
3131
# NVidia CUDA driver
3232
# TODO provide URL for CUDA driver
3333
nvidia_gpu_driver_lin=435.21

clang-tools-extra/clang-query/tool/ClangQuery.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -110,31 +110,33 @@ int main(int argc, const char **argv) {
110110
ClangTool Tool(OptionsParser->getCompilations(),
111111
OptionsParser->getSourcePathList());
112112
std::vector<std::unique_ptr<ASTUnit>> ASTs;
113-
int Status = Tool.buildASTs(ASTs);
114113
int ASTStatus = 0;
115-
if (Status == 1) {
116-
// Building ASTs failed.
114+
switch (Tool.buildASTs(ASTs)) {
115+
case 0:
116+
break;
117+
case 1: // Building ASTs failed.
117118
return 1;
118-
} else if (Status == 2) {
119+
case 2:
119120
ASTStatus |= 1;
120121
llvm::errs() << "Failed to build AST for some of the files, "
121122
<< "results may be incomplete."
122123
<< "\n";
123-
} else {
124-
assert(Status == 0 && "Unexpected status returned");
124+
break;
125+
default:
126+
llvm_unreachable("Unexpected status returned");
125127
}
126128

127129
QuerySession QS(ASTs);
128130

129131
if (!Commands.empty()) {
130-
for (auto I = Commands.begin(), E = Commands.end(); I != E; ++I) {
131-
QueryRef Q = QueryParser::parse(*I, QS);
132+
for (auto &Command : Commands) {
133+
QueryRef Q = QueryParser::parse(Command, QS);
132134
if (!Q->run(llvm::outs(), QS))
133135
return 1;
134136
}
135137
} else if (!CommandFiles.empty()) {
136-
for (auto I = CommandFiles.begin(), E = CommandFiles.end(); I != E; ++I) {
137-
if (runCommandsInFile(argv[0], *I, QS))
138+
for (auto &CommandFile : CommandFiles) {
139+
if (runCommandsInFile(argv[0], CommandFile, QS))
138140
return 1;
139141
}
140142
} else {

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

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,18 @@ AST_POLYMORPHIC_MATCHER(
4747
if (PrefixPosition == StringRef::npos)
4848
return false;
4949
Path = Path.drop_front(PrefixPosition + AbslPrefix.size());
50-
static const char *AbseilLibraries[] = {
51-
"algorithm", "base", "container", "debugging", "flags",
52-
"hash", "iterator", "memory", "meta", "numeric",
53-
"random", "strings", "synchronization", "time", "types",
54-
"utility"};
55-
return std::any_of(
56-
std::begin(AbseilLibraries), std::end(AbseilLibraries),
57-
[&](const char *Library) { return Path.startswith(Library); });
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"};
59+
return llvm::any_of(AbseilLibraries, [&](const char *Library) {
60+
return Path.startswith(Library);
61+
});
5862
}
5963

6064
} // namespace ast_matchers

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include "NotNullTerminatedResultCheck.h"
3939
#include "ParentVirtualCallCheck.h"
4040
#include "PosixReturnCheck.h"
41+
#include "RedundantBranchConditionCheck.h"
4142
#include "ReservedIdentifierCheck.h"
4243
#include "SignedCharMisuseCheck.h"
4344
#include "SizeofContainerCheck.h"
@@ -119,6 +120,8 @@ class BugproneModule : public ClangTidyModule {
119120
"bugprone-move-forwarding-reference");
120121
CheckFactories.registerCheck<MultipleStatementMacroCheck>(
121122
"bugprone-multiple-statement-macro");
123+
CheckFactories.registerCheck<RedundantBranchConditionCheck>(
124+
"bugprone-redundant-branch-condition");
122125
CheckFactories.registerCheck<cppcoreguidelines::NarrowingConversionsCheck>(
123126
"bugprone-narrowing-conversions");
124127
CheckFactories.registerCheck<NoEscapeCheck>("bugprone-no-escape");

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ add_clang_library(clangTidyBugproneModule
3333
NotNullTerminatedResultCheck.cpp
3434
ParentVirtualCallCheck.cpp
3535
PosixReturnCheck.cpp
36+
RedundantBranchConditionCheck.cpp
3637
ReservedIdentifierCheck.cpp
3738
SignedCharMisuseCheck.cpp
3839
SizeofContainerCheck.cpp
Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
//===--- RedundantBranchConditionCheck.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 "RedundantBranchConditionCheck.h"
10+
#include "../utils/Aliasing.h"
11+
#include "clang/AST/ASTContext.h"
12+
#include "clang/ASTMatchers/ASTMatchFinder.h"
13+
#include "clang/Analysis/Analyses/ExprMutationAnalyzer.h"
14+
#include "clang/Lex/Lexer.h"
15+
16+
using namespace clang::ast_matchers;
17+
using clang::tidy::utils::hasPtrOrReferenceInFunc;
18+
19+
namespace clang {
20+
namespace tidy {
21+
namespace bugprone {
22+
23+
static const char CondVarStr[] = "cond_var";
24+
static const char OuterIfStr[] = "outer_if";
25+
static const char InnerIfStr[] = "inner_if";
26+
static const char FuncStr[] = "func";
27+
28+
/// Returns whether `Var` is changed in `S` before `NextS`.
29+
static bool isChangedBefore(const Stmt *S, const Stmt *NextS,
30+
const VarDecl *Var, ASTContext *Context) {
31+
ExprMutationAnalyzer MutAn(*S, *Context);
32+
const auto &SM = Context->getSourceManager();
33+
const Stmt *MutS = MutAn.findMutation(Var);
34+
return MutS &&
35+
SM.isBeforeInTranslationUnit(MutS->getEndLoc(), NextS->getBeginLoc());
36+
}
37+
38+
void RedundantBranchConditionCheck::registerMatchers(MatchFinder *Finder) {
39+
const auto ImmutableVar =
40+
varDecl(anyOf(parmVarDecl(), hasLocalStorage()), hasType(isInteger()),
41+
unless(hasType(isVolatileQualified())))
42+
.bind(CondVarStr);
43+
Finder->addMatcher(
44+
ifStmt(
45+
hasCondition(ignoringParenImpCasts(anyOf(
46+
declRefExpr(hasDeclaration(ImmutableVar)),
47+
binaryOperator(hasOperatorName("&&"),
48+
hasEitherOperand(ignoringParenImpCasts(declRefExpr(
49+
hasDeclaration(ImmutableVar)))))))),
50+
hasThen(hasDescendant(
51+
ifStmt(hasCondition(ignoringParenImpCasts(
52+
anyOf(declRefExpr(hasDeclaration(
53+
varDecl(equalsBoundNode(CondVarStr)))),
54+
binaryOperator(
55+
hasAnyOperatorName("&&", "||"),
56+
hasEitherOperand(ignoringParenImpCasts(
57+
declRefExpr(hasDeclaration(varDecl(
58+
equalsBoundNode(CondVarStr)))))))))))
59+
.bind(InnerIfStr))),
60+
forFunction(functionDecl().bind(FuncStr)))
61+
.bind(OuterIfStr),
62+
this);
63+
// FIXME: Handle longer conjunctive and disjunctive clauses.
64+
}
65+
66+
void RedundantBranchConditionCheck::check(const MatchFinder::MatchResult &Result) {
67+
const auto *OuterIf = Result.Nodes.getNodeAs<IfStmt>(OuterIfStr);
68+
const auto *InnerIf = Result.Nodes.getNodeAs<IfStmt>(InnerIfStr);
69+
const auto *CondVar = Result.Nodes.getNodeAs<VarDecl>(CondVarStr);
70+
const auto *Func = Result.Nodes.getNodeAs<FunctionDecl>(FuncStr);
71+
72+
// If the variable has an alias then it can be changed by that alias as well.
73+
// FIXME: could potentially support tracking pointers and references in the
74+
// future to improve catching true positives through aliases.
75+
if (hasPtrOrReferenceInFunc(Func, CondVar))
76+
return;
77+
78+
if (isChangedBefore(OuterIf->getThen(), InnerIf, CondVar, Result.Context))
79+
return;
80+
81+
auto Diag = diag(InnerIf->getBeginLoc(), "redundant condition %0") << CondVar;
82+
83+
// For standalone condition variables and for "or" binary operations we simply
84+
// remove the inner `if`.
85+
const auto *BinOpCond = dyn_cast<BinaryOperator>(InnerIf->getCond());
86+
if (isa<DeclRefExpr>(InnerIf->getCond()->IgnoreParenImpCasts()) ||
87+
(BinOpCond && BinOpCond->getOpcode() == BO_LOr)) {
88+
SourceLocation IfBegin = InnerIf->getBeginLoc();
89+
const Stmt *Body = InnerIf->getThen();
90+
const Expr *OtherSide = nullptr;
91+
if (BinOpCond) {
92+
const auto *LeftDRE =
93+
dyn_cast<DeclRefExpr>(BinOpCond->getLHS()->IgnoreParenImpCasts());
94+
if (LeftDRE && LeftDRE->getDecl() == CondVar)
95+
OtherSide = BinOpCond->getRHS();
96+
else
97+
OtherSide = BinOpCond->getLHS();
98+
}
99+
100+
SourceLocation IfEnd = Body->getBeginLoc().getLocWithOffset(-1);
101+
102+
// For compound statements also remove the left brace.
103+
if (isa<CompoundStmt>(Body))
104+
IfEnd = Body->getBeginLoc();
105+
106+
// If the other side has side effects then keep it.
107+
if (OtherSide && OtherSide->HasSideEffects(*Result.Context)) {
108+
SourceLocation BeforeOtherSide =
109+
OtherSide->getBeginLoc().getLocWithOffset(-1);
110+
SourceLocation AfterOtherSide =
111+
Lexer::findNextToken(OtherSide->getEndLoc(), *Result.SourceManager,
112+
getLangOpts())
113+
->getLocation();
114+
Diag << FixItHint::CreateRemoval(
115+
CharSourceRange::getTokenRange(IfBegin, BeforeOtherSide))
116+
<< FixItHint::CreateInsertion(AfterOtherSide, ";")
117+
<< FixItHint::CreateRemoval(
118+
CharSourceRange::getTokenRange(AfterOtherSide, IfEnd));
119+
} else {
120+
Diag << FixItHint::CreateRemoval(
121+
CharSourceRange::getTokenRange(IfBegin, IfEnd));
122+
}
123+
124+
// For comound statements also remove the right brace at the end.
125+
if (isa<CompoundStmt>(Body))
126+
Diag << FixItHint::CreateRemoval(
127+
CharSourceRange::getTokenRange(Body->getEndLoc(), Body->getEndLoc()));
128+
129+
// For "and" binary operations we remove the "and" operation with the
130+
// condition variable from the inner if.
131+
} else {
132+
const auto *CondOp = cast<BinaryOperator>(InnerIf->getCond());
133+
const auto *LeftDRE =
134+
dyn_cast<DeclRefExpr>(CondOp->getLHS()->IgnoreParenImpCasts());
135+
if (LeftDRE && LeftDRE->getDecl() == CondVar) {
136+
SourceLocation BeforeRHS =
137+
CondOp->getRHS()->getBeginLoc().getLocWithOffset(-1);
138+
Diag << FixItHint::CreateRemoval(CharSourceRange::getTokenRange(
139+
CondOp->getLHS()->getBeginLoc(), BeforeRHS));
140+
} else {
141+
SourceLocation AfterLHS =
142+
Lexer::findNextToken(CondOp->getLHS()->getEndLoc(),
143+
*Result.SourceManager, getLangOpts())
144+
->getLocation();
145+
Diag << FixItHint::CreateRemoval(CharSourceRange::getTokenRange(
146+
AfterLHS, CondOp->getRHS()->getEndLoc()));
147+
}
148+
}
149+
}
150+
151+
} // namespace bugprone
152+
} // namespace tidy
153+
} // namespace clang
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//===--- RedundantBranchConditionCheck.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_BUGPRONE_REDUNDANTBRANCHCONDITIONCHECK_H
10+
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_REDUNDANTBRANCHCONDITIONCHECK_H
11+
12+
#include "../ClangTidyCheck.h"
13+
14+
namespace clang {
15+
namespace tidy {
16+
namespace bugprone {
17+
18+
/// Finds condition variables in nested `if` statements that were also checked
19+
/// in the outer `if` statement and were not changed.
20+
///
21+
/// For the user-facing documentation see:
22+
/// http://clang.llvm.org/extra/clang-tidy/checks/bugprone-redundant-branch-condition.html
23+
class RedundantBranchConditionCheck : public ClangTidyCheck {
24+
public:
25+
RedundantBranchConditionCheck(StringRef Name, ClangTidyContext *Context)
26+
: ClangTidyCheck(Name, Context) {}
27+
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
28+
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
29+
};
30+
31+
} // namespace bugprone
32+
} // namespace tidy
33+
} // namespace clang
34+
35+
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_REDUNDANTBRANCHCONDITIONCHECK_H

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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 3 additions & 0 deletions
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>(

0 commit comments

Comments
 (0)