Skip to content

Commit e1e3308

Browse files
committed
Merge from 'main' to 'sycl-web' (#3)
CONFLICT (content): Merge conflict in clang/lib/Frontend/InitPreprocessor.cpp CONFLICT (content): Merge conflict in clang/lib/Frontend/CompilerInvocation.cpp CONFLICT (content): Merge conflict in clang/include/clang/Basic/LangOptions.h CONFLICT (content): Merge conflict in clang/include/clang/Basic/LangOptions.def
2 parents 2430ad5 + 5a85526 commit e1e3308

File tree

1,817 files changed

+199963
-16517
lines changed

Some content is hidden

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

1,817 files changed

+199963
-16517
lines changed

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

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ class ErrorReporter {
101101
public:
102102
ErrorReporter(ClangTidyContext &Context, bool ApplyFixes,
103103
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> BaseFS)
104-
: Files(FileSystemOptions(), BaseFS), DiagOpts(new DiagnosticOptions()),
104+
: Files(FileSystemOptions(), std::move(BaseFS)),
105+
DiagOpts(new DiagnosticOptions()),
105106
DiagPrinter(new TextDiagnosticPrinter(llvm::outs(), &*DiagOpts)),
106107
Diags(IntrusiveRefCntPtr<DiagnosticIDs>(new DiagnosticIDs), &*DiagOpts,
107108
DiagPrinter),
@@ -319,7 +320,7 @@ class ClangTidyASTConsumer : public MultiplexConsumer {
319320
ClangTidyASTConsumerFactory::ClangTidyASTConsumerFactory(
320321
ClangTidyContext &Context,
321322
IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> OverlayFS)
322-
: Context(Context), OverlayFS(OverlayFS),
323+
: Context(Context), OverlayFS(std::move(OverlayFS)),
323324
CheckFactories(new ClangTidyCheckFactories) {
324325
for (ClangTidyModuleRegistry::entry E : ClangTidyModuleRegistry::entries()) {
325326
std::unique_ptr<ClangTidyModule> Module = E.instantiate();
@@ -328,15 +329,16 @@ ClangTidyASTConsumerFactory::ClangTidyASTConsumerFactory(
328329
}
329330

330331
#if CLANG_TIDY_ENABLE_STATIC_ANALYZER
331-
static void setStaticAnalyzerCheckerOpts(const ClangTidyOptions &Opts,
332-
AnalyzerOptionsRef AnalyzerOptions) {
332+
static void
333+
setStaticAnalyzerCheckerOpts(const ClangTidyOptions &Opts,
334+
clang::AnalyzerOptions &AnalyzerOptions) {
333335
StringRef AnalyzerPrefix(AnalyzerCheckNamePrefix);
334336
for (const auto &Opt : Opts.CheckOptions) {
335337
StringRef OptName(Opt.getKey());
336338
if (!OptName.consume_front(AnalyzerPrefix))
337339
continue;
338340
// Analyzer options are always local options so we can ignore priority.
339-
AnalyzerOptions->Config[OptName] = Opt.getValue().Value;
341+
AnalyzerOptions.Config[OptName] = Opt.getValue().Value;
340342
}
341343
}
342344

@@ -432,7 +434,7 @@ ClangTidyASTConsumerFactory::CreateASTConsumer(
432434
AnalyzerOptions->CheckersAndPackages = getAnalyzerCheckersAndPackages(
433435
Context, Context.canEnableAnalyzerAlphaCheckers());
434436
if (!AnalyzerOptions->CheckersAndPackages.empty()) {
435-
setStaticAnalyzerCheckerOpts(Context.getOptions(), AnalyzerOptions);
437+
setStaticAnalyzerCheckerOpts(Context.getOptions(), *AnalyzerOptions);
436438
AnalyzerOptions->AnalysisStoreOpt = RegionStoreModel;
437439
AnalyzerOptions->AnalysisDiagOpt = PD_NONE;
438440
AnalyzerOptions->AnalyzeNestedBlocks = true;
@@ -539,7 +541,7 @@ runClangTidy(clang::tidy::ClangTidyContext &Context,
539541
public:
540542
ActionFactory(ClangTidyContext &Context,
541543
IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> BaseFS)
542-
: ConsumerFactory(Context, BaseFS) {}
544+
: ConsumerFactory(Context, std::move(BaseFS)) {}
543545
std::unique_ptr<FrontendAction> create() override {
544546
return std::make_unique<Action>(&ConsumerFactory);
545547
}
@@ -570,7 +572,7 @@ runClangTidy(clang::tidy::ClangTidyContext &Context,
570572
ClangTidyASTConsumerFactory ConsumerFactory;
571573
};
572574

573-
ActionFactory Factory(Context, BaseFS);
575+
ActionFactory Factory(Context, std::move(BaseFS));
574576
Tool.run(&Factory);
575577
return DiagConsumer.take();
576578
}
@@ -579,7 +581,7 @@ void handleErrors(llvm::ArrayRef<ClangTidyError> Errors,
579581
ClangTidyContext &Context, bool Fix,
580582
unsigned &WarningsAsErrorsCount,
581583
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> BaseFS) {
582-
ErrorReporter Reporter(Context, Fix, BaseFS);
584+
ErrorReporter Reporter(Context, Fix, std::move(BaseFS));
583585
llvm::vfs::FileSystem &FileSystem =
584586
Reporter.getSourceManager().getFileManager().getVirtualFileSystem();
585587
auto InitialWorkingDir = FileSystem.getCurrentWorkingDirectory();

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "llvm/Support/Debug.h"
1414
#include "llvm/Support/Errc.h"
1515
#include "llvm/Support/FileSystem.h"
16+
#include "llvm/Support/MemoryBufferRef.h"
1617
#include "llvm/Support/Path.h"
1718
#include "llvm/Support/YAMLTraits.h"
1819
#include "llvm/Support/raw_ostream.h"
@@ -390,6 +391,22 @@ parseConfiguration(llvm::MemoryBufferRef Config) {
390391
return Options;
391392
}
392393

394+
static void diagHandlerImpl(const llvm::SMDiagnostic &Diag, void *Ctx) {
395+
(*reinterpret_cast<DiagCallback *>(Ctx))(Diag);
396+
};
397+
398+
llvm::ErrorOr<ClangTidyOptions>
399+
parseConfigurationWithDiags(llvm::MemoryBufferRef Config,
400+
DiagCallback Handler) {
401+
llvm::yaml::Input Input(Config, nullptr, Handler ? diagHandlerImpl : nullptr,
402+
&Handler);
403+
ClangTidyOptions Options;
404+
Input >> Options;
405+
if (Input.error())
406+
return Input.error();
407+
return Options;
408+
}
409+
393410
std::string configurationAsText(const ClangTidyOptions &Options) {
394411
std::string Text;
395412
llvm::raw_string_ostream Stream(Text);

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "llvm/ADT/StringMap.h"
1515
#include "llvm/ADT/StringRef.h"
1616
#include "llvm/Support/ErrorOr.h"
17+
#include "llvm/Support/MemoryBufferRef.h"
1718
#include "llvm/Support/VirtualFileSystem.h"
1819
#include <functional>
1920
#include <string>
@@ -311,6 +312,11 @@ std::error_code parseLineFilter(llvm::StringRef LineFilter,
311312
llvm::ErrorOr<ClangTidyOptions>
312313
parseConfiguration(llvm::MemoryBufferRef Config);
313314

315+
using DiagCallback = llvm::function_ref<void(const llvm::SMDiagnostic &)>;
316+
317+
llvm::ErrorOr<ClangTidyOptions>
318+
parseConfigurationWithDiags(llvm::MemoryBufferRef Config, DiagCallback Handler);
319+
314320
/// Serializes configuration to a YAML-encoded string.
315321
std::string configurationAsText(const ClangTidyOptions &Options);
316322

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "../ClangTidyModule.h"
1111
#include "../ClangTidyModuleRegistry.h"
1212
#include "KernelNameRestrictionCheck.h"
13+
#include "SingleWorkItemBarrierCheck.h"
1314
#include "StructPackAlignCheck.h"
1415

1516
using namespace clang::ast_matchers;
@@ -23,6 +24,8 @@ class AlteraModule : public ClangTidyModule {
2324
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
2425
CheckFactories.registerCheck<KernelNameRestrictionCheck>(
2526
"altera-kernel-name-restriction");
27+
CheckFactories.registerCheck<SingleWorkItemBarrierCheck>(
28+
"altera-single-work-item-barrier");
2629
CheckFactories.registerCheck<StructPackAlignCheck>(
2730
"altera-struct-pack-align");
2831
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ set(LLVM_LINK_COMPONENTS
66
add_clang_library(clangTidyAlteraModule
77
AlteraTidyModule.cpp
88
KernelNameRestrictionCheck.cpp
9+
SingleWorkItemBarrierCheck.cpp
910
StructPackAlignCheck.cpp
1011

1112
LINK_LIBS
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
//===--- SingleWorkItemBarrierCheck.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 "SingleWorkItemBarrierCheck.h"
10+
#include "clang/AST/ASTContext.h"
11+
#include "clang/ASTMatchers/ASTMatchFinder.h"
12+
13+
using namespace clang::ast_matchers;
14+
15+
namespace clang {
16+
namespace tidy {
17+
namespace altera {
18+
19+
void SingleWorkItemBarrierCheck::registerMatchers(MatchFinder *Finder) {
20+
// Find any function that calls barrier but does not call an ID function.
21+
// hasAttr(attr::Kind::OpenCLKernel) restricts it to only kernel functions.
22+
// FIXME: Have it accept all functions but check for a parameter that gets an
23+
// ID from one of the four ID functions.
24+
Finder->addMatcher(
25+
// Find function declarations...
26+
functionDecl(
27+
allOf(
28+
// That are OpenCL kernels...
29+
hasAttr(attr::Kind::OpenCLKernel),
30+
// And call a barrier function (either 1.x or 2.x version)...
31+
forEachDescendant(callExpr(callee(functionDecl(hasAnyName(
32+
"barrier", "work_group_barrier"))))
33+
.bind("barrier")),
34+
// But do not call an ID function.
35+
unless(hasDescendant(callExpr(callee(functionDecl(
36+
hasAnyName("get_global_id", "get_local_id", "get_group_id",
37+
"get_local_linear_id"))))))))
38+
.bind("function"),
39+
this);
40+
}
41+
42+
void SingleWorkItemBarrierCheck::check(const MatchFinder::MatchResult &Result) {
43+
const auto *MatchedDecl = Result.Nodes.getNodeAs<FunctionDecl>("function");
44+
const auto *MatchedBarrier = Result.Nodes.getNodeAs<CallExpr>("barrier");
45+
if (AOCVersion < 1701) {
46+
// get_group_id and get_local_linear_id were added at/after v17.01
47+
diag(MatchedDecl->getLocation(),
48+
"kernel function %0 does not call 'get_global_id' or 'get_local_id' "
49+
"and will be treated as a single work-item")
50+
<< MatchedDecl;
51+
diag(MatchedBarrier->getBeginLoc(),
52+
"barrier call is in a single work-item and may error out",
53+
DiagnosticIDs::Note);
54+
} else {
55+
// If reqd_work_group_size is anything other than (1,1,1), it will be
56+
// interpreted as an NDRange in AOC version >= 17.1.
57+
bool IsNDRange = false;
58+
if (MatchedDecl->hasAttr<ReqdWorkGroupSizeAttr>()) {
59+
const auto *Attribute = MatchedDecl->getAttr<ReqdWorkGroupSizeAttr>();
60+
if (Attribute->getXDim() > 1 || Attribute->getYDim() > 1 ||
61+
Attribute->getZDim() > 1)
62+
IsNDRange = true;
63+
}
64+
if (IsNDRange) // No warning if kernel is treated as an NDRange.
65+
return;
66+
diag(MatchedDecl->getLocation(),
67+
"kernel function %0 does not call an ID function and may be a viable "
68+
"single work-item, but will be forced to execute as an NDRange")
69+
<< MatchedDecl;
70+
diag(MatchedBarrier->getBeginLoc(),
71+
"barrier call will force NDRange execution; if single work-item "
72+
"semantics are desired a mem_fence may be more efficient",
73+
DiagnosticIDs::Note);
74+
}
75+
}
76+
77+
void SingleWorkItemBarrierCheck::storeOptions(
78+
ClangTidyOptions::OptionMap &Opts) {
79+
Options.store(Opts, "AOCVersion", AOCVersion);
80+
}
81+
82+
} // namespace altera
83+
} // namespace tidy
84+
} // namespace clang
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//===--- SingleWorkItemBarrierCheck.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_ALTERA_SINGLE_WORK_ITEM_BARRIER_H
10+
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ALTERA_SINGLE_WORK_ITEM_BARRIER_H
11+
12+
#include "../ClangTidyCheck.h"
13+
14+
namespace clang {
15+
namespace tidy {
16+
namespace altera {
17+
18+
/// Detects OpenCL kernel functions that call a barrier but do not call an
19+
/// ID-function function. These functions will be treated as single work-item
20+
/// kernels, which may be inefficient or cause an error.
21+
///
22+
/// For the user-facing documentation see:
23+
/// http://clang.llvm.org/extra/clang-tidy/checks/opencl-single-work-item-barrier.html
24+
class SingleWorkItemBarrierCheck : public ClangTidyCheck {
25+
const unsigned AOCVersion;
26+
27+
public:
28+
SingleWorkItemBarrierCheck(StringRef Name, ClangTidyContext *Context)
29+
: ClangTidyCheck(Name, Context),
30+
AOCVersion(Options.get("AOCVersion", 1600U)) {}
31+
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
32+
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
33+
void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
34+
};
35+
36+
} // namespace altera
37+
} // namespace tidy
38+
} // namespace clang
39+
40+
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ALTERA_SINGLE_WORK_ITEM_BARRIER_H

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,10 @@ void ProTypeMemberInitCheck::check(const MatchFinder::MatchResult &Result) {
297297
// Skip declarations delayed by late template parsing without a body.
298298
if (!Ctor->getBody())
299299
return;
300+
// Skip out-of-band explicitly defaulted special member functions
301+
// (except the default constructor).
302+
if (Ctor->isExplicitlyDefaulted() && !Ctor->isDefaultConstructor())
303+
return;
300304
checkMissingMemberInitializer(*Result.Context, *Ctor->getParent(), Ctor);
301305
checkMissingBaseClassInitializer(*Result.Context, *Ctor->getParent(), Ctor);
302306
} else if (const auto *Record =

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ void MakeSmartPtrCheck::checkConstruct(SourceManager &SM, ASTContext *Ctx,
176176
}
177177

178178
// Find the location of the template's left angle.
179-
size_t LAngle = ExprStr.find("<");
179+
size_t LAngle = ExprStr.find('<');
180180
SourceLocation ConstructCallEnd;
181181
if (LAngle == StringRef::npos) {
182182
// If the template argument is missing (because it is part of the alias)

clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ int clangTidyMain(int argc, const char **argv) {
393393
getVfsFromFile(VfsOverlay, BaseFS);
394394
if (!VfsFromFile)
395395
return 1;
396-
BaseFS->pushOverlay(VfsFromFile);
396+
BaseFS->pushOverlay(std::move(VfsFromFile));
397397
}
398398

399399
auto OwningOptionsProvider = createOptionsProvider(BaseFS);

clang-tools-extra/clangd/AST.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,8 +350,7 @@ class DeducedTypeVisitor : public RecursiveASTVisitor<DeducedTypeVisitor> {
350350
return true;
351351

352352
if (auto *AT = D->getType()->getContainedAutoType()) {
353-
if (!AT->getDeducedType().isNull())
354-
DeducedType = AT->getDeducedType();
353+
DeducedType = AT->desugar();
355354
}
356355
return true;
357356
}

clang-tools-extra/clangd/AST.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ QualType declaredType(const TypeDecl *D);
109109

110110
/// Retrieves the deduced type at a given location (auto, decltype).
111111
/// It will return the underlying type.
112+
/// If the type is an undeduced auto, returns the type itself.
112113
llvm::Optional<QualType> getDeducedType(ASTContext &, SourceLocation Loc);
113114

114115
/// Gets the nested name specifier necessary for spelling \p ND in \p

clang-tools-extra/clangd/ClangdLSPServer.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -496,8 +496,10 @@ void ClangdLSPServer::onInitialize(const InitializeParams &Params,
496496
if (const auto &Dir = Params.initializationOptions.compilationDatabasePath)
497497
Opts.CompileCommandsDir = Dir;
498498
if (Opts.UseDirBasedCDB) {
499-
BaseCDB = std::make_unique<DirectoryBasedGlobalCompilationDatabase>(
500-
Opts.CompileCommandsDir);
499+
DirectoryBasedGlobalCompilationDatabase::Options CDBOpts(TFS);
500+
CDBOpts.CompileCommandsDir = Opts.CompileCommandsDir;
501+
BaseCDB =
502+
std::make_unique<DirectoryBasedGlobalCompilationDatabase>(CDBOpts);
501503
BaseCDB = getQueryDriverDatabase(llvm::makeArrayRef(Opts.QueryDriverGlobs),
502504
std::move(BaseCDB));
503505
}
@@ -704,6 +706,10 @@ void ClangdLSPServer::onFileEvent(const DidChangeWatchedFilesParams &Params) {
704706
// - this is useful e.g. when switching git branches, but we're likely to see
705707
// fresh headers but still have the old-branch main-file content
706708
Server->onFileEvent(Params);
709+
// FIXME: observe config files, immediately expire time-based caches, reparse:
710+
// - compile_commands.json and compile_flags.txt
711+
// - .clang_format and .clang-tidy
712+
// - .clangd and clangd/config.yaml
707713
}
708714

709715
void ClangdLSPServer::onCommand(const ExecuteCommandParams &Params,

clang-tools-extra/clangd/DumpAST.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ class DumpVisitor : public RecursiveASTVisitor<DumpVisitor> {
143143
TEMPLATE_ARGUMENT_KIND(Declaration);
144144
TEMPLATE_ARGUMENT_KIND(Template);
145145
TEMPLATE_ARGUMENT_KIND(TemplateExpansion);
146+
TEMPLATE_ARGUMENT_KIND(UncommonValue);
146147
#undef TEMPLATE_ARGUMENT_KIND
147148
}
148149
llvm_unreachable("Unhandled ArgKind enum");

clang-tools-extra/clangd/FindTarget.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,6 +1069,7 @@ class ExplicitReferenceCollector
10691069
case TemplateArgument::Pack:
10701070
case TemplateArgument::Type:
10711071
case TemplateArgument::Expression:
1072+
case TemplateArgument::UncommonValue:
10721073
break; // Handled by VisitType and VisitExpression.
10731074
};
10741075
return RecursiveASTVisitor::TraverseTemplateArgumentLoc(A);

0 commit comments

Comments
 (0)