Skip to content

Commit 185983b

Browse files
committed
LLVM and SPIRV-LLVM-Translator pulldown (WW46-47)
LLVM: llvm/llvm-project@0f652d8f527f SPIRV-LLVM-Translator: KhronosGroup/SPIRV-LLVM-Translator@05e183d
2 parents 2869ca7 + 3c3ca19 commit 185983b

File tree

5,688 files changed

+226266
-93865
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,688 files changed

+226266
-93865
lines changed

clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "clang/Tooling/DiagnosticsYaml.h"
2424
#include "clang/Tooling/ReplacementsYaml.h"
2525
#include "llvm/ADT/ArrayRef.h"
26+
#include "llvm/ADT/Optional.h"
2627
#include "llvm/Support/FileSystem.h"
2728
#include "llvm/Support/MemoryBuffer.h"
2829
#include "llvm/Support/Path.h"
@@ -152,9 +153,13 @@ groupReplacements(const TUReplacements &TUs, const TUDiagnostics &TUDs,
152153
DiagReplacements;
153154

154155
auto AddToGroup = [&](const tooling::Replacement &R,
155-
const tooling::TranslationUnitDiagnostics *SourceTU) {
156+
const tooling::TranslationUnitDiagnostics *SourceTU,
157+
const llvm::Optional<std::string> BuildDir) {
156158
// Use the file manager to deduplicate paths. FileEntries are
157159
// automatically canonicalized.
160+
auto PrevWorkingDir = SM.getFileManager().getFileSystemOpts().WorkingDir;
161+
if (BuildDir)
162+
SM.getFileManager().getFileSystemOpts().WorkingDir = std::move(*BuildDir);
158163
if (auto Entry = SM.getFileManager().getFile(R.getFilePath())) {
159164
if (SourceTU) {
160165
auto &Replaces = DiagReplacements[*Entry];
@@ -170,18 +175,19 @@ groupReplacements(const TUReplacements &TUs, const TUDiagnostics &TUDs,
170175
errs() << "Described file '" << R.getFilePath()
171176
<< "' doesn't exist. Ignoring...\n";
172177
}
178+
SM.getFileManager().getFileSystemOpts().WorkingDir = PrevWorkingDir;
173179
};
174180

175181
for (const auto &TU : TUs)
176182
for (const tooling::Replacement &R : TU.Replacements)
177-
AddToGroup(R, nullptr);
183+
AddToGroup(R, nullptr, {});
178184

179185
for (const auto &TU : TUDs)
180186
for (const auto &D : TU.Diagnostics)
181187
if (const auto *ChoosenFix = tooling::selectFirstFix(D)) {
182188
for (const auto &Fix : *ChoosenFix)
183189
for (const tooling::Replacement &R : Fix.second)
184-
AddToGroup(R, &TU);
190+
AddToGroup(R, &TU, D.BuildDirectory);
185191
}
186192

187193
// Sort replacements per file to keep consistent behavior when

clang-tools-extra/clang-tidy/ClangTidy.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ static CheckersList getAnalyzerCheckersAndPackages(ClangTidyContext &Context,
385385
#endif // CLANG_TIDY_ENABLE_STATIC_ANALYZER
386386

387387
std::unique_ptr<clang::ASTConsumer>
388-
ClangTidyASTConsumerFactory::CreateASTConsumer(
388+
ClangTidyASTConsumerFactory::createASTConsumer(
389389
clang::CompilerInstance &Compiler, StringRef File) {
390390
// FIXME: Move this to a separate method, so that CreateASTConsumer doesn't
391391
// modify Compiler.
@@ -573,7 +573,7 @@ runClangTidy(clang::tidy::ClangTidyContext &Context,
573573
Action(ClangTidyASTConsumerFactory *Factory) : Factory(Factory) {}
574574
std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &Compiler,
575575
StringRef File) override {
576-
return Factory->CreateASTConsumer(Compiler, File);
576+
return Factory->createASTConsumer(Compiler, File);
577577
}
578578

579579
private:

clang-tools-extra/clang-tidy/ClangTidy.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class ClangTidyASTConsumerFactory {
3838

3939
/// Returns an ASTConsumer that runs the specified clang-tidy checks.
4040
std::unique_ptr<clang::ASTConsumer>
41-
CreateASTConsumer(clang::CompilerInstance &Compiler, StringRef File);
41+
createASTConsumer(clang::CompilerInstance &Compiler, StringRef File);
4242

4343
/// Get the list of enabled checks.
4444
std::vector<std::string> getCheckNames();

clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class ClangTidyDiagnosticRenderer : public DiagnosticRenderer {
6666
? tooling::DiagnosticMessage(Message, Loc.getManager(), Loc)
6767
: tooling::DiagnosticMessage(Message);
6868

69-
// Make sure that if a TokenRange is receieved from the check it is unfurled
69+
// Make sure that if a TokenRange is received from the check it is unfurled
7070
// into a real CharRange for the diagnostic printer later.
7171
// Whatever we store here gets decoupled from the current SourceManager, so
7272
// we **have to** know the exact position and length of the highlight.
@@ -376,10 +376,10 @@ static ClangTidyError createNolintError(const ClangTidyContext &Context,
376376
Context.getCurrentBuildDirectory(), false);
377377
StringRef Message =
378378
IsNolintBegin
379-
? "unmatched 'NOLINTBEGIN' comment without a subsequent 'NOLINTEND' "
380-
"comment"
381-
: "unmatched 'NOLINTEND' comment without a previous 'NOLINTBEGIN' "
382-
"comment";
379+
? ("unmatched 'NOLINTBEGIN' comment without a subsequent 'NOLINT"
380+
"END' comment")
381+
: ("unmatched 'NOLINTEND' comment without a previous 'NOLINT"
382+
"BEGIN' comment");
383383
Error.Message = tooling::DiagnosticMessage(Message, SM, Loc);
384384
return Error;
385385
}
@@ -517,16 +517,6 @@ static bool lineIsMarkedWithNOLINTinMacro(
517517
namespace clang {
518518
namespace tidy {
519519

520-
bool shouldSuppressDiagnostic(DiagnosticsEngine::Level DiagLevel,
521-
const Diagnostic &Info, ClangTidyContext &Context,
522-
bool AllowIO) {
523-
SmallVector<ClangTidyError, 1> Unused;
524-
bool ShouldSuppress =
525-
shouldSuppressDiagnostic(DiagLevel, Info, Context, Unused, AllowIO);
526-
assert(Unused.empty());
527-
return ShouldSuppress;
528-
}
529-
530520
bool shouldSuppressDiagnostic(
531521
DiagnosticsEngine::Level DiagLevel, const Diagnostic &Info,
532522
ClangTidyContext &Context,

clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ class CompilerInstance;
2323
class SourceManager;
2424
namespace ast_matchers {
2525
class MatchFinder;
26-
}
26+
} // namespace ast_matchers
2727
namespace tooling {
2828
class CompilationDatabase;
29-
}
29+
} // namespace tooling
3030

3131
namespace tidy {
3232

@@ -45,18 +45,13 @@ struct ClangTidyError : tooling::Diagnostic {
4545
std::vector<std::string> EnabledDiagnosticAliases;
4646
};
4747

48-
/// Contains displayed and ignored diagnostic counters for a ClangTidy
49-
/// run.
48+
/// Contains displayed and ignored diagnostic counters for a ClangTidy run.
5049
struct ClangTidyStats {
51-
ClangTidyStats()
52-
: ErrorsDisplayed(0), ErrorsIgnoredCheckFilter(0), ErrorsIgnoredNOLINT(0),
53-
ErrorsIgnoredNonUserCode(0), ErrorsIgnoredLineFilter(0) {}
54-
55-
unsigned ErrorsDisplayed;
56-
unsigned ErrorsIgnoredCheckFilter;
57-
unsigned ErrorsIgnoredNOLINT;
58-
unsigned ErrorsIgnoredNonUserCode;
59-
unsigned ErrorsIgnoredLineFilter;
50+
unsigned ErrorsDisplayed = 0;
51+
unsigned ErrorsIgnoredCheckFilter = 0;
52+
unsigned ErrorsIgnoredNOLINT = 0;
53+
unsigned ErrorsIgnoredNonUserCode = 0;
54+
unsigned ErrorsIgnoredLineFilter = 0;
6055

6156
unsigned errorsIgnored() const {
6257
return ErrorsIgnoredNOLINT + ErrorsIgnoredCheckFilter +
@@ -228,10 +223,6 @@ class ClangTidyContext {
228223
/// for example, the use of a "NOLINTBEGIN" comment that is not followed by a
229224
/// "NOLINTEND" comment - a diagnostic regarding the improper use is returned
230225
/// via the output argument `SuppressionErrors`.
231-
bool shouldSuppressDiagnostic(DiagnosticsEngine::Level DiagLevel,
232-
const Diagnostic &Info, ClangTidyContext &Context,
233-
bool AllowIO = true);
234-
235226
bool shouldSuppressDiagnostic(
236227
DiagnosticsEngine::Level DiagLevel, const Diagnostic &Info,
237228
ClangTidyContext &Context,

clang-tools-extra/clang-tidy/ClangTidyOptions.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ struct ClangTidyOptions {
108108

109109
std::string Value;
110110
/// Priority stores relative precedence of the value loaded from config
111-
/// files to disambigute local vs global value from different levels.
111+
/// files to disambiguate local vs global value from different levels.
112112
unsigned Priority;
113113
};
114114
typedef std::pair<std::string, std::string> StringPair;
@@ -129,8 +129,8 @@ struct ClangTidyOptions {
129129
/// and using a FileOptionsProvider, it will take a configuration file in the
130130
/// parent directory (if any exists) and apply this config file on top of the
131131
/// parent one. IF true and using a ConfigOptionsProvider, it will apply this
132-
/// config on top of any configuation file it finds in the directory using the
133-
/// same logic as FileOptionsProvider. If false or missing, only this
132+
/// config on top of any configuration file it finds in the directory using
133+
/// the same logic as FileOptionsProvider. If false or missing, only this
134134
/// configuration file will be used.
135135
llvm::Optional<bool> InheritParentConfig;
136136

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "../ClangTidy.h"
1010
#include "../ClangTidyModule.h"
1111
#include "../ClangTidyModuleRegistry.h"
12+
#include "CleanupCtadCheck.h"
1213
#include "DurationAdditionCheck.h"
1314
#include "DurationComparisonCheck.h"
1415
#include "DurationConversionCastCheck.h"
@@ -35,6 +36,7 @@ namespace abseil {
3536
class AbseilModule : public ClangTidyModule {
3637
public:
3738
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
39+
CheckFactories.registerCheck<CleanupCtadCheck>("abseil-cleanup-ctad");
3840
CheckFactories.registerCheck<DurationAdditionCheck>(
3941
"abseil-duration-addition");
4042
CheckFactories.registerCheck<DurationComparisonCheck>(

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ set(LLVM_LINK_COMPONENTS
55

66
add_clang_library(clangTidyAbseilModule
77
AbseilTidyModule.cpp
8+
CleanupCtadCheck.cpp
89
DurationAdditionCheck.cpp
910
DurationComparisonCheck.cpp
1011
DurationConversionCastCheck.cpp
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
//===--- CleanupCtadCheck.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 "CleanupCtadCheck.h"
10+
#include "../utils/TransformerClangTidyCheck.h"
11+
#include "clang/AST/ASTContext.h"
12+
#include "clang/ASTMatchers/ASTMatchFinder.h"
13+
#include "clang/ASTMatchers/ASTMatchers.h"
14+
#include "clang/Tooling/Transformer/RangeSelector.h"
15+
#include "clang/Tooling/Transformer/RewriteRule.h"
16+
#include "clang/Tooling/Transformer/Stencil.h"
17+
#include "llvm/ADT/StringRef.h"
18+
19+
using namespace ::clang::ast_matchers;
20+
using namespace ::clang::transformer;
21+
22+
namespace clang {
23+
namespace tidy {
24+
namespace abseil {
25+
26+
RewriteRule CleanupCtadCheckImpl() {
27+
auto warning_message = cat("prefer absl::Cleanup's class template argument "
28+
"deduction pattern in C++17 and higher");
29+
30+
return makeRule(
31+
declStmt(has(varDecl(
32+
hasType(autoType()), hasTypeLoc(typeLoc().bind("auto_type_loc")),
33+
hasInitializer(traverse(
34+
clang::TK_IgnoreUnlessSpelledInSource,
35+
callExpr(callee(functionDecl(hasName("absl::MakeCleanup"))),
36+
argumentCountIs(1),
37+
hasArgument(0, expr().bind("make_cleanup_argument")))
38+
.bind("make_cleanup_call")))))),
39+
{changeTo(node("auto_type_loc"), cat("absl::Cleanup")),
40+
changeTo(node("make_cleanup_call"), cat(node("make_cleanup_argument")))},
41+
warning_message);
42+
}
43+
44+
CleanupCtadCheck::CleanupCtadCheck(StringRef Name, ClangTidyContext *Context)
45+
: utils::TransformerClangTidyCheck(CleanupCtadCheckImpl(), Name, Context) {}
46+
47+
} // namespace abseil
48+
} // namespace tidy
49+
} // namespace clang
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//===--- CleanupCtadCheck.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_ABSEIL_CLEANUPCTADCHECK_H
10+
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ABSEIL_CLEANUPCTADCHECK_H
11+
12+
#include "../utils/TransformerClangTidyCheck.h"
13+
14+
namespace clang {
15+
namespace tidy {
16+
namespace abseil {
17+
18+
/// Suggests switching the initialization pattern of `absl::Cleanup`
19+
/// instances from the factory function to class template argument
20+
/// deduction (CTAD), in C++17 and higher.
21+
///
22+
/// For the user-facing documentation see:
23+
/// http://clang.llvm.org/extra/clang-tidy/checks/abseil-cleanup-ctad.html
24+
class CleanupCtadCheck : public utils::TransformerClangTidyCheck {
25+
public:
26+
CleanupCtadCheck(StringRef Name, ClangTidyContext *Context);
27+
28+
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
29+
return LangOpts.CPlusPlus17;
30+
}
31+
};
32+
33+
} // namespace abseil
34+
} // namespace tidy
35+
} // namespace clang
36+
37+
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ABSEIL_CLEANUPCTADCHECK_H

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ class DurationDivisionCheck : public ClangTidyCheck {
2626
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
2727
return LangOpts.CPlusPlus;
2828
}
29-
void registerMatchers(ast_matchers::MatchFinder *finder) override;
30-
void check(const ast_matchers::MatchFinder::MatchResult &result) override;
29+
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
30+
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
3131
};
3232

3333
} // namespace abseil

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ void DurationFactoryScaleCheck::check(const MatchFinder::MatchResult &Result) {
145145
return;
146146

147147
// We first handle the cases of literal zero (both float and integer).
148-
if (IsLiteralZero(Result, *Arg)) {
148+
if (isLiteralZero(Result, *Arg)) {
149149
diag(Call->getBeginLoc(),
150150
"use ZeroDuration() for zero-length time intervals")
151151
<< FixItHint::CreateReplacement(Call->getSourceRange(),

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ llvm::StringRef getTimeInverseForScale(DurationScale Scale) {
157157
}
158158

159159
/// Returns `true` if `Node` is a value which evaluates to a literal `0`.
160-
bool IsLiteralZero(const MatchFinder::MatchResult &Result, const Expr &Node) {
160+
bool isLiteralZero(const MatchFinder::MatchResult &Result, const Expr &Node) {
161161
auto ZeroMatcher =
162162
anyOf(integerLiteral(equals(0)), floatLiteral(equals(0.0)));
163163

@@ -276,7 +276,7 @@ std::string rewriteExprFromNumberToDuration(
276276
rewriteInverseDurationCall(Result, Scale, RootNode))
277277
return *MaybeRewrite;
278278

279-
if (IsLiteralZero(Result, RootNode))
279+
if (isLiteralZero(Result, RootNode))
280280
return std::string("absl::ZeroDuration()");
281281

282282
return (llvm::Twine(getDurationFactoryForScale(Scale)) + "(" +
@@ -294,7 +294,7 @@ std::string rewriteExprFromNumberToTime(
294294
rewriteInverseTimeCall(Result, Scale, RootNode))
295295
return *MaybeRewrite;
296296

297-
if (IsLiteralZero(Result, RootNode))
297+
if (isLiteralZero(Result, RootNode))
298298
return std::string("absl::UnixEpoch()");
299299

300300
return (llvm::Twine(getTimeFactoryForScale(Scale)) + "(" +

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ llvm::StringRef getDurationFactoryForScale(DurationScale Scale);
3333

3434
/// Given a 'Scale', return the appropriate factory function call for
3535
/// constructing a `Time` for that scale.
36-
llvm::StringRef getTimeFactoryForScale(DurationScale scale);
36+
llvm::StringRef getTimeFactoryForScale(DurationScale Scale);
3737

3838
// Determine if `Node` represents a literal floating point or integral zero.
39-
bool IsLiteralZero(const ast_matchers::MatchFinder::MatchResult &Result,
39+
bool isLiteralZero(const ast_matchers::MatchFinder::MatchResult &Result,
4040
const Expr &Node);
4141

4242
/// Possibly strip a floating point cast expression.
@@ -77,7 +77,7 @@ const std::pair<llvm::StringRef, llvm::StringRef> &
7777
getDurationInverseForScale(DurationScale Scale);
7878

7979
/// Returns the Time inverse function name for a given `Scale`.
80-
llvm::StringRef getTimeInverseForScale(DurationScale scale);
80+
llvm::StringRef getTimeInverseForScale(DurationScale Scale);
8181

8282
/// Assuming `Node` has type `double` or `int` representing a time interval of
8383
/// `Scale`, return the expression to make it a suitable `Duration`.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ void StringFindStartswithCheck::check(const MatchFinder::MatchResult &Result) {
9797
", " + NeedleExprCode + ")")
9898
.str());
9999

100-
// Create a preprocessor #include FixIt hint (CreateIncludeInsertion checks
100+
// Create a preprocessor #include FixIt hint (createIncludeInsertion checks
101101
// whether this already exists).
102102
Diagnostic << IncludeInserter.createIncludeInsertion(
103103
Source.getFileID(ComparisonExpr->getBeginLoc()),

clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ bool UnrollLoopsCheck::extractValue(int &Value, const BinaryOperator *Op,
240240
else if (RHS->isEvaluatable(*Context))
241241
RHS->EvaluateAsRValue(Result, *Context);
242242
else
243-
return false; // Cannot evalue either side.
243+
return false; // Cannot evaluate either side.
244244
if (!Result.Val.isInt())
245245
return false; // Cannot check number of iterations, return false to be
246246
// safe.

0 commit comments

Comments
 (0)