Skip to content

Commit 50e4056

Browse files
author
Valery N Dmitriev
committed
Merge from 'master' to 'sycl-web' (#13)
CONFLICT (content): Merge conflict in clang/lib/Driver/Driver.cpp
2 parents cbb2e5a + 77df5a8 commit 50e4056

32 files changed

+1247
-817
lines changed

clang-tools-extra/clang-tidy/llvm/TwineLocalCheck.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ namespace llvm_check {
1919

2020
void TwineLocalCheck::registerMatchers(MatchFinder *Finder) {
2121
auto TwineType =
22-
qualType(hasDeclaration(recordDecl(hasName("::llvm::Twine"))));
23-
Finder->addMatcher(varDecl(hasType(TwineType)).bind("variable"), this);
22+
qualType(hasDeclaration(cxxRecordDecl(hasName("::llvm::Twine"))));
23+
Finder->addMatcher(
24+
varDecl(unless(parmVarDecl()), hasType(TwineType)).bind("variable"),
25+
this);
2426
}
2527

2628
void TwineLocalCheck::check(const MatchFinder::MatchResult &Result) {

clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -156,14 +156,17 @@ void RenamerClangTidyCheck::addUsage(
156156
// is already in there
157157
RenamerClangTidyCheck::NamingCheckFailure &Failure =
158158
NamingCheckFailures[Decl];
159-
if (!Failure.RawUsageLocs.insert(FixLocation.getRawEncoding()).second)
160-
return;
161159

162160
if (!Failure.ShouldFix())
163161
return;
164162

163+
if (SourceMgr && SourceMgr->isWrittenInScratchSpace(FixLocation))
164+
Failure.FixStatus = RenamerClangTidyCheck::ShouldFixStatus::InsideMacro;
165+
165166
if (!utils::rangeCanBeFixed(Range, SourceMgr))
166167
Failure.FixStatus = RenamerClangTidyCheck::ShouldFixStatus::InsideMacro;
168+
169+
Failure.RawUsageLocs.insert(FixLocation.getRawEncoding());
167170
}
168171

169172
void RenamerClangTidyCheck::addUsage(const NamedDecl *Decl, SourceRange Range,
@@ -248,13 +251,15 @@ void RenamerClangTidyCheck::check(const MatchFinder::MatchResult &Result) {
248251
if (const auto *Decl =
249252
Result.Nodes.getNodeAs<CXXConstructorDecl>("classRef")) {
250253

251-
addUsage(Decl->getParent(), Decl->getNameInfo().getSourceRange());
254+
addUsage(Decl->getParent(), Decl->getNameInfo().getSourceRange(),
255+
Result.SourceManager);
252256

253257
for (const auto *Init : Decl->inits()) {
254258
if (!Init->isWritten() || Init->isInClassMemberInitializer())
255259
continue;
256260
if (const FieldDecl *FD = Init->getAnyMember())
257-
addUsage(FD, SourceRange(Init->getMemberLocation()));
261+
addUsage(FD, SourceRange(Init->getMemberLocation()),
262+
Result.SourceManager);
258263
// Note: delegating constructors and base class initializers are handled
259264
// via the "typeLoc" matcher.
260265
}
@@ -271,7 +276,7 @@ void RenamerClangTidyCheck::check(const MatchFinder::MatchResult &Result) {
271276
// we want instead to replace the next token, that will be the identifier.
272277
Range.setBegin(CharSourceRange::getTokenRange(Range).getEnd());
273278

274-
addUsage(Decl->getParent(), Range);
279+
addUsage(Decl->getParent(), Range, Result.SourceManager);
275280
return;
276281
}
277282

@@ -289,7 +294,7 @@ void RenamerClangTidyCheck::check(const MatchFinder::MatchResult &Result) {
289294
// further TypeLocs handled below
290295

291296
if (Decl) {
292-
addUsage(Decl, Loc->getSourceRange());
297+
addUsage(Decl, Loc->getSourceRange(), Result.SourceManager);
293298
return;
294299
}
295300

@@ -300,15 +305,15 @@ void RenamerClangTidyCheck::check(const MatchFinder::MatchResult &Result) {
300305
SourceRange Range(Ref.getTemplateNameLoc(), Ref.getTemplateNameLoc());
301306
if (const auto *ClassDecl = dyn_cast<TemplateDecl>(Decl)) {
302307
if (const NamedDecl *TemplDecl = ClassDecl->getTemplatedDecl())
303-
addUsage(TemplDecl, Range);
308+
addUsage(TemplDecl, Range, Result.SourceManager);
304309
return;
305310
}
306311
}
307312

308313
if (const auto &Ref =
309314
Loc->getAs<DependentTemplateSpecializationTypeLoc>()) {
310315
if (const TagDecl *Decl = Ref.getTypePtr()->getAsTagDecl())
311-
addUsage(Decl, Loc->getSourceRange());
316+
addUsage(Decl, Loc->getSourceRange(), Result.SourceManager);
312317
return;
313318
}
314319
}
@@ -317,15 +322,16 @@ void RenamerClangTidyCheck::check(const MatchFinder::MatchResult &Result) {
317322
Result.Nodes.getNodeAs<NestedNameSpecifierLoc>("nestedNameLoc")) {
318323
if (const NestedNameSpecifier *Spec = Loc->getNestedNameSpecifier()) {
319324
if (const NamespaceDecl *Decl = Spec->getAsNamespace()) {
320-
addUsage(Decl, Loc->getLocalSourceRange());
325+
addUsage(Decl, Loc->getLocalSourceRange(), Result.SourceManager);
321326
return;
322327
}
323328
}
324329
}
325330

326331
if (const auto *Decl = Result.Nodes.getNodeAs<UsingDecl>("using")) {
327332
for (const auto *Shadow : Decl->shadows())
328-
addUsage(Shadow->getTargetDecl(), Decl->getNameInfo().getSourceRange());
333+
addUsage(Shadow->getTargetDecl(), Decl->getNameInfo().getSourceRange(),
334+
Result.SourceManager);
329335
return;
330336
}
331337

@@ -371,34 +377,37 @@ void RenamerClangTidyCheck::check(const MatchFinder::MatchResult &Result) {
371377
// Fix using namespace declarations.
372378
if (const auto *UsingNS = dyn_cast<UsingDirectiveDecl>(Decl))
373379
addUsage(UsingNS->getNominatedNamespaceAsWritten(),
374-
UsingNS->getIdentLocation());
380+
UsingNS->getIdentLocation(), Result.SourceManager);
375381

376382
if (!Decl->getIdentifier() || Decl->getName().empty() || Decl->isImplicit())
377383
return;
378384

379385
const auto *Canonical = cast<NamedDecl>(Decl->getCanonicalDecl());
380386
if (Canonical != Decl) {
381-
addUsage(Canonical, Decl->getLocation());
387+
addUsage(Canonical, Decl->getLocation(), Result.SourceManager);
382388
return;
383389
}
384390

385391
// Fix type aliases in value declarations.
386392
if (const auto *Value = Result.Nodes.getNodeAs<ValueDecl>("decl")) {
387393
if (const Type *TypePtr = Value->getType().getTypePtrOrNull()) {
388394
if (const auto *Typedef = TypePtr->getAs<TypedefType>())
389-
addUsage(Typedef->getDecl(), Value->getSourceRange());
395+
addUsage(Typedef->getDecl(), Value->getSourceRange(),
396+
Result.SourceManager);
390397
}
391398
}
392399

393400
// Fix type aliases in function declarations.
394401
if (const auto *Value = Result.Nodes.getNodeAs<FunctionDecl>("decl")) {
395402
if (const auto *Typedef =
396403
Value->getReturnType().getTypePtr()->getAs<TypedefType>())
397-
addUsage(Typedef->getDecl(), Value->getSourceRange());
404+
addUsage(Typedef->getDecl(), Value->getSourceRange(),
405+
Result.SourceManager);
398406
for (const ParmVarDecl *Param : Value->parameters()) {
399407
if (const TypedefType *Typedef =
400408
Param->getType().getTypePtr()->getAs<TypedefType>())
401-
addUsage(Typedef->getDecl(), Value->getSourceRange());
409+
addUsage(Typedef->getDecl(), Value->getSourceRange(),
410+
Result.SourceManager);
402411
}
403412
}
404413

clang-tools-extra/test/clang-tidy/checkers/llvm-twine-local.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class Twine {
1313
using namespace llvm;
1414

1515
void foo(const Twine &x);
16+
void bar(Twine x);
1617

1718
static Twine Moo = Twine("bark") + "bah";
1819
// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: twine variables are prone to use-after-free bugs

clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,3 +562,19 @@ void ReferenceBadNamedFunction() {
562562
}
563563

564564
} // namespace redecls
565+
566+
namespace scratchspace {
567+
#define DUP(Tok) Tok
568+
#define M1(Tok) DUP(badName##Tok())
569+
570+
// We don't want a warning here as the call to this in Foo is in a scratch
571+
// buffer so its fix-it wouldn't be applied, resulting in invalid code.
572+
void badNameWarn();
573+
574+
void Foo() {
575+
M1(Warn);
576+
}
577+
578+
#undef M1
579+
#undef DUP
580+
} // namespace scratchspace

clang/include/clang/Basic/arm_neon.td

Lines changed: 20 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -190,28 +190,20 @@ def OP_SCALAR_QRDMLAH_LN : Op<(call "vqadd", $p0, (call "vqrdmulh", $p1,
190190
def OP_SCALAR_QRDMLSH_LN : Op<(call "vqsub", $p0, (call "vqrdmulh", $p1,
191191
(call "vget_lane", $p2, $p3)))>;
192192

193-
multiclass ScalarGetSetLaneOpsF16<string scalarTy,
194-
string vectorTy4, string vectorTy8> {
195-
def _GET_LN : Op<(bitcast scalarTy,
196-
(call "vget_lane",
197-
(bitcast "int16x4_t", $p0), $p1))>;
198-
def _GET_LNQ : Op<(bitcast scalarTy,
199-
(call "vget_lane",
200-
(bitcast "int16x8_t", $p0), $p1))>;
201-
def _SET_LN : Op<(bitcast vectorTy4,
202-
(call "vset_lane",
203-
(bitcast "int16_t", $p0),
204-
(bitcast "int16x4_t", $p1), $p2))>;
205-
def _SET_LNQ : Op<(bitcast vectorTy8,
206-
(call "vset_lane",
207-
(bitcast "int16_t", $p0),
208-
(bitcast "int16x8_t", $p1), $p2))>;
209-
}
210-
211-
defm OP_SCALAR_HALF: ScalarGetSetLaneOpsF16<"float16_t",
212-
"float16x4_t", "float16x8_t">;
213-
defm OP_SCALAR_BF16: ScalarGetSetLaneOpsF16<"bfloat16_t",
214-
"bfloat16x4_t", "bfloat16x8_t">;
193+
def OP_SCALAR_HALF_GET_LN : Op<(bitcast "float16_t",
194+
(call "vget_lane",
195+
(bitcast "int16x4_t", $p0), $p1))>;
196+
def OP_SCALAR_HALF_GET_LNQ : Op<(bitcast "float16_t",
197+
(call "vget_lane",
198+
(bitcast "int16x8_t", $p0), $p1))>;
199+
def OP_SCALAR_HALF_SET_LN : Op<(bitcast "float16x4_t",
200+
(call "vset_lane",
201+
(bitcast "int16_t", $p0),
202+
(bitcast "int16x4_t", $p1), $p2))>;
203+
def OP_SCALAR_HALF_SET_LNQ : Op<(bitcast "float16x8_t",
204+
(call "vset_lane",
205+
(bitcast "int16_t", $p0),
206+
(bitcast "int16x8_t", $p1), $p2))>;
215207

216208
def OP_DOT_LN
217209
: Op<(call "vdot", $p0, $p1,
@@ -1918,10 +1910,12 @@ let ArchGuard = "defined(__ARM_FEATURE_BF16_VECTOR_ARITHMETIC)" in {
19181910
def VGET_HIGH_BF : NoTestOpInst<"vget_high", ".Q", "b", OP_HI>;
19191911
def VGET_LOW_BF : NoTestOpInst<"vget_low", ".Q", "b", OP_LO>;
19201912

1921-
def VGET_LANE_BF : IOpInst<"vget_lane", "1.I", "b", OP_SCALAR_BF16_GET_LN>;
1922-
def VSET_LANE_BF : IOpInst<"vset_lane", ".1.I", "b", OP_SCALAR_BF16_SET_LN>;
1923-
def VGET_LANEQ_BF : IOpInst<"vget_lane", "1.I", "Qb", OP_SCALAR_BF16_GET_LNQ>;
1924-
def VSET_LANEQ_BF : IOpInst<"vset_lane", ".1.I", "Qb", OP_SCALAR_BF16_SET_LNQ>;
1913+
def VGET_LANE_BF : IInst<"vget_lane", "1.I", "bQb">;
1914+
def VSET_LANE_BF : IInst<"vset_lane", ".1.I", "bQb">;
1915+
def SCALAR_VDUP_LANE_BF : IInst<"vdup_lane", "1.I", "Sb">;
1916+
def SCALAR_VDUP_LANEQ_BF : IInst<"vdup_laneq", "1QI", "Sb"> {
1917+
let isLaneQ = 1;
1918+
}
19251919

19261920
def VLD1_BF : WInst<"vld1", ".(c*!)", "bQb">;
19271921
def VLD2_BF : WInst<"vld2", "2(c*!)", "bQb">;
@@ -1957,18 +1951,6 @@ let ArchGuard = "defined(__ARM_FEATURE_BF16_VECTOR_ARITHMETIC)" in {
19571951

19581952
}
19591953

1960-
let ArchGuard = "defined(__ARM_FEATURE_BF16_VECTOR_ARITHMETIC) && !defined(__aarch64__)" in {
1961-
def SCALAR_VDUP_LANE_BF_A32 : IOpInst<"vduph_lane", "1.I", "b", OP_SCALAR_BF16_GET_LN>;
1962-
def SCALAR_VDUP_LANEQ_BF_A32 : IOpInst<"vduph_laneq", "1.I", "Hb", OP_SCALAR_BF16_GET_LNQ>;
1963-
}
1964-
1965-
let ArchGuard = "defined(__ARM_FEATURE_BF16_VECTOR_ARITHMETIC) && defined(__aarch64__)" in {
1966-
def SCALAR_VDUP_LANE_BF_A64 : IInst<"vdup_lane", "1.I", "Sb">;
1967-
def SCALAR_VDUP_LANEQ_BF_A64 : IInst<"vdup_laneq", "1QI", "Sb"> {
1968-
let isLaneQ = 1;
1969-
}
1970-
}
1971-
19721954
let ArchGuard = "defined(__ARM_FEATURE_BF16) && !defined(__aarch64__)" in {
19731955
let BigEndianSafe = 1 in {
19741956
defm VREINTERPRET_BF : REINTERPRET_CROSS_TYPES<

clang/lib/Basic/Targets/X86.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1518,14 +1518,14 @@ bool X86TargetInfo::hasFeature(StringRef Feature) const {
15181518
// X86TargetInfo::hasFeature for a somewhat comprehensive list).
15191519
bool X86TargetInfo::validateCpuSupports(StringRef FeatureStr) const {
15201520
return llvm::StringSwitch<bool>(FeatureStr)
1521-
#define X86_FEATURE_COMPAT(VAL, ENUM, STR) .Case(STR, true)
1521+
#define X86_FEATURE_COMPAT(ENUM, STR) .Case(STR, true)
15221522
#include "llvm/Support/X86TargetParser.def"
15231523
.Default(false);
15241524
}
15251525

15261526
static llvm::X86::ProcessorFeatures getFeature(StringRef Name) {
15271527
return llvm::StringSwitch<llvm::X86::ProcessorFeatures>(Name)
1528-
#define X86_FEATURE_COMPAT(VAL, ENUM, STR) .Case(STR, llvm::X86::ENUM)
1528+
#define X86_FEATURE_COMPAT(ENUM, STR) .Case(STR, llvm::X86::ENUM)
15291529
#include "llvm/Support/X86TargetParser.def"
15301530
;
15311531
// Note, this function should only be used after ensuring the value is

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6422,21 +6422,27 @@ static bool HasExtraNeonArgument(unsigned BuiltinID) {
64226422
default: break;
64236423
case NEON::BI__builtin_neon_vget_lane_i8:
64246424
case NEON::BI__builtin_neon_vget_lane_i16:
6425+
case NEON::BI__builtin_neon_vget_lane_bf16:
64256426
case NEON::BI__builtin_neon_vget_lane_i32:
64266427
case NEON::BI__builtin_neon_vget_lane_i64:
64276428
case NEON::BI__builtin_neon_vget_lane_f32:
64286429
case NEON::BI__builtin_neon_vgetq_lane_i8:
64296430
case NEON::BI__builtin_neon_vgetq_lane_i16:
6431+
case NEON::BI__builtin_neon_vgetq_lane_bf16:
64306432
case NEON::BI__builtin_neon_vgetq_lane_i32:
64316433
case NEON::BI__builtin_neon_vgetq_lane_i64:
64326434
case NEON::BI__builtin_neon_vgetq_lane_f32:
6435+
case NEON::BI__builtin_neon_vduph_lane_bf16:
6436+
case NEON::BI__builtin_neon_vduph_laneq_bf16:
64336437
case NEON::BI__builtin_neon_vset_lane_i8:
64346438
case NEON::BI__builtin_neon_vset_lane_i16:
6439+
case NEON::BI__builtin_neon_vset_lane_bf16:
64356440
case NEON::BI__builtin_neon_vset_lane_i32:
64366441
case NEON::BI__builtin_neon_vset_lane_i64:
64376442
case NEON::BI__builtin_neon_vset_lane_f32:
64386443
case NEON::BI__builtin_neon_vsetq_lane_i8:
64396444
case NEON::BI__builtin_neon_vsetq_lane_i16:
6445+
case NEON::BI__builtin_neon_vsetq_lane_bf16:
64406446
case NEON::BI__builtin_neon_vsetq_lane_i32:
64416447
case NEON::BI__builtin_neon_vsetq_lane_i64:
64426448
case NEON::BI__builtin_neon_vsetq_lane_f32:
@@ -6882,12 +6888,16 @@ Value *CodeGenFunction::EmitARMBuiltinExpr(unsigned BuiltinID,
68826888
case NEON::BI__builtin_neon_vget_lane_i16:
68836889
case NEON::BI__builtin_neon_vget_lane_i32:
68846890
case NEON::BI__builtin_neon_vget_lane_i64:
6891+
case NEON::BI__builtin_neon_vget_lane_bf16:
68856892
case NEON::BI__builtin_neon_vget_lane_f32:
68866893
case NEON::BI__builtin_neon_vgetq_lane_i8:
68876894
case NEON::BI__builtin_neon_vgetq_lane_i16:
68886895
case NEON::BI__builtin_neon_vgetq_lane_i32:
68896896
case NEON::BI__builtin_neon_vgetq_lane_i64:
6897+
case NEON::BI__builtin_neon_vgetq_lane_bf16:
68906898
case NEON::BI__builtin_neon_vgetq_lane_f32:
6899+
case NEON::BI__builtin_neon_vduph_lane_bf16:
6900+
case NEON::BI__builtin_neon_vduph_laneq_bf16:
68916901
return Builder.CreateExtractElement(Ops[0], Ops[1], "vget_lane");
68926902

68936903
case NEON::BI__builtin_neon_vrndns_f32: {
@@ -6900,11 +6910,13 @@ Value *CodeGenFunction::EmitARMBuiltinExpr(unsigned BuiltinID,
69006910
case NEON::BI__builtin_neon_vset_lane_i16:
69016911
case NEON::BI__builtin_neon_vset_lane_i32:
69026912
case NEON::BI__builtin_neon_vset_lane_i64:
6913+
case NEON::BI__builtin_neon_vset_lane_bf16:
69036914
case NEON::BI__builtin_neon_vset_lane_f32:
69046915
case NEON::BI__builtin_neon_vsetq_lane_i8:
69056916
case NEON::BI__builtin_neon_vsetq_lane_i16:
69066917
case NEON::BI__builtin_neon_vsetq_lane_i32:
69076918
case NEON::BI__builtin_neon_vsetq_lane_i64:
6919+
case NEON::BI__builtin_neon_vsetq_lane_bf16:
69086920
case NEON::BI__builtin_neon_vsetq_lane_f32:
69096921
return Builder.CreateInsertElement(Ops[1], Ops[0], Ops[2], "vset_lane");
69106922

@@ -9315,11 +9327,13 @@ Value *CodeGenFunction::EmitAArch64BuiltinExpr(unsigned BuiltinID,
93159327
case NEON::BI__builtin_neon_vset_lane_i16:
93169328
case NEON::BI__builtin_neon_vset_lane_i32:
93179329
case NEON::BI__builtin_neon_vset_lane_i64:
9330+
case NEON::BI__builtin_neon_vset_lane_bf16:
93189331
case NEON::BI__builtin_neon_vset_lane_f32:
93199332
case NEON::BI__builtin_neon_vsetq_lane_i8:
93209333
case NEON::BI__builtin_neon_vsetq_lane_i16:
93219334
case NEON::BI__builtin_neon_vsetq_lane_i32:
93229335
case NEON::BI__builtin_neon_vsetq_lane_i64:
9336+
case NEON::BI__builtin_neon_vsetq_lane_bf16:
93239337
case NEON::BI__builtin_neon_vsetq_lane_f32:
93249338
Ops.push_back(EmitScalarExpr(E->getArg(2)));
93259339
return Builder.CreateInsertElement(Ops[1], Ops[0], Ops[2], "vset_lane");
@@ -9598,11 +9612,13 @@ Value *CodeGenFunction::EmitAArch64BuiltinExpr(unsigned BuiltinID,
95989612
: Intrinsic::aarch64_neon_sqsub;
95999613
return EmitNeonCall(CGM.getIntrinsic(AccInt, Int64Ty), Ops, "vqdmlXl");
96009614
}
9615+
case NEON::BI__builtin_neon_vget_lane_bf16:
96019616
case NEON::BI__builtin_neon_vduph_lane_bf16:
96029617
case NEON::BI__builtin_neon_vduph_lane_f16: {
96039618
return Builder.CreateExtractElement(Ops[0], EmitScalarExpr(E->getArg(1)),
96049619
"vget_lane");
96059620
}
9621+
case NEON::BI__builtin_neon_vgetq_lane_bf16:
96069622
case NEON::BI__builtin_neon_vduph_laneq_bf16:
96079623
case NEON::BI__builtin_neon_vduph_laneq_f16: {
96089624
return Builder.CreateExtractElement(Ops[0], EmitScalarExpr(E->getArg(1)),
@@ -11652,7 +11668,7 @@ CodeGenFunction::GetX86CpuSupportsMask(ArrayRef<StringRef> FeatureStrs) {
1165211668
for (const StringRef &FeatureStr : FeatureStrs) {
1165311669
unsigned Feature =
1165411670
StringSwitch<unsigned>(FeatureStr)
11655-
#define X86_FEATURE_COMPAT(VAL, ENUM, STR) .Case(STR, VAL)
11671+
#define X86_FEATURE_COMPAT(ENUM, STR) .Case(STR, llvm::X86::ENUM)
1165611672
#include "llvm/Support/X86TargetParser.def"
1165711673
;
1165811674
FeaturesMask |= (1ULL << Feature);

0 commit comments

Comments
 (0)