Skip to content

Commit 0030b1b

Browse files
committed
Merge remote-tracking branch 'origin/main' into lv-use-scev-for-min-iter
2 parents 8a89ff3 + 6d8e966 commit 0030b1b

File tree

348 files changed

+12131
-5092
lines changed

Some content is hidden

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

348 files changed

+12131
-5092
lines changed

.github/new-prs-labeler.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ PGO:
6969
- llvm/**/llvm-profdata/**/*
7070
- llvm/**/llvm-profgen/**/*
7171

72-
vectorization:
72+
vectorizers:
7373
- llvm/lib/Transforms/Vectorize/**/*
7474
- llvm/include/llvm/Transforms/Vectorize/**/*
7575

.github/workflows/release-binaries.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ jobs:
328328
run: |
329329
# Build some of the mlir tools that take a long time to link
330330
if [ "${{ needs.prepare.outputs.build-flang }}" = "true" ]; then
331-
ninja -C ${{ steps.setup-stage.outputs.build-prefix }}/build/tools/clang/stage2-bins/ -j2 flang-new bbc
331+
ninja -C ${{ steps.setup-stage.outputs.build-prefix }}/build/tools/clang/stage2-bins/ -j2 flang bbc
332332
fi
333333
ninja -C ${{ steps.setup-stage.outputs.build-prefix }}/build/tools/clang/stage2-bins/ \
334334
mlir-bytecode-parser-fuzzer \

bolt/lib/Profile/YAMLProfileReader.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -643,11 +643,7 @@ size_t YAMLProfileReader::matchWithNameSimilarity(BinaryContext &BC) {
643643
// equal number of blocks.
644644
if (NamespaceToProfiledBFSizesIt->second.count(BF->size()) == 0)
645645
continue;
646-
auto NamespaceToBFsIt = NamespaceToBFs.find(Namespace);
647-
if (NamespaceToBFsIt == NamespaceToBFs.end())
648-
NamespaceToBFs[Namespace] = {BF};
649-
else
650-
NamespaceToBFsIt->second.push_back(BF);
646+
NamespaceToBFs[Namespace].push_back(BF);
651647
}
652648

653649
// Iterates through all profiled functions and binary functions belonging to

clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,9 @@ void MoveConstArgCheck::check(const MatchFinder::MatchResult &Result) {
209209
}
210210

211211
if (const CXXRecordDecl *RecordDecl = ArgType->getAsCXXRecordDecl();
212-
RecordDecl && !(RecordDecl->hasMoveConstructor() &&
213-
RecordDecl->hasMoveAssignment())) {
212+
RecordDecl && RecordDecl->hasDefinition() &&
213+
!(RecordDecl->hasMoveConstructor() &&
214+
RecordDecl->hasMoveAssignment())) {
214215
const bool MissingMoveAssignment = !RecordDecl->hasMoveAssignment();
215216
const bool MissingMoveConstructor = !RecordDecl->hasMoveConstructor();
216217
const bool MissingBoth = MissingMoveAssignment && MissingMoveConstructor;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ add_clang_library(clangTidyPortabilityModule STATIC
99
RestrictSystemIncludesCheck.cpp
1010
SIMDIntrinsicsCheck.cpp
1111
StdAllocatorConstCheck.cpp
12+
TemplateVirtualMemberFunctionCheck.cpp
1213

1314
LINK_LIBS
1415
clangTidy

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "RestrictSystemIncludesCheck.h"
1313
#include "SIMDIntrinsicsCheck.h"
1414
#include "StdAllocatorConstCheck.h"
15+
#include "TemplateVirtualMemberFunctionCheck.h"
1516

1617
namespace clang::tidy {
1718
namespace portability {
@@ -25,6 +26,8 @@ class PortabilityModule : public ClangTidyModule {
2526
"portability-simd-intrinsics");
2627
CheckFactories.registerCheck<StdAllocatorConstCheck>(
2728
"portability-std-allocator-const");
29+
CheckFactories.registerCheck<TemplateVirtualMemberFunctionCheck>(
30+
"portability-template-virtual-member-function");
2831
}
2932
};
3033

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
//===--- TemplateVirtualMemberFunctionCheck.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 "TemplateVirtualMemberFunctionCheck.h"
10+
#include "clang/ASTMatchers/ASTMatchFinder.h"
11+
12+
using namespace clang::ast_matchers;
13+
14+
namespace clang::tidy::portability {
15+
namespace {
16+
AST_MATCHER(CXXMethodDecl, isUsed) { return Node.isUsed(); }
17+
} // namespace
18+
19+
void TemplateVirtualMemberFunctionCheck::registerMatchers(MatchFinder *Finder) {
20+
Finder->addMatcher(
21+
cxxMethodDecl(ofClass(classTemplateSpecializationDecl(
22+
unless(isExplicitTemplateSpecialization()))
23+
.bind("specialization")),
24+
isVirtual(), unless(isUsed()),
25+
unless(cxxDestructorDecl(isDefaulted())))
26+
.bind("method"),
27+
this);
28+
}
29+
30+
void TemplateVirtualMemberFunctionCheck::check(
31+
const MatchFinder::MatchResult &Result) {
32+
const auto *ImplicitSpecialization =
33+
Result.Nodes.getNodeAs<ClassTemplateSpecializationDecl>("specialization");
34+
const auto *MethodDecl = Result.Nodes.getNodeAs<CXXMethodDecl>("method");
35+
36+
diag(MethodDecl->getLocation(),
37+
"unspecified virtual member function instantiation; the virtual "
38+
"member function is not instantiated but it might be with a "
39+
"different compiler");
40+
diag(ImplicitSpecialization->getPointOfInstantiation(),
41+
"template instantiated here", DiagnosticIDs::Note);
42+
}
43+
44+
} // namespace clang::tidy::portability
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//===--- TemplateVirtualMemberFunctionCheck.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_PORTABILITY_TEMPLATEVIRTUALMEMBERFUNCTIONCHECK_H
10+
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PORTABILITY_TEMPLATEVIRTUALMEMBERFUNCTIONCHECK_H
11+
12+
#include "../ClangTidyCheck.h"
13+
14+
namespace clang::tidy::portability {
15+
16+
/// Upon instantiating a template class, non-virtual member functions don't have
17+
/// to be instantiated unless they are used. Virtual member function
18+
/// instantiation on the other hand is unspecified and depends on the
19+
/// implementation of the compiler. This check intends to find cases when a
20+
/// virtual member function is not instantiated but it might be with a different
21+
/// compiler.
22+
///
23+
/// For the user-facing documentation see:
24+
/// http://clang.llvm.org/extra/clang-tidy/checks/portability/template-virtual-member-function.html
25+
class TemplateVirtualMemberFunctionCheck : public ClangTidyCheck {
26+
public:
27+
TemplateVirtualMemberFunctionCheck(StringRef Name, ClangTidyContext *Context)
28+
: ClangTidyCheck(Name, Context) {}
29+
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
30+
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
31+
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
32+
return LangOpts.CPlusPlus;
33+
}
34+
};
35+
36+
} // namespace clang::tidy::portability
37+
38+
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PORTABILITY_TEMPLATEVIRTUALMEMBERFUNCTIONCHECK_H

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

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@
88
#
99
# ===-----------------------------------------------------------------------===#
1010

11-
from __future__ import unicode_literals
12-
1311
import argparse
1412
import glob
1513
import io
1614
import os
1715
import re
16+
import sys
17+
from typing import List
1818

1919

20-
def replaceInFileRegex(fileName, sFrom, sTo):
20+
def replaceInFileRegex(fileName: str, sFrom: str, sTo: str) -> None:
2121
if sFrom == sTo:
2222
return
2323

@@ -35,7 +35,7 @@ def replaceInFileRegex(fileName, sFrom, sTo):
3535
f.write(txt)
3636

3737

38-
def replaceInFile(fileName, sFrom, sTo):
38+
def replaceInFile(fileName: str, sFrom: str, sTo: str) -> None:
3939
if sFrom == sTo:
4040
return
4141
txt = None
@@ -51,7 +51,7 @@ def replaceInFile(fileName, sFrom, sTo):
5151
f.write(txt)
5252

5353

54-
def generateCommentLineHeader(filename):
54+
def generateCommentLineHeader(filename: str) -> str:
5555
return "".join(
5656
[
5757
"//===--- ",
@@ -63,7 +63,7 @@ def generateCommentLineHeader(filename):
6363
)
6464

6565

66-
def generateCommentLineSource(filename):
66+
def generateCommentLineSource(filename: str) -> str:
6767
return "".join(
6868
[
6969
"//===--- ",
@@ -75,7 +75,7 @@ def generateCommentLineSource(filename):
7575
)
7676

7777

78-
def fileRename(fileName, sFrom, sTo):
78+
def fileRename(fileName: str, sFrom: str, sTo: str) -> str:
7979
if sFrom not in fileName or sFrom == sTo:
8080
return fileName
8181
newFileName = fileName.replace(sFrom, sTo)
@@ -84,7 +84,7 @@ def fileRename(fileName, sFrom, sTo):
8484
return newFileName
8585

8686

87-
def deleteMatchingLines(fileName, pattern):
87+
def deleteMatchingLines(fileName: str, pattern: str) -> bool:
8888
lines = None
8989
with io.open(fileName, "r", encoding="utf8") as f:
9090
lines = f.readlines()
@@ -101,7 +101,7 @@ def deleteMatchingLines(fileName, pattern):
101101
return True
102102

103103

104-
def getListOfFiles(clang_tidy_path):
104+
def getListOfFiles(clang_tidy_path: str) -> List[str]:
105105
files = glob.glob(os.path.join(clang_tidy_path, "**"), recursive=True)
106106
files += [
107107
os.path.normpath(os.path.join(clang_tidy_path, "../docs/ReleaseNotes.rst"))
@@ -124,7 +124,7 @@ def getListOfFiles(clang_tidy_path):
124124

125125
# Adapts the module's CMakelist file. Returns 'True' if it could add a new
126126
# entry and 'False' if the entry already existed.
127-
def adapt_cmake(module_path, check_name_camel):
127+
def adapt_cmake(module_path: str, check_name_camel: str) -> bool:
128128
filename = os.path.join(module_path, "CMakeLists.txt")
129129
with io.open(filename, "r", encoding="utf8") as f:
130130
lines = f.readlines()
@@ -153,7 +153,9 @@ def adapt_cmake(module_path, check_name_camel):
153153

154154

155155
# Modifies the module to include the new check.
156-
def adapt_module(module_path, module, check_name, check_name_camel):
156+
def adapt_module(
157+
module_path: str, module: str, check_name: str, check_name_camel: str
158+
) -> None:
157159
modulecpp = next(
158160
iter(
159161
filter(
@@ -204,7 +206,9 @@ def adapt_module(module_path, module, check_name, check_name_camel):
204206

205207

206208
# Adds a release notes entry.
207-
def add_release_notes(clang_tidy_path, old_check_name, new_check_name):
209+
def add_release_notes(
210+
clang_tidy_path: str, old_check_name: str, new_check_name: str
211+
) -> None:
208212
filename = os.path.normpath(
209213
os.path.join(clang_tidy_path, "../docs/ReleaseNotes.rst")
210214
)
@@ -262,7 +266,7 @@ def add_release_notes(clang_tidy_path, old_check_name, new_check_name):
262266
f.write(line)
263267

264268

265-
def main():
269+
def main() -> None:
266270
parser = argparse.ArgumentParser(description="Rename clang-tidy check.")
267271
parser.add_argument("old_check_name", type=str, help="Old check name.")
268272
parser.add_argument("new_check_name", type=str, help="New check name.")
@@ -311,7 +315,7 @@ def main():
311315
"Check name '%s' not found in %s. Exiting."
312316
% (check_name_camel, cmake_lists)
313317
)
314-
return 1
318+
sys.exit(1)
315319

316320
modulecpp = next(
317321
iter(

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,12 @@ New checks
121121
Gives warnings for tagged unions, where the number of tags is
122122
different from the number of data members inside the union.
123123

124+
- New :doc:`portability-template-virtual-member-function
125+
<clang-tidy/checks/portability/template-virtual-member-function>` check.
126+
127+
Finds cases when an uninstantiated virtual member function in a template class
128+
causes cross-compiler incompatibility.
129+
124130
New check aliases
125131
^^^^^^^^^^^^^^^^^
126132

@@ -210,6 +216,10 @@ Changes in existing checks
210216
<clang-tidy/checks/performance/avoid-endl>` check to use ``std::endl`` as
211217
placeholder when lexer cannot get source text.
212218

219+
- Improved :doc:`performance-move-const-arg
220+
<clang-tidy/checks/performance/move-const-arg>` check to fix a crash when
221+
an argument type is declared but not defined.
222+
213223
- Improved :doc:`readability-container-contains
214224
<clang-tidy/checks/readability/container-contains>` check to let it work on
215225
any class that has a ``contains`` method.

0 commit comments

Comments
 (0)