Skip to content

Commit 1a5165e

Browse files
authored
LLVM and LLVM-SPIRV-Translator pulldown
LLVM: 145dcef LLVM-SPIRV-Translator: KhronosGroup/SPIRV-LLVM-Translator@10cdc73
2 parents abe533c + 6b757e5 commit 1a5165e

File tree

2,907 files changed

+85917
-25731
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,907 files changed

+85917
-25731
lines changed

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

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,14 @@ namespace abseil {
2323
// `FactoryName`, return `None`.
2424
static llvm::Optional<DurationScale>
2525
getScaleForFactory(llvm::StringRef FactoryName) {
26-
static const std::unordered_map<std::string, DurationScale> ScaleMap(
27-
{{"Nanoseconds", DurationScale::Nanoseconds},
28-
{"Microseconds", DurationScale::Microseconds},
29-
{"Milliseconds", DurationScale::Milliseconds},
30-
{"Seconds", DurationScale::Seconds},
31-
{"Minutes", DurationScale::Minutes},
32-
{"Hours", DurationScale::Hours}});
33-
34-
auto ScaleIter = ScaleMap.find(std::string(FactoryName));
35-
if (ScaleIter == ScaleMap.end())
36-
return llvm::None;
37-
38-
return ScaleIter->second;
26+
return llvm::StringSwitch<llvm::Optional<DurationScale>>(FactoryName)
27+
.Case("Nanoseconds", DurationScale::Nanoseconds)
28+
.Case("Microseconds", DurationScale::Microseconds)
29+
.Case("Milliseconds", DurationScale::Milliseconds)
30+
.Case("Seconds", DurationScale::Seconds)
31+
.Case("Minutes", DurationScale::Minutes)
32+
.Case("Hours", DurationScale::Hours)
33+
.Default(llvm::None);
3934
}
4035

4136
// Given either an integer or float literal, return its value.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ void ProTypeMemberInitCheck::checkMissingMemberInitializer(
456456
// Don't suggest fixes for bitfields because in-class initialization is not
457457
// possible until C++2a.
458458
if (F->getType()->isEnumeralType() ||
459-
(!getLangOpts().CPlusPlus2a && F->isBitField()))
459+
(!getLangOpts().CPlusPlus20 && F->isBitField()))
460460
return;
461461
if (!F->getParent()->isUnion() || UnionsSeen.insert(F->getParent()).second)
462462
FieldsToFix.insert(F);

clang-tools-extra/clang-tidy/modernize/DeprecatedIosBaseAliasesCheck.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,13 @@ static constexpr std::array<StringRef, 5> DeprecatedTypes = {
2121
"::std::ios_base::seek_dir", "::std::ios_base::streamoff",
2222
"::std::ios_base::streampos"};
2323

24-
static const llvm::StringMap<StringRef> ReplacementTypes = {
25-
{"io_state", "iostate"},
26-
{"open_mode", "openmode"},
27-
{"seek_dir", "seekdir"}};
24+
static llvm::Optional<const char *> getReplacementType(StringRef Type) {
25+
return llvm::StringSwitch<llvm::Optional<const char *>>(Type)
26+
.Case("io_state", "iostate")
27+
.Case("open_mode", "openmode")
28+
.Case("seek_dir", "seekdir")
29+
.Default(llvm::None);
30+
}
2831

2932
void DeprecatedIosBaseAliasesCheck::registerMatchers(MatchFinder *Finder) {
3033
auto IoStateDecl = typedefDecl(hasAnyName(DeprecatedTypes)).bind("TypeDecl");
@@ -40,23 +43,23 @@ void DeprecatedIosBaseAliasesCheck::check(
4043

4144
const auto *Typedef = Result.Nodes.getNodeAs<TypedefDecl>("TypeDecl");
4245
StringRef TypeName = Typedef->getName();
43-
bool HasReplacement = ReplacementTypes.count(TypeName);
46+
auto Replacement = getReplacementType(TypeName);
4447

4548
const auto *TL = Result.Nodes.getNodeAs<TypeLoc>("TypeLoc");
4649
SourceLocation IoStateLoc = TL->getBeginLoc();
4750

4851
// Do not generate fixits for matches depending on template arguments and
4952
// macro expansions.
50-
bool Fix = HasReplacement && !TL->getType()->isDependentType();
53+
bool Fix = Replacement && !TL->getType()->isDependentType();
5154
if (IoStateLoc.isMacroID()) {
5255
IoStateLoc = SM.getSpellingLoc(IoStateLoc);
5356
Fix = false;
5457
}
5558

5659
SourceLocation EndLoc = IoStateLoc.getLocWithOffset(TypeName.size() - 1);
5760

58-
if (HasReplacement) {
59-
auto FixName = ReplacementTypes.lookup(TypeName);
61+
if (Replacement) {
62+
auto FixName = *Replacement;
6063
auto Builder = diag(IoStateLoc, "'std::ios_base::%0' is deprecated; use "
6164
"'std::ios_base::%1' instead")
6265
<< TypeName << FixName;

clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -525,13 +525,11 @@ void LoopConvertCheck::doConversion(
525525
const ValueDecl *MaybeContainer, const UsageResult &Usages,
526526
const DeclStmt *AliasDecl, bool AliasUseRequired, bool AliasFromForInit,
527527
const ForStmt *Loop, RangeDescriptor Descriptor) {
528-
auto Diag = diag(Loop->getForLoc(), "use range-based for loop instead");
529-
530528
std::string VarName;
531529
bool VarNameFromAlias = (Usages.size() == 1) && AliasDecl;
532530
bool AliasVarIsRef = false;
533531
bool CanCopy = true;
534-
532+
std::vector<FixItHint> FixIts;
535533
if (VarNameFromAlias) {
536534
const auto *AliasVar = cast<VarDecl>(AliasDecl->getSingleDecl());
537535
VarName = AliasVar->getName().str();
@@ -563,8 +561,8 @@ void LoopConvertCheck::doConversion(
563561
getAliasRange(Context->getSourceManager(), ReplaceRange);
564562
}
565563

566-
Diag << FixItHint::CreateReplacement(
567-
CharSourceRange::getTokenRange(ReplaceRange), ReplacementText);
564+
FixIts.push_back(FixItHint::CreateReplacement(
565+
CharSourceRange::getTokenRange(ReplaceRange), ReplacementText));
568566
// No further replacements are made to the loop, since the iterator or index
569567
// was used exactly once - in the initialization of AliasVar.
570568
} else {
@@ -609,8 +607,8 @@ void LoopConvertCheck::doConversion(
609607
Usage.Kind == Usage::UK_CaptureByCopy ? "&" + VarName : VarName;
610608
}
611609
TUInfo->getReplacedVars().insert(std::make_pair(Loop, IndexVar));
612-
Diag << FixItHint::CreateReplacement(
613-
CharSourceRange::getTokenRange(Range), ReplaceText);
610+
FixIts.push_back(FixItHint::CreateReplacement(
611+
CharSourceRange::getTokenRange(Range), ReplaceText));
614612
}
615613
}
616614

@@ -648,8 +646,9 @@ void LoopConvertCheck::doConversion(
648646
std::string Range = ("(" + TypeString + " " + VarName + " : " +
649647
MaybeDereference + Descriptor.ContainerString + ")")
650648
.str();
651-
Diag << FixItHint::CreateReplacement(
652-
CharSourceRange::getTokenRange(ParenRange), Range);
649+
FixIts.push_back(FixItHint::CreateReplacement(
650+
CharSourceRange::getTokenRange(ParenRange), Range));
651+
diag(Loop->getForLoc(), "use range-based for loop instead") << FixIts;
653652
TUInfo->getGeneratedDecls().insert(make_pair(Loop, VarName));
654653
}
655654

clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ void UseDefaultMemberInitCheck::registerMatchers(MatchFinder *Finder) {
217217
isDefaultConstructor(), unless(isInstantiated()),
218218
forEachConstructorInitializer(
219219
cxxCtorInitializer(
220-
forField(unless(anyOf(getLangOpts().CPlusPlus2a
220+
forField(unless(anyOf(getLangOpts().CPlusPlus20
221221
? unless(anything())
222222
: isBitField(),
223223
hasInClassInitializer(anything()),

clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ void UseUsingCheck::check(const MatchFinder::MatchResult &Result) {
5858
printPolicy.SuppressScope = true;
5959
printPolicy.ConstantArraySizeAsWritten = true;
6060
printPolicy.UseVoidForZeroParams = false;
61+
printPolicy.PrintInjectedClassNameWithArguments = false;
6162

6263
std::string Type = MatchedDecl->getUnderlyingType().getAsString(printPolicy);
6364
std::string Name = MatchedDecl->getNameAsString();

clang-tools-extra/clang-tidy/portability/SIMDIntrinsicsCheck.cpp

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,15 @@ static StringRef TrySuggestPPC(StringRef Name) {
4343
if (!Name.consume_front("vec_"))
4444
return {};
4545

46-
static const llvm::StringMap<StringRef> Mapping{
47-
// [simd.alg]
48-
{"max", "$std::max"},
49-
{"min", "$std::min"},
50-
51-
// [simd.binary]
52-
{"add", "operator+ on $simd objects"},
53-
{"sub", "operator- on $simd objects"},
54-
{"mul", "operator* on $simd objects"},
55-
};
56-
57-
auto It = Mapping.find(Name);
58-
if (It != Mapping.end())
59-
return It->second;
60-
return {};
46+
return llvm::StringSwitch<StringRef>(Name)
47+
// [simd.alg]
48+
.Case("max", "$std::max")
49+
.Case("min", "$std::min")
50+
// [simd.binary]
51+
.Case("add", "operator+ on $simd objects")
52+
.Case("sub", "operator- on $simd objects")
53+
.Case("mul", "operator* on $simd objects")
54+
.Default({});
6155
}
6256

6357
static StringRef TrySuggestX86(StringRef Name) {
@@ -96,7 +90,7 @@ void SIMDIntrinsicsCheck::registerMatchers(MatchFinder *Finder) {
9690
// If Std is not specified, infer it from the language options.
9791
// libcxx implementation backports it to C++11 std::experimental::simd.
9892
if (Std.empty())
99-
Std = getLangOpts().CPlusPlus2a ? "std" : "std::experimental";
93+
Std = getLangOpts().CPlusPlus20 ? "std" : "std::experimental";
10094

10195
Finder->addMatcher(callExpr(callee(functionDecl(
10296
matchesName("^::(_mm_|_mm256_|_mm512_|vec_)"),

clang-tools-extra/clang-tidy/tool/run-clang-tidy.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,12 @@ def make_absolute(f, directory):
7878

7979

8080
def get_tidy_invocation(f, clang_tidy_binary, checks, tmpdir, build_path,
81-
header_filter, extra_arg, extra_arg_before, quiet,
82-
config):
81+
header_filter, allow_enabling_alpha_checkers,
82+
extra_arg, extra_arg_before, quiet, config):
8383
"""Gets a command line for clang-tidy."""
8484
start = [clang_tidy_binary]
85+
if allow_enabling_alpha_checkers is not None:
86+
start.append('-allow-enabling-analyzer-alpha-checkers')
8587
if header_filter is not None:
8688
start.append('-header-filter=' + header_filter)
8789
if checks:
@@ -159,6 +161,7 @@ def run_tidy(args, tmpdir, build_path, queue, lock, failed_files):
159161
name = queue.get()
160162
invocation = get_tidy_invocation(name, args.clang_tidy_binary, args.checks,
161163
tmpdir, build_path, args.header_filter,
164+
args.allow_enabling_alpha_checkers,
162165
args.extra_arg, args.extra_arg_before,
163166
args.quiet, args.config)
164167

@@ -179,6 +182,9 @@ def main():
179182
'in a compilation database. Requires '
180183
'clang-tidy and clang-apply-replacements in '
181184
'$PATH.')
185+
parser.add_argument('-allow-enabling-alpha-checkers',
186+
action='store_true', help='allow alpha checkers from '
187+
'clang-analyzer.')
182188
parser.add_argument('-clang-tidy-binary', metavar='PATH',
183189
default='clang-tidy',
184190
help='path to clang-tidy binary')
@@ -238,6 +244,8 @@ def main():
238244

239245
try:
240246
invocation = [args.clang_tidy_binary, '-list-checks']
247+
if args.allow_enabling_alpha_checkers:
248+
invocation.append('-allow-enabling-analyzer-alpha-checkers')
241249
invocation.append('-p=' + build_path)
242250
if args.checks:
243251
invocation.append('-checks=' + args.checks)

clang-tools-extra/clangd/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
140140
endif()
141141
add_subdirectory(tool)
142142
add_subdirectory(indexer)
143-
add_subdirectory(index/dex/dexp)
144143

145144
if (LLVM_INCLUDE_BENCHMARKS)
146145
add_subdirectory(benchmarks)
@@ -160,5 +159,6 @@ set(GRPC_INSTALL_PATH "" CACHE PATH "Path to gRPC library manual installation.")
160159

161160
if (CLANGD_ENABLE_REMOTE)
162161
include(FindGRPC)
163-
add_subdirectory(index/remote)
164162
endif()
163+
add_subdirectory(index/remote)
164+
add_subdirectory(index/dex/dexp)

clang-tools-extra/clangd/ClangdServer.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -280,11 +280,8 @@ void ClangdServer::signatureHelp(PathRef File, Position Pos,
280280
Pos, FS, Index));
281281
};
282282

283-
// Unlike code completion, we wait for an up-to-date preamble here.
284-
// Signature help is often triggered after code completion. If the code
285-
// completion inserted a header to make the symbol available, then using
286-
// the old preamble would yield useless results.
287-
WorkScheduler.runWithPreamble("SignatureHelp", File, TUScheduler::Consistent,
283+
// Unlike code completion, we wait for a preamble here.
284+
WorkScheduler.runWithPreamble("SignatureHelp", File, TUScheduler::Stale,
288285
std::move(Action));
289286
}
290287

0 commit comments

Comments
 (0)