Skip to content

Commit cb28f0f

Browse files
committed
Merge remote-tracking branch 'upstream/release/12.x' into rustc/12.0-2021-02-03
2 parents efa7d85 + 76d5d54 commit cb28f0f

File tree

289 files changed

+8524
-7705
lines changed

Some content is hidden

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

289 files changed

+8524
-7705
lines changed

.github/workflows/clang-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
uses: llvm/actions/install-ninja@main
3636
- uses: actions/checkout@v1
3737
with:
38-
fetch-depth: 1
38+
fetch-depth: 250
3939
- name: Test clang
4040
uses: llvm/actions/build-test-llvm-project@main
4141
with:

.github/workflows/libclang-abi-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
- name: Checkout source
2929
uses: actions/checkout@v1
3030
with:
31-
fetch-depth: 1
31+
fetch-depth: 250
3232

3333
- name: Get LLVM version
3434
id: version

.github/workflows/libclc-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
uses: llvm/actions/install-ninja@main
3939
- uses: actions/checkout@v1
4040
with:
41-
fetch-depth: 1
41+
fetch-depth: 250
4242
- name: Build clang
4343
uses: llvm/actions/build-test-llvm-project@main
4444
with:

.github/workflows/lld-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
uses: llvm/actions/install-ninja@main
3636
- uses: actions/checkout@v1
3737
with:
38-
fetch-depth: 1
38+
fetch-depth: 250
3939
- name: Test lld
4040
uses: llvm/actions/build-test-llvm-project@main
4141
with:

.github/workflows/lldb-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
uses: llvm/actions/install-ninja@main
4141
- uses: actions/checkout@v1
4242
with:
43-
fetch-depth: 1
43+
fetch-depth: 250
4444
- name: Build lldb
4545
uses: llvm/actions/build-test-llvm-project@main
4646
with:

.github/workflows/llvm-tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
uses: llvm/actions/install-ninja@main
3434
- uses: actions/checkout@v1
3535
with:
36-
fetch-depth: 1
36+
fetch-depth: 250
3737
- name: Test llvm
3838
uses: llvm/actions/build-test-llvm-project@main
3939
with:
@@ -52,7 +52,7 @@ jobs:
5252
- name: Checkout source
5353
uses: actions/checkout@v1
5454
with:
55-
fetch-depth: 1
55+
fetch-depth: 250
5656

5757
- name: Get LLVM version
5858
id: version

clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,10 @@ static bool isParamInMainLikeFunction(const ParmVarDecl &ParmDecl,
352352
return false;
353353
if (FDecl->getAccess() != AS_public && FDecl->getAccess() != AS_none)
354354
return false;
355+
// If the function doesn't have a name thats an identifier, can occur of the
356+
// function is an operator overload, bail out early.
357+
if (!FDecl->getDeclName().isIdentifier())
358+
return false;
355359
enum MainType { None, Main, WMain };
356360
auto IsCharPtrPtr = [](QualType QType) -> MainType {
357361
if (QType.isNull())

clang-tools-extra/clangd/GlobalCompilationDatabase.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include <atomic>
3535
#include <chrono>
3636
#include <condition_variable>
37+
#include <mutex>
3738
#include <string>
3839
#include <tuple>
3940
#include <vector>
@@ -567,7 +568,10 @@ class DirectoryBasedGlobalCompilationDatabase::BroadcastThread {
567568
}
568569

569570
~BroadcastThread() {
570-
ShouldStop.store(true, std::memory_order_release);
571+
{
572+
std::lock_guard<std::mutex> Lock(Mu);
573+
ShouldStop.store(true, std::memory_order_release);
574+
}
571575
CV.notify_all();
572576
Thread.join();
573577
}

clang-tools-extra/clangd/Protocol.cpp

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,21 @@
2727

2828
namespace clang {
2929
namespace clangd {
30+
namespace {
31+
32+
// Helper that doesn't treat `null` and absent fields as failures.
33+
template <typename T>
34+
bool mapOptOrNull(const llvm::json::Value &Params, llvm::StringLiteral Prop,
35+
T &Out, llvm::json::Path P) {
36+
auto *O = Params.getAsObject();
37+
assert(O);
38+
auto *V = O->get(Prop);
39+
// Field is missing or null.
40+
if (!V || V->getAsNull().hasValue())
41+
return true;
42+
return fromJSON(*V, Out, P.field(Prop));
43+
}
44+
} // namespace
3045

3146
char LSPError::ID;
3247

@@ -490,7 +505,7 @@ bool fromJSON(const llvm::json::Value &Params, DidChangeTextDocumentParams &R,
490505
return O && O.map("textDocument", R.textDocument) &&
491506
O.map("contentChanges", R.contentChanges) &&
492507
O.map("wantDiagnostics", R.wantDiagnostics) &&
493-
O.mapOptional("forceRebuild", R.forceRebuild);
508+
mapOptOrNull(Params, "forceRebuild", R.forceRebuild, P);
494509
}
495510

496511
bool fromJSON(const llvm::json::Value &E, FileChangeType &Out,
@@ -580,10 +595,10 @@ bool fromJSON(const llvm::json::Value &Params, Diagnostic &R,
580595
llvm::json::Path P) {
581596
llvm::json::ObjectMapper O(Params, P);
582597
return O && O.map("range", R.range) && O.map("message", R.message) &&
583-
O.mapOptional("severity", R.severity) &&
584-
O.mapOptional("category", R.category) &&
585-
O.mapOptional("code", R.code) && O.mapOptional("source", R.source);
586-
return true;
598+
mapOptOrNull(Params, "severity", R.severity, P) &&
599+
mapOptOrNull(Params, "category", R.category, P) &&
600+
mapOptOrNull(Params, "code", R.code, P) &&
601+
mapOptOrNull(Params, "source", R.source, P);
587602
}
588603

589604
llvm::json::Value toJSON(const PublishDiagnosticsParams &PDP) {
@@ -818,7 +833,7 @@ bool fromJSON(const llvm::json::Value &Params, CompletionContext &R,
818833
llvm::json::ObjectMapper O(Params, P);
819834
int TriggerKind;
820835
if (!O || !O.map("triggerKind", TriggerKind) ||
821-
!O.mapOptional("triggerCharacter", R.triggerCharacter))
836+
!mapOptOrNull(Params, "triggerCharacter", R.triggerCharacter, P))
822837
return false;
823838
R.triggerKind = static_cast<CompletionTriggerKind>(TriggerKind);
824839
return true;
@@ -1121,8 +1136,8 @@ bool fromJSON(const llvm::json::Value &Params, ConfigurationSettings &S,
11211136
llvm::json::ObjectMapper O(Params, P);
11221137
if (!O)
11231138
return true; // 'any' type in LSP.
1124-
return O.mapOptional("compilationDatabaseChanges",
1125-
S.compilationDatabaseChanges);
1139+
return mapOptOrNull(Params, "compilationDatabaseChanges",
1140+
S.compilationDatabaseChanges, P);
11261141
}
11271142

11281143
bool fromJSON(const llvm::json::Value &Params, InitializationOptions &Opts,
@@ -1133,8 +1148,8 @@ bool fromJSON(const llvm::json::Value &Params, InitializationOptions &Opts,
11331148

11341149
return fromJSON(Params, Opts.ConfigSettings, P) &&
11351150
O.map("compilationDatabasePath", Opts.compilationDatabasePath) &&
1136-
O.mapOptional("fallbackFlags", Opts.fallbackFlags) &&
1137-
O.mapOptional("clangdFileStatus", Opts.FileStatus);
1151+
mapOptOrNull(Params, "fallbackFlags", Opts.fallbackFlags, P) &&
1152+
mapOptOrNull(Params, "clangdFileStatus", Opts.FileStatus, P);
11381153
}
11391154

11401155
bool fromJSON(const llvm::json::Value &E, TypeHierarchyDirection &Out,
@@ -1190,10 +1205,11 @@ bool fromJSON(const llvm::json::Value &Params, TypeHierarchyItem &I,
11901205
return O && O.map("name", I.name) && O.map("kind", I.kind) &&
11911206
O.map("uri", I.uri) && O.map("range", I.range) &&
11921207
O.map("selectionRange", I.selectionRange) &&
1193-
O.mapOptional("detail", I.detail) &&
1194-
O.mapOptional("deprecated", I.deprecated) &&
1195-
O.mapOptional("parents", I.parents) &&
1196-
O.mapOptional("children", I.children) && O.mapOptional("data", I.data);
1208+
mapOptOrNull(Params, "detail", I.detail, P) &&
1209+
mapOptOrNull(Params, "deprecated", I.deprecated, P) &&
1210+
mapOptOrNull(Params, "parents", I.parents, P) &&
1211+
mapOptOrNull(Params, "children", I.children, P) &&
1212+
mapOptOrNull(Params, "data", I.data, P);
11971213
}
11981214

11991215
bool fromJSON(const llvm::json::Value &Params,
@@ -1238,7 +1254,7 @@ bool fromJSON(const llvm::json::Value &Params, CallHierarchyItem &I,
12381254
return O && O.map("name", I.name) && O.map("kind", I.kind) &&
12391255
O.map("uri", I.uri) && O.map("range", I.range) &&
12401256
O.map("selectionRange", I.selectionRange) &&
1241-
O.mapOptional("data", I.data);
1257+
mapOptOrNull(Params, "data", I.data, P);
12421258
}
12431259

12441260
bool fromJSON(const llvm::json::Value &Params,

clang-tools-extra/clangd/TidyProvider.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class DotClangTidyTree {
106106
llvm::SmallVector<DotClangTidyCache *> Caches;
107107
{
108108
std::lock_guard<std::mutex> Lock(Mu);
109-
for (auto I = path::begin(Parent), E = path::end(Parent); I != E; ++I) {
109+
for (auto I = path::rbegin(Parent), E = path::rend(Parent); I != E; ++I) {
110110
assert(I->end() >= Parent.begin() && I->end() <= Parent.end() &&
111111
"Canonical path components should be substrings");
112112
llvm::StringRef Ancestor(Parent.begin(), I->end() - Parent.begin());

clang-tools-extra/clangd/unittests/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ add_unittest(ClangdUnitTests ClangdTests
9393
TestIndex.cpp
9494
TestTU.cpp
9595
TestWorkspace.cpp
96+
TidyProviderTests.cpp
9697
TypeHierarchyTests.cpp
9798
URITests.cpp
9899
XRefsTests.cpp
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
//===-- TidyProviderTests.cpp - Clang tidy configuration provider tests ---===//
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 "TestFS.h"
10+
#include "TidyProvider.h"
11+
#include "gtest/gtest.h"
12+
13+
namespace clang {
14+
namespace clangd {
15+
16+
namespace {
17+
18+
TEST(TidyProvider, NestedDirectories) {
19+
MockFS FS;
20+
FS.Files[testPath(".clang-tidy")] = R"yaml(
21+
Checks: 'llvm-*'
22+
CheckOptions:
23+
- key: TestKey
24+
value: 1
25+
)yaml";
26+
FS.Files[testPath("sub1/.clang-tidy")] = R"yaml(
27+
Checks: 'misc-*'
28+
CheckOptions:
29+
- key: TestKey
30+
value: 2
31+
)yaml";
32+
FS.Files[testPath("sub1/sub2/.clang-tidy")] = R"yaml(
33+
Checks: 'bugprone-*'
34+
CheckOptions:
35+
- key: TestKey
36+
value: 3
37+
InheritParentConfig: true
38+
)yaml";
39+
40+
TidyProvider Provider = provideClangTidyFiles(FS);
41+
42+
auto BaseOptions = getTidyOptionsForFile(Provider, testPath("File.cpp"));
43+
ASSERT_TRUE(BaseOptions.Checks.hasValue());
44+
EXPECT_EQ(*BaseOptions.Checks, "llvm-*");
45+
EXPECT_EQ(BaseOptions.CheckOptions.lookup("TestKey").Value, "1");
46+
47+
auto Sub1Options = getTidyOptionsForFile(Provider, testPath("sub1/File.cpp"));
48+
ASSERT_TRUE(Sub1Options.Checks.hasValue());
49+
EXPECT_EQ(*Sub1Options.Checks, "misc-*");
50+
EXPECT_EQ(Sub1Options.CheckOptions.lookup("TestKey").Value, "2");
51+
52+
auto Sub2Options =
53+
getTidyOptionsForFile(Provider, testPath("sub1/sub2/File.cpp"));
54+
ASSERT_TRUE(Sub2Options.Checks.hasValue());
55+
EXPECT_EQ(*Sub2Options.Checks, "misc-*,bugprone-*");
56+
EXPECT_EQ(Sub2Options.CheckOptions.lookup("TestKey").Value, "3");
57+
}
58+
} // namespace
59+
} // namespace clangd
60+
} // namespace clang

clang/docs/ReleaseNotes.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,18 @@ New Pragmas in Clang
144144

145145
- ...
146146

147+
Modified Pragmas in Clang
148+
-------------------------
149+
150+
- The "#pragma clang loop vectorize_width" has been extended to support an
151+
optional 'fixed|scalable' argument, which can be used to indicate that the
152+
compiler should use fixed-width or scalable vectorization. Fixed-width is
153+
assumed by default.
154+
155+
Scalable or vector length agnostic vectorization is an experimental feature
156+
for targets that support scalable vectors. For more information please refer
157+
to the Clang Language Extensions documentation.
158+
147159
Attribute Changes in Clang
148160
--------------------------
149161

clang/include/clang/AST/ASTContext.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,9 @@ class ASTContext : public RefCountedBase<ASTContext> {
538538
/// need them (like static local vars).
539539
llvm::MapVector<const NamedDecl *, unsigned> MangleNumbers;
540540
llvm::MapVector<const VarDecl *, unsigned> StaticLocalNumbers;
541+
/// Mapping the associated device lambda mangling number if present.
542+
mutable llvm::DenseMap<const CXXRecordDecl *, unsigned>
543+
DeviceLambdaManglingNumbers;
541544

542545
/// Mapping that stores parameterIndex values for ParmVarDecls when
543546
/// that value exceeds the bitfield size of ParmVarDeclBits.ParameterIndex.

clang/include/clang/AST/DeclCXX.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1735,6 +1735,12 @@ class CXXRecordDecl : public RecordDecl {
17351735
getLambdaData().HasKnownInternalLinkage = HasKnownInternalLinkage;
17361736
}
17371737

1738+
/// Set the device side mangling number.
1739+
void setDeviceLambdaManglingNumber(unsigned Num) const;
1740+
1741+
/// Retrieve the device side mangling number.
1742+
unsigned getDeviceLambdaManglingNumber() const;
1743+
17381744
/// Returns the inheritance model used for this record.
17391745
MSInheritanceModel getMSInheritanceModel() const;
17401746

clang/include/clang/AST/Mangle.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ class MangleContext {
9696
virtual bool shouldMangleCXXName(const NamedDecl *D) = 0;
9797
virtual bool shouldMangleStringLiteral(const StringLiteral *SL) = 0;
9898

99+
virtual bool isDeviceMangleContext() const { return false; }
100+
virtual void setDeviceMangleContext(bool) {}
101+
99102
// FIXME: consider replacing raw_ostream & with something like SmallString &.
100103
void mangleName(GlobalDecl GD, raw_ostream &);
101104
virtual void mangleCXXName(GlobalDecl GD, raw_ostream &) = 0;

clang/include/clang/AST/MangleNumberingContext.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ class MangleNumberingContext {
5252
/// this context.
5353
virtual unsigned getManglingNumber(const TagDecl *TD,
5454
unsigned MSLocalManglingNumber) = 0;
55+
56+
/// Retrieve the mangling number of a new lambda expression with the
57+
/// given call operator within the device context. No device number is
58+
/// assigned if there's no device numbering context is associated.
59+
virtual unsigned getDeviceManglingNumber(const CXXMethodDecl *) { return 0; }
5560
};
5661

5762
} // end namespace clang

clang/include/clang/AST/RecursiveASTVisitor.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,9 @@ template <typename Derived> class RecursiveASTVisitor {
186186
/// code, e.g., implicit constructors and destructors.
187187
bool shouldVisitImplicitCode() const { return false; }
188188

189+
/// Return whether this visitor should recurse into lambda body
190+
bool shouldVisitLambdaBody() const { return true; }
191+
189192
/// Return whether this visitor should traverse post-order.
190193
bool shouldTraversePostOrder() const { return false; }
191194

@@ -2057,6 +2060,15 @@ bool RecursiveASTVisitor<Derived>::TraverseFunctionHelper(FunctionDecl *D) {
20572060
// by clang.
20582061
(!D->isDefaulted() || getDerived().shouldVisitImplicitCode());
20592062

2063+
if (const auto *MD = dyn_cast<CXXMethodDecl>(D)) {
2064+
if (const CXXRecordDecl *RD = MD->getParent()) {
2065+
if (RD->isLambda() &&
2066+
declaresSameEntity(RD->getLambdaCallOperator(), MD)) {
2067+
VisitBody = VisitBody && getDerived().shouldVisitLambdaBody();
2068+
}
2069+
}
2070+
}
2071+
20602072
if (VisitBody) {
20612073
TRY_TO(TraverseStmt(D->getBody())); // Function body.
20622074
}

clang/include/clang/ASTMatchers/ASTMatchers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ extern const internal::VariadicAllOfMatcher<Decl> decl;
344344
/// int number = 42;
345345
/// auto [foo, bar] = std::make_pair{42, 42};
346346
/// \endcode
347-
extern const internal::VariadicAllOfMatcher<DecompositionDecl>
347+
extern const internal::VariadicDynCastAllOfMatcher<Decl, DecompositionDecl>
348348
decompositionDecl;
349349

350350
/// Matches a declaration of a linkage specification.

clang/include/clang/Basic/CodeGenOptions.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,9 @@ CODEGENOPT(VectorizeLoop , 1, 0) ///< Run loop vectorizer.
266266
CODEGENOPT(VectorizeSLP , 1, 0) ///< Run SLP vectorizer.
267267
CODEGENOPT(ProfileSampleAccurate, 1, 0) ///< Sample profile is accurate.
268268

269+
/// Treat loops as finite: language, always, never.
270+
ENUM_CODEGENOPT(FiniteLoops, FiniteLoopsKind, 2, FiniteLoopsKind::Language)
271+
269272
/// Attempt to use register sized accesses to bit-fields in structures, when
270273
/// possible.
271274
CODEGENOPT(UseRegisterSizedBitfieldAccess , 1, 0)

clang/include/clang/Basic/CodeGenOptions.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,12 @@ class CodeGenOptions : public CodeGenOptionsBase {
140140
All, // Keep all frame pointers.
141141
};
142142

143+
enum FiniteLoopsKind {
144+
Language, // Not specified, use language standard.
145+
Always, // All loops are assumed to be finite.
146+
Never, // No loop is assumed to be finite.
147+
};
148+
143149
/// The code model to use (-mcmodel).
144150
std::string CodeModel;
145151

0 commit comments

Comments
 (0)