Skip to content

Commit 3648542

Browse files
committed
Merge from 'master' to 'sycl-web' (#5)
CONFLICT (content): Merge conflict in llvm/lib/Support/Triple.cpp
2 parents 2415f3b + f77c948 commit 3648542

File tree

1,411 files changed

+44943
-11771
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,411 files changed

+44943
-11771
lines changed

.github/workflows/main-branch-sync.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,14 @@ jobs:
1212
- name: Checkout Code
1313
uses: actions/checkout@v2
1414
with:
15+
# persist-credentials: false allows us to use our own credentials for
16+
# pushing to the repository. Otherwise, the default github actions token
17+
# is used.
18+
persist-credentials: false
1519
fetch-depth: 0
1620

1721
- name: Update branch
1822
env:
1923
LLVMBOT_TOKEN: ${{ secrets.LLVMBOT_MAIN_SYNC }}
2024
run: |
21-
git push https://[email protected]/${{ github.repository }} HEAD:temp-test-main
25+
git push https://[email protected]/${{ github.repository }} HEAD:main

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ using ::clang::transformer::cat;
2929
using ::clang::transformer::change;
3030
using ::clang::transformer::makeRule;
3131
using ::clang::transformer::node;
32+
using ::clang::transformer::RewriteRule;
3233

3334
static const char DefaultStringLikeClasses[] = "::std::basic_string;"
3435
"::std::basic_string_view;"
@@ -69,7 +70,7 @@ MakeRule(const LangOptions &LangOpts,
6970
hasArgument(1, cxxDefaultArgExpr())),
7071
onImplicitObjectArgument(expr().bind("string_being_searched")));
7172

72-
tooling::RewriteRule rule = applyFirst(
73+
RewriteRule rule = applyFirst(
7374
{makeRule(binaryOperator(hasOperatorName("=="),
7475
hasOperands(ignoringParenImpCasts(StringNpos),
7576
ignoringParenImpCasts(StringFind))),

clang-tools-extra/clang-tidy/rename_check.py

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -120,16 +120,15 @@ def adapt_cmake(module_path, check_name_camel):
120120
if (not file_added) and (cpp_line or cpp_found):
121121
cpp_found = True
122122
if (line.strip() > cpp_file) or (not cpp_line):
123-
f.write(' ' + cpp_file + '\n')
123+
f.write((' ' + cpp_file + '\n').encode())
124124
file_added = True
125-
f.write(line)
125+
f.write(line.encode())
126126

127127
return True
128128

129129
# Modifies the module to include the new check.
130130
def adapt_module(module_path, module, check_name, check_name_camel):
131-
modulecpp = filter(lambda p: p.lower() == module.lower() + 'tidymodule.cpp',
132-
os.listdir(module_path))[0]
131+
modulecpp = next(filter(lambda p: p.lower() == module.lower() + 'tidymodule.cpp', os.listdir(module_path)))
133132
filename = os.path.join(module_path, modulecpp)
134133
with open(filename, 'r') as f:
135134
lines = f.readlines()
@@ -149,21 +148,21 @@ def adapt_module(module_path, module, check_name, check_name_camel):
149148
header_found = True
150149
if match.group(1) > check_name_camel:
151150
header_added = True
152-
f.write('#include "' + check_name_camel + '.h"\n')
151+
f.write(('#include "' + check_name_camel + '.h"\n').encode())
153152
elif header_found:
154153
header_added = True
155-
f.write('#include "' + check_name_camel + '.h"\n')
154+
f.write(('#include "' + check_name_camel + '.h"\n').encode())
156155

157156
if not check_added:
158157
if line.strip() == '}':
159158
check_added = True
160-
f.write(check_decl)
159+
f.write(check_decl.encode())
161160
else:
162161
match = re.search('registerCheck<(.*)>', line)
163162
if match and match.group(1) > check_name_camel:
164163
check_added = True
165-
f.write(check_decl)
166-
f.write(line)
164+
f.write(check_decl.encode())
165+
f.write(line.encode())
167166

168167

169168
# Adds a release notes entry.
@@ -198,22 +197,22 @@ def add_release_notes(clang_tidy_path, old_check_name, new_check_name):
198197

199198
if match:
200199
header_found = True
201-
f.write(line)
200+
f.write(line.encode())
202201
continue
203202

204203
if line.startswith('^^^^'):
205-
f.write(line)
204+
f.write(line.encode())
206205
continue
207206

208207
if header_found and add_note_here:
209208
if not line.startswith('^^^^'):
210-
f.write("""- The '%s' check was renamed to :doc:`%s
209+
f.write(("""- The '%s' check was renamed to :doc:`%s
211210
<clang-tidy/checks/%s>`
212211
213-
""" % (old_check_name, new_check_name, new_check_name))
212+
""" % (old_check_name, new_check_name, new_check_name)).encode())
214213
note_added = True
215214

216-
f.write(line)
215+
f.write(line.encode())
217216

218217
def main():
219218
parser = argparse.ArgumentParser(description='Rename clang-tidy check.')
@@ -259,9 +258,9 @@ def main():
259258
(check_name_camel, cmake_lists))
260259
return 1
261260

262-
modulecpp = filter(
261+
modulecpp = next(filter(
263262
lambda p: p.lower() == old_module.lower() + 'tidymodule.cpp',
264-
os.listdir(old_module_path))[0]
263+
os.listdir(old_module_path)))
265264
deleteMatchingLines(os.path.join(old_module_path, modulecpp),
266265
'\\b' + check_name_camel + '|\\b' + args.old_check_name)
267266

clang-tools-extra/clangd/CodeComplete.cpp

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,22 @@ struct CompletionCandidate {
173173

174174
// Returns a token identifying the overload set this is part of.
175175
// 0 indicates it's not part of any overload set.
176-
size_t overloadSet(const CodeCompleteOptions &Opts) const {
176+
size_t overloadSet(const CodeCompleteOptions &Opts, llvm::StringRef FileName,
177+
IncludeInserter *Inserter) const {
177178
if (!Opts.BundleOverloads.getValueOr(false))
178179
return 0;
180+
181+
// Depending on the index implementation, we can see different header
182+
// strings (literal or URI) mapping to the same file. We still want to
183+
// bundle those, so we must resolve the header to be included here.
184+
std::string HeaderForHash;
185+
if (Inserter)
186+
if (auto Header = headerToInsertIfAllowed(Opts))
187+
if (auto HeaderFile = toHeaderFile(*Header, FileName))
188+
if (auto Spelled =
189+
Inserter->calculateIncludePath(*HeaderFile, FileName))
190+
HeaderForHash = *Spelled;
191+
179192
llvm::SmallString<256> Scratch;
180193
if (IndexResult) {
181194
switch (IndexResult->SymInfo.Kind) {
@@ -192,7 +205,7 @@ struct CompletionCandidate {
192205
// This could break #include insertion.
193206
return llvm::hash_combine(
194207
(IndexResult->Scope + IndexResult->Name).toStringRef(Scratch),
195-
headerToInsertIfAllowed(Opts).getValueOr(""));
208+
HeaderForHash);
196209
default:
197210
return 0;
198211
}
@@ -206,8 +219,7 @@ struct CompletionCandidate {
206219
llvm::raw_svector_ostream OS(Scratch);
207220
D->printQualifiedName(OS);
208221
}
209-
return llvm::hash_combine(Scratch,
210-
headerToInsertIfAllowed(Opts).getValueOr(""));
222+
return llvm::hash_combine(Scratch, HeaderForHash);
211223
}
212224
assert(IdentifierResult);
213225
return 0;
@@ -1570,7 +1582,8 @@ class CodeCompleteFlow {
15701582
assert(IdentifierResult);
15711583
C.Name = IdentifierResult->Name;
15721584
}
1573-
if (auto OverloadSet = C.overloadSet(Opts)) {
1585+
if (auto OverloadSet = C.overloadSet(
1586+
Opts, FileName, Inserter ? Inserter.getPointer() : nullptr)) {
15741587
auto Ret = BundleLookup.try_emplace(OverloadSet, Bundles.size());
15751588
if (Ret.second)
15761589
Bundles.emplace_back();

clang-tools-extra/clangd/Diagnostics.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ const char *getMainFileRange(const Diag &D, const SourceManager &SM,
186186

187187
// Place the diagnostic the main file, rather than the header, if possible:
188188
// - for errors in included files, use the #include location
189-
// - for errors in template instantiation, use the instantation location
189+
// - for errors in template instantiation, use the instantiation location
190190
// In both cases, add the original header location as a note.
191191
bool tryMoveToMainFile(Diag &D, FullSourceLoc DiagLoc) {
192192
const SourceManager &SM = DiagLoc.getManager();

clang-tools-extra/clangd/index/FileIndex.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,8 +366,6 @@ FileSymbols::buildIndex(IndexType Type, DuplicateHandling DuplicateHandle,
366366
StorageSize += Slab->bytes();
367367
for (const auto &RefSlab : RefSlabs)
368368
StorageSize += RefSlab->bytes();
369-
for (const auto &RelationSlab : RelationSlabs)
370-
StorageSize += RelationSlab->bytes();
371369

372370
// Index must keep the slabs and contiguous ranges alive.
373371
switch (Type) {

clang-tools-extra/clangd/refactor/Rename.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ const NamedDecl *canonicalRenameDecl(const NamedDecl *D) {
129129
// CXXMethodDecl::getInstantiatedFromMemberFunction for the field because
130130
// Clang AST does not store relevant information about the field that is
131131
// instantiated.
132-
const auto *FieldParent = dyn_cast<CXXRecordDecl>(Field->getParent());
132+
const auto *FieldParent =
133+
dyn_cast_or_null<CXXRecordDecl>(Field->getParent());
133134
if (!FieldParent)
134135
return Field->getCanonicalDecl();
135136
FieldParent = FieldParent->getTemplateInstantiationPattern();

clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1628,6 +1628,29 @@ TEST(CompletionTest, OverloadBundling) {
16281628
EXPECT_EQ(A.SnippetSuffix, "($0)");
16291629
}
16301630

1631+
TEST(CompletionTest, OverloadBundlingSameFileDifferentURI) {
1632+
clangd::CodeCompleteOptions Opts;
1633+
Opts.BundleOverloads = true;
1634+
1635+
Symbol SymX = sym("ns::X", index::SymbolKind::Function, "@F@\\0#");
1636+
Symbol SymY = sym("ns::X", index::SymbolKind::Function, "@F@\\0#I#");
1637+
std::string BarHeader = testPath("bar.h");
1638+
auto BarURI = URI::create(BarHeader).toString();
1639+
SymX.CanonicalDeclaration.FileURI = BarURI.c_str();
1640+
SymY.CanonicalDeclaration.FileURI = BarURI.c_str();
1641+
// The include header is different, but really it's the same file.
1642+
SymX.IncludeHeaders.emplace_back("\"bar.h\"", 1);
1643+
SymY.IncludeHeaders.emplace_back(BarURI.c_str(), 1);
1644+
1645+
auto Results = completions("void f() { ::ns::^ }", {SymX, SymY}, Opts);
1646+
// Expect both results are bundled, despite the different-but-same
1647+
// IncludeHeader.
1648+
ASSERT_EQ(1u, Results.Completions.size());
1649+
const auto &R = Results.Completions.front();
1650+
EXPECT_EQ("X", R.Name);
1651+
EXPECT_EQ(2u, R.BundleSize);
1652+
}
1653+
16311654
TEST(CompletionTest, DocumentationFromChangedFileCrash) {
16321655
MockFS FS;
16331656
auto FooH = testPath("foo.h");

clang-tools-extra/clangd/unittests/RenameTests.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -816,13 +816,21 @@ TEST(RenameTest, WithinFileRename) {
816816
[[F^oo]] foo = static_cast<[[F^oo]]>(boo);
817817
}
818818
)cpp",
819+
820+
// ObjC, should not crash.
821+
R"cpp(
822+
@interface ObjC {
823+
char [[da^ta]];
824+
} @end
825+
)cpp",
819826
};
820827
llvm::StringRef NewName = "NewName";
821828
for (llvm::StringRef T : Tests) {
822829
SCOPED_TRACE(T);
823830
Annotations Code(T);
824831
auto TU = TestTU::withCode(Code.code());
825832
TU.ExtraArgs.push_back("-fno-delayed-template-parsing");
833+
TU.ExtraArgs.push_back("-xobjective-c++");
826834
auto AST = TU.build();
827835
for (const auto &RenamePos : Code.points()) {
828836
auto RenameResult =

clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,22 @@ using namespace ::clang::ast_matchers;
2323
using transformer::cat;
2424
using transformer::change;
2525
using transformer::IncludeFormat;
26+
using transformer::makeRule;
2627
using transformer::node;
2728
using transformer::RewriteRule;
2829
using transformer::statement;
2930

3031
// Invert the code of an if-statement, while maintaining its semantics.
3132
RewriteRule invertIf() {
3233
StringRef C = "C", T = "T", E = "E";
33-
RewriteRule Rule = tooling::makeRule(
34-
ifStmt(hasCondition(expr().bind(C)), hasThen(stmt().bind(T)),
35-
hasElse(stmt().bind(E))),
36-
change(statement(std::string(RewriteRule::RootID)),
37-
cat("if(!(", node(std::string(C)), ")) ",
38-
statement(std::string(E)), " else ",
39-
statement(std::string(T)))),
40-
cat("negate condition and reverse `then` and `else` branches"));
34+
RewriteRule Rule =
35+
makeRule(ifStmt(hasCondition(expr().bind(C)), hasThen(stmt().bind(T)),
36+
hasElse(stmt().bind(E))),
37+
change(statement(std::string(RewriteRule::RootID)),
38+
cat("if(!(", node(std::string(C)), ")) ",
39+
statement(std::string(E)), " else ",
40+
statement(std::string(T)))),
41+
cat("negate condition and reverse `then` and `else` branches"));
4142
return Rule;
4243
}
4344

@@ -70,10 +71,9 @@ TEST(TransformerClangTidyCheckTest, Basic) {
7071
class IntLitCheck : public TransformerClangTidyCheck {
7172
public:
7273
IntLitCheck(StringRef Name, ClangTidyContext *Context)
73-
: TransformerClangTidyCheck(tooling::makeRule(integerLiteral(),
74-
change(cat("LIT")),
75-
cat("no message")),
76-
Name, Context) {}
74+
: TransformerClangTidyCheck(
75+
makeRule(integerLiteral(), change(cat("LIT")), cat("no message")),
76+
Name, Context) {}
7777
};
7878

7979
// Tests that two changes in a single macro expansion do not lead to conflicts
@@ -95,7 +95,7 @@ class BinOpCheck : public TransformerClangTidyCheck {
9595
public:
9696
BinOpCheck(StringRef Name, ClangTidyContext *Context)
9797
: TransformerClangTidyCheck(
98-
tooling::makeRule(
98+
makeRule(
9999
binaryOperator(hasOperatorName("+"), hasRHS(expr().bind("r"))),
100100
change(node("r"), cat("RIGHT")), cat("no message")),
101101
Name, Context) {}
@@ -122,8 +122,8 @@ Optional<RewriteRule> needsObjC(const LangOptions &LangOpts,
122122
const ClangTidyCheck::OptionsView &Options) {
123123
if (!LangOpts.ObjC)
124124
return None;
125-
return tooling::makeRule(clang::ast_matchers::functionDecl(),
126-
change(cat("void changed() {}")), cat("no message"));
125+
return makeRule(clang::ast_matchers::functionDecl(),
126+
change(cat("void changed() {}")), cat("no message"));
127127
}
128128

129129
class NeedsObjCCheck : public TransformerClangTidyCheck {
@@ -147,8 +147,8 @@ Optional<RewriteRule> noSkip(const LangOptions &LangOpts,
147147
const ClangTidyCheck::OptionsView &Options) {
148148
if (Options.get("Skip", "false") == "true")
149149
return None;
150-
return tooling::makeRule(clang::ast_matchers::functionDecl(),
151-
changeTo(cat("void nothing();")), cat("no message"));
150+
return makeRule(clang::ast_matchers::functionDecl(),
151+
changeTo(cat("void nothing();")), cat("no message"));
152152
}
153153

154154
class ConfigurableCheck : public TransformerClangTidyCheck {
@@ -174,9 +174,8 @@ TEST(TransformerClangTidyCheckTest, DisableByConfig) {
174174

175175
RewriteRule replaceCall(IncludeFormat Format) {
176176
using namespace ::clang::ast_matchers;
177-
RewriteRule Rule =
178-
tooling::makeRule(callExpr(callee(functionDecl(hasName("f")))),
179-
change(cat("other()")), cat("no message"));
177+
RewriteRule Rule = makeRule(callExpr(callee(functionDecl(hasName("f")))),
178+
change(cat("other()")), cat("no message"));
180179
addInclude(Rule, "clang/OtherLib.h", Format);
181180
return Rule;
182181
}

clang/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,6 @@ set(ENABLE_LINKER_BUILD_ID OFF CACHE BOOL "pass --build-id to ld")
242242
set(ENABLE_X86_RELAX_RELOCATIONS ON CACHE BOOL
243243
"enable x86 relax relocations by default")
244244

245-
set(ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER FALSE CACHE BOOL
246-
"Enable the experimental new pass manager by default.")
247-
248245
set(CLANG_SPAWN_CC1 OFF CACHE BOOL
249246
"Whether clang should use a new process for the CC1 invocation")
250247

clang/cmake/caches/Fuchsia-stage2.cmake

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,14 +211,24 @@ if(FUCHSIA_SDK)
211211
set(RUNTIMES_${target}-unknown-fuchsia+asan+noexcept_LIBCXXABI_ENABLE_EXCEPTIONS OFF CACHE BOOL "")
212212
set(RUNTIMES_${target}-unknown-fuchsia+asan+noexcept_LIBCXX_ENABLE_EXCEPTIONS OFF CACHE BOOL "")
213213

214+
set(RUNTIMES_${target}-unknown-fuchsia+relative-vtables_LLVM_BUILD_COMPILER_RT OFF CACHE BOOL "")
215+
set(RUNTIMES_${target}-unknown-fuchsia+relative-vtables_CMAKE_CXX_FLAGS "${RUNTIMES_${target}-unknown-fuchsia+relative-vtables_CMAKE_CXX_FLAGS} -Xclang -fexperimental-relative-c++-abi-vtables" CACHE STRING "")
216+
217+
set(RUNTIMES_${target}-unknown-fuchsia+relative-vtables+noexcept_LLVM_BUILD_COMPILER_RT OFF CACHE BOOL "")
218+
set(RUNTIMES_${target}-unknown-fuchsia+relative-vtables+noexcept_CMAKE_CXX_FLAGS "${RUNTIMES_${target}-unknown-fuchsia+relative-vtables+noexcept_CMAKE_CXX_FLAGS} -Xclang -fexperimental-relative-c++-abi-vtables" CACHE STRING "")
219+
set(RUNTIMES_${target}-unknown-fuchsia+relative-vtables+noexcept_LIBCXXABI_ENABLE_EXCEPTIONS OFF CACHE BOOL "")
220+
set(RUNTIMES_${target}-unknown-fuchsia+relative-vtables+noexcept_LIBCXX_ENABLE_EXCEPTIONS OFF CACHE BOOL "")
221+
214222
# Use .build-id link.
215223
list(APPEND RUNTIME_BUILD_ID_LINK "${target}-unknown-fuchsia")
216224
endforeach()
217225

218-
set(LLVM_RUNTIME_MULTILIBS "asan;noexcept;asan+noexcept" CACHE STRING "")
226+
set(LLVM_RUNTIME_MULTILIBS "asan;noexcept;asan+noexcept;relative-vtables;relative-vtables+noexcept" CACHE STRING "")
219227
set(LLVM_RUNTIME_MULTILIB_asan_TARGETS "x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
220228
set(LLVM_RUNTIME_MULTILIB_noexcept_TARGETS "x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
221229
set(LLVM_RUNTIME_MULTILIB_asan+noexcept_TARGETS "x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
230+
set(LLVM_RUNTIME_MULTILIB_relative-vtables_TARGETS "x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
231+
set(LLVM_RUNTIME_MULTILIB_relative-vtables+noexcept_TARGETS "x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
222232
endif()
223233

224234
set(LLVM_BUILTIN_TARGETS "${BUILTIN_TARGETS}" CACHE STRING "")
@@ -235,6 +245,7 @@ set(LLVM_TOOLCHAIN_TOOLS
235245
llvm-dlltool
236246
llvm-dwarfdump
237247
llvm-dwp
248+
llvm-elfabi
238249
llvm-gsymutil
239250
llvm-lib
240251
llvm-mt

clang/docs/ClangFormatStyleOptions.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2301,6 +2301,10 @@ the configuration (without a prefix: ``Auto``).
23012301
**PenaltyExcessCharacter** (``unsigned``)
23022302
The penalty for each character outside of the column limit.
23032303

2304+
**PenaltyIndentedWhitespace** (``unsigned``)
2305+
Penalty for each character of whitespace indentation
2306+
(counted relative to leading non-whitespace column).
2307+
23042308
**PenaltyReturnTypeOnItsOwnLine** (``unsigned``)
23052309
Penalty for putting the return type of a function onto its own
23062310
line.

0 commit comments

Comments
 (0)