Skip to content

Commit 81cf910

Browse files
committed
Merge from 'main' to 'sycl-web' (327 commits)
CONFLICT (content): Merge conflict in clang/test/CodeGenCXX/visibility.cpp
2 parents 8b549f6 + 7474214 commit 81cf910

File tree

2,018 files changed

+43235
-10995
lines changed

Some content is hidden

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

2,018 files changed

+43235
-10995
lines changed

clang-tools-extra/clang-include-fixer/IncludeFixer.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,14 @@ namespace {
2727
class Action : public clang::ASTFrontendAction {
2828
public:
2929
explicit Action(SymbolIndexManager &SymbolIndexMgr, bool MinimizeIncludePaths)
30-
: SemaSource(SymbolIndexMgr, MinimizeIncludePaths,
31-
/*GenerateDiagnostics=*/false) {}
30+
: SemaSource(new IncludeFixerSemaSource(SymbolIndexMgr,
31+
MinimizeIncludePaths,
32+
/*GenerateDiagnostics=*/false)) {}
3233

3334
std::unique_ptr<clang::ASTConsumer>
3435
CreateASTConsumer(clang::CompilerInstance &Compiler,
3536
StringRef InFile) override {
36-
SemaSource.setFilePath(InFile);
37+
SemaSource->setFilePath(InFile);
3738
return std::make_unique<clang::ASTConsumer>();
3839
}
3940

@@ -51,8 +52,8 @@ class Action : public clang::ASTFrontendAction {
5152
CompletionConsumer = &Compiler->getCodeCompletionConsumer();
5253

5354
Compiler->createSema(getTranslationUnitKind(), CompletionConsumer);
54-
SemaSource.setCompilerInstance(Compiler);
55-
Compiler->getSema().addExternalSource(&SemaSource);
55+
SemaSource->setCompilerInstance(Compiler);
56+
Compiler->getSema().addExternalSource(SemaSource.get());
5657

5758
clang::ParseAST(Compiler->getSema(), Compiler->getFrontendOpts().ShowStats,
5859
Compiler->getFrontendOpts().SkipFunctionBodies);
@@ -61,12 +62,12 @@ class Action : public clang::ASTFrontendAction {
6162
IncludeFixerContext
6263
getIncludeFixerContext(const clang::SourceManager &SourceManager,
6364
clang::HeaderSearch &HeaderSearch) const {
64-
return SemaSource.getIncludeFixerContext(SourceManager, HeaderSearch,
65-
SemaSource.getMatchedSymbols());
65+
return SemaSource->getIncludeFixerContext(SourceManager, HeaderSearch,
66+
SemaSource->getMatchedSymbols());
6667
}
6768

6869
private:
69-
IncludeFixerSemaSource SemaSource;
70+
IntrusiveRefCntPtr<IncludeFixerSemaSource> SemaSource;
7071
};
7172

7273
} // namespace

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

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -134,22 +134,25 @@ void UseEmplaceCheck::registerMatchers(MatchFinder *Finder) {
134134
// + match for emplace calls that should be replaced with insertion
135135
auto CallPushBack = cxxMemberCallExpr(
136136
hasDeclaration(functionDecl(hasName("push_back"))),
137-
on(hasType(cxxRecordDecl(hasAnyName(ContainersWithPushBack)))));
137+
on(hasType(hasCanonicalType(
138+
hasDeclaration(cxxRecordDecl(hasAnyName(ContainersWithPushBack)))))));
138139

139-
auto CallPush = cxxMemberCallExpr(
140-
hasDeclaration(functionDecl(hasName("push"))),
141-
on(hasType(cxxRecordDecl(hasAnyName(ContainersWithPush)))));
140+
auto CallPush =
141+
cxxMemberCallExpr(hasDeclaration(functionDecl(hasName("push"))),
142+
on(hasType(hasCanonicalType(hasDeclaration(
143+
cxxRecordDecl(hasAnyName(ContainersWithPush)))))));
142144

143145
auto CallPushFront = cxxMemberCallExpr(
144146
hasDeclaration(functionDecl(hasName("push_front"))),
145-
on(hasType(cxxRecordDecl(hasAnyName(ContainersWithPushFront)))));
147+
on(hasType(hasCanonicalType(hasDeclaration(
148+
cxxRecordDecl(hasAnyName(ContainersWithPushFront)))))));
146149

147150
auto CallEmplacy = cxxMemberCallExpr(
148151
hasDeclaration(
149152
functionDecl(hasAnyNameIgnoringTemplates(EmplacyFunctions))),
150-
on(hasType(cxxRecordDecl(has(typedefNameDecl(
153+
on(hasType(hasCanonicalType(hasDeclaration(has(typedefNameDecl(
151154
hasName("value_type"), hasType(type(hasUnqualifiedDesugaredType(
152-
recordType().bind("value_type"))))))))));
155+
recordType().bind("value_type")))))))))));
153156

154157
// We can't replace push_backs of smart pointer because
155158
// if emplacement fails (f.e. bad_alloc in vector) we will have leak of

clang-tools-extra/clangd/ParsedAST.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,7 @@ ParsedAST::build(llvm::StringRef Filename, const ParseInputs &Inputs,
493493
// We restore the original severity in the level adjuster.
494494
// FIXME: It would be better to have a real API for this, but what?
495495
for (auto ID : {diag::ext_implicit_function_decl_c99,
496+
diag::ext_implicit_lib_function_decl,
496497
diag::ext_implicit_lib_function_decl_c99,
497498
diag::warn_implicit_function_decl}) {
498499
OverriddenSeverity.try_emplace(

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

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1465,11 +1465,12 @@ TEST(IncludeFixerTest, NoCrashOnTemplateInstantiations) {
14651465
TEST(IncludeFixerTest, HeaderNamedInDiag) {
14661466
Annotations Test(R"cpp(
14671467
$insert[[]]int main() {
1468-
[[printf]](""); // error-ok
1468+
[[printf]]("");
14691469
}
14701470
)cpp");
14711471
auto TU = TestTU::withCode(Test.code());
1472-
TU.ExtraArgs = {"-xc"};
1472+
TU.ExtraArgs = {"-xc", "-std=c99",
1473+
"-Wno-error=implicit-function-declaration"};
14731474
auto Index = buildIndexWithSymbol({});
14741475
TU.ExternalIndex = Index.get();
14751476

@@ -1482,13 +1483,22 @@ TEST(IncludeFixerTest, HeaderNamedInDiag) {
14821483
"declarations"),
14831484
withFix(Fix(Test.range("insert"), "#include <stdio.h>\n",
14841485
"Include <stdio.h> for symbol printf")))));
1486+
1487+
TU.ExtraArgs = {"-xc", "-std=c89"};
1488+
EXPECT_THAT(
1489+
*TU.build().getDiagnostics(),
1490+
ElementsAre(AllOf(
1491+
Diag(Test.range(), "implicitly declaring library function 'printf' "
1492+
"with type 'int (const char *, ...)'"),
1493+
withFix(Fix(Test.range("insert"), "#include <stdio.h>\n",
1494+
"Include <stdio.h> for symbol printf")))));
14851495
}
14861496

14871497
TEST(IncludeFixerTest, CImplicitFunctionDecl) {
1488-
Annotations Test("void x() { [[foo]](); /* error-ok */ }");
1498+
Annotations Test("void x() { [[foo]](); }");
14891499
auto TU = TestTU::withCode(Test.code());
14901500
TU.Filename = "test.c";
1491-
TU.ExtraArgs.push_back("-std=c99");
1501+
TU.ExtraArgs = {"-std=c99", "-Wno-error=implicit-function-declaration"};
14921502

14931503
Symbol Sym = func("foo");
14941504
Sym.Flags |= Symbol::IndexedForCodeCompletion;
@@ -1509,6 +1519,13 @@ TEST(IncludeFixerTest, CImplicitFunctionDecl) {
15091519
"support implicit function declarations"),
15101520
withFix(Fix(Range{}, "#include \"foo.h\"\n",
15111521
"Include \"foo.h\" for symbol foo")))));
1522+
1523+
TU.ExtraArgs = {"-std=c89", "-Wall"};
1524+
EXPECT_THAT(*TU.build().getDiagnostics(),
1525+
ElementsAre(AllOf(
1526+
Diag(Test.range(), "implicit declaration of function 'foo'"),
1527+
withFix(Fix(Range{}, "#include \"foo.h\"\n",
1528+
"Include \"foo.h\" for symbol foo")))));
15121529
}
15131530

15141531
TEST(DiagsInHeaders, DiagInsideHeader) {

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,20 @@ Changes in existing checks
129129
<clang-tidy/checks/cppcoreguidelines/pro-type-member-init>` when warnings
130130
would be emitted for uninitialized members of an anonymous union despite
131131
there being an initializer for one of the other members.
132-
133-
- Improved `modernize-use-emplace <clang-tidy/checks/modernize/use-emplace.html>`_ check.
132+
133+
- Improved :doc:`modernize-use-emplace <clang-tidy/checks/modernize/use-emplace>`
134+
check.
134135

135136
The check now supports detecting inefficient invocations of ``push`` and
136137
``push_front`` on STL-style containers and replacing them with ``emplace``
137138
or ``emplace_front``.
138139

139-
- Improved `modernize-use-equals-default <clang-tidy/checks/modernize/use-equals-default.html>`_ check.
140+
The check now supports detecting alias cases of ``push_back`` ``push`` and
141+
``push_front`` on STL-style containers and replacing them with ``emplace_back``,
142+
``emplace`` or ``emplace_front``.
143+
144+
- Improved :doc:`modernize-use-equals-default <clang-tidy/checks/modernize/use-equals-default>`
145+
check.
140146

141147
The check now skips unions since in this case a default constructor with empty body
142148
is not equivalent to the explicitly defaulted one.

clang-tools-extra/test/clang-tidy/checkers/modernize/use-emplace.cpp

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,6 +1061,82 @@ void testAllSTLEmplacyFunctions() {
10611061
// CHECK-FIXES: priority_queue.emplace(13);
10621062
}
10631063

1064+
void test_AliasEmplacyFunctions() {
1065+
typedef std::list<Foo> L;
1066+
using DQ = std::deque<Foo>;
1067+
L l;
1068+
l.emplace_back(Foo(3));
1069+
// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: unnecessary temporary object created while calling emplace_back
1070+
// CHECK-FIXES: l.emplace_back(3);
1071+
1072+
DQ dq;
1073+
dq.emplace_back(Foo(3));
1074+
// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: unnecessary temporary object created while calling emplace_back
1075+
// CHECK-FIXES: dq.emplace_back(3);
1076+
1077+
typedef std::stack<Foo> STACK;
1078+
using PQ = std::priority_queue<Foo>;
1079+
STACK stack;
1080+
stack.emplace(Foo(3));
1081+
// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: unnecessary temporary object created while calling emplace
1082+
// CHECK-FIXES: stack.emplace(3);
1083+
1084+
PQ pq;
1085+
pq.emplace(Foo(3));
1086+
// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: unnecessary temporary object created while calling emplace
1087+
// CHECK-FIXES: pq.emplace(3);
1088+
1089+
typedef std::forward_list<Foo> FL;
1090+
using DQ2 = std::deque<Foo>;
1091+
FL fl;
1092+
fl.emplace_front(Foo(3));
1093+
// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: unnecessary temporary object created while calling emplace_front
1094+
// CHECK-FIXES: fl.emplace_front(3);
1095+
1096+
DQ2 dq2;
1097+
dq2.emplace_front(Foo(3));
1098+
// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: unnecessary temporary object created while calling emplace_front
1099+
// CHECK-FIXES: dq2.emplace_front(3);
1100+
}
1101+
1102+
void test_Alias() {
1103+
typedef std::list<Foo> L;
1104+
using DQ = std::deque<Foo>;
1105+
L l;
1106+
l.push_back(Foo(3));
1107+
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back instead of push_back [modernize-use-emplace]
1108+
// CHECK-FIXES: l.emplace_back(3);
1109+
1110+
DQ dq;
1111+
dq.push_back(Foo(3));
1112+
// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: use emplace_back instead of push_back [modernize-use-emplace]
1113+
// CHECK-FIXES: dq.emplace_back(3);
1114+
1115+
typedef std::stack<Foo> STACK;
1116+
using PQ = std::priority_queue<Foo>;
1117+
STACK stack;
1118+
stack.push(Foo(3));
1119+
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use emplace instead of push [modernize-use-emplace]
1120+
// CHECK-FIXES: stack.emplace(3);
1121+
1122+
PQ pq;
1123+
pq.push(Foo(3));
1124+
// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: use emplace instead of push [modernize-use-emplace]
1125+
// CHECK-FIXES: pq.emplace(3);
1126+
1127+
typedef std::forward_list<Foo> FL;
1128+
using DQ2 = std::deque<Foo>;
1129+
FL fl;
1130+
fl.push_front(Foo(3));
1131+
// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: use emplace_front instead of push_front [modernize-use-emplace]
1132+
// CHECK-FIXES: fl.emplace_front(3);
1133+
1134+
DQ2 dq2;
1135+
dq2.push_front(Foo(3));
1136+
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use emplace_front instead of push_front [modernize-use-emplace]
1137+
// CHECK-FIXES: dq2.emplace_front(3);
1138+
}
1139+
10641140
struct Bar {
10651141
public:
10661142
Bar(){};

clang/docs/ClangCommandLineReference.rst

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,6 @@ Pass <arg> to fatbinary invocation
7676

7777
Pass <arg> to the ptxas assembler
7878

79-
.. option:: -Z<arg>
80-
81-
.. option:: -a<arg>, --profile-blocks
82-
8379
.. option:: -all\_load
8480

8581
.. option:: -allowable\_client <arg>
@@ -579,10 +575,6 @@ Print the library path for the currently used compiler runtime library ("libgcc.
579575

580576
.. option:: -print-multi-lib, --print-multi-lib
581577

582-
.. option:: -print-multiarch, --print-multiarch
583-
584-
Print the multiarch target triple
585-
586578
.. option:: -print-prog-name=<name>, --print-prog-name=<name>, --print-prog-name <arg>
587579

588580
Print the full program path of <name>
@@ -859,9 +851,9 @@ no effect during actions that do not perform compilation.
859851

860852
Pass <arg> to the assembler
861853

862-
.. option:: -Xclang <arg>
854+
.. option:: -Xclang <arg>, -Xclang=<arg>
863855

864-
Pass <arg> to the clang compiler
856+
Pass <arg> to clang -cc1
865857

866858
.. option:: -Xopenmp-target <arg>
867859

@@ -947,10 +939,6 @@ Inline suitable functions
947939

948940
Inline functions which are (explicitly or implicitly) marked inline
949941

950-
.. option:: -finline-max-stacksize=<arg>
951-
952-
Suppress inlining of functions with a stacksize larger than <arg> bytes.
953-
954942
.. option:: -fno-legacy-pass-manager, -fexperimental-new-pass-manager
955943

956944
.. option:: -fno-sanitize-ignorelist, -fno-sanitize-blacklist
@@ -1913,6 +1901,10 @@ Implicitly search the file system for module map files.
19131901

19141902
.. option:: -fimplicit-modules, -fno-implicit-modules
19151903

1904+
.. option:: -finline-max-stacksize=<arg>
1905+
1906+
Suppress inlining of functions whose stack size exceeds the given value
1907+
19161908
.. option:: -finput-charset=<arg>
19171909

19181910
Specify the default character set for source files
@@ -2737,7 +2729,7 @@ The visibility for definitions without an explicit DLL export class \[-fvisibili
27372729

27382730
.. option:: -fvisibility=<arg>
27392731

2740-
Set the default symbol visibility for all global declarations. <arg> must be 'hidden' or 'default'.
2732+
Set the default symbol visibility for all global definitions. <arg> must be 'default', 'protected', 'internal' or 'hidden'.
27412733

27422734
.. option:: -fwasm-exceptions
27432735

@@ -2785,11 +2777,7 @@ Only instrument 1 of N groups
27852777

27862778
Don't instrument functions with loops unless they also meet the minimum function size
27872779

2788-
.. option:: -fxray-instruction-threshold<arg>
2789-
2790-
.. program:: clang1
27912780
.. option:: -fxray-instruction-threshold=<arg>
2792-
.. program:: clang
27932781

27942782
Sets the minimum function size to instrument with XRay
27952783

@@ -3205,6 +3193,10 @@ Not emit the visibility attribute for asm in AIX OS or give all symbols 'unspeci
32053193

32063194
(integrated-as) Emit an object file which can be used with an incremental linker
32073195

3196+
.. option:: -mindirect-branch-cs-prefix
3197+
3198+
Add cs prefix to call and jmp to indirect thunk
3199+
32083200
.. option:: -mios-version-min=<arg>, -miphoneos-version-min=<arg>
32093201

32103202
Set iOS deployment target
@@ -4301,9 +4293,7 @@ Pass <arg> to the linker
43014293

43024294
Pass <arg> to the offload linkers or the ones idenfied by -<triple>
43034295

4304-
.. program:: clang1
43054296
.. option:: -Z
4306-
.. program:: clang
43074297

43084298
.. option:: -b<arg>
43094299

@@ -4390,18 +4380,28 @@ CL.EXE COMPATIBILITY OPTIONS
43904380
dxc compatibility options
43914381

43924382
.. program:: clang4
4383+
.. option:: --E<arg>, /E<arg>, -E<arg>
4384+
.. program:: clang
4385+
4386+
Entry point name
4387+
4388+
.. program:: clang5
43934389
.. option:: /T<profile>, -T<profile>
43944390
.. program:: clang
43954391

43964392
Set target profile. <profile> must be 'ps_6_0', ' ps_6_1', ' ps_6_2', ' ps_6_3', ' ps_6_4', ' ps_6_5', ' ps_6_6', ' ps_6_7', 'vs_6_0', ' vs_6_1', ' vs_6_2', ' vs_6_3', ' vs_6_4', ' vs_6_5', ' vs_6_6', ' vs_6_7', 'gs_6_0', ' gs_6_1', ' gs_6_2', ' gs_6_3', ' gs_6_4', ' gs_6_5', ' gs_6_6', ' gs_6_7', 'hs_6_0', ' hs_6_1', ' hs_6_2', ' hs_6_3', ' hs_6_4', ' hs_6_5', ' hs_6_6', ' hs_6_7', 'ds_6_0', ' ds_6_1', ' ds_6_2', ' ds_6_3', ' ds_6_4', ' ds_6_5', ' ds_6_6', ' ds_6_7', 'cs_6_0', ' cs_6_1', ' cs_6_2', ' cs_6_3', ' cs_6_4', ' cs_6_5', ' cs_6_6', ' cs_6_7', 'lib_6_3', ' lib_6_4', ' lib_6_5', ' lib_6_6', ' lib_6_7', ' lib_6_x', 'ms_6_5', ' ms_6_6', ' ms_6_7', 'as_6_5', ' as_6_6' or ' as_6_7'.
43974393

4398-
.. program:: clang5
4394+
.. program:: clang6
43994395
.. option:: /emit-pristine-llvm, -emit-pristine-llvm, /fcgl, -fcgl
44004396
.. program:: clang
44014397

44024398
Emit pristine LLVM IR from the frontend by not running any LLVM passes at all.Same as -S + -emit-llvm + -disable-llvm-passes.
44034399

4404-
.. program:: clang6
4400+
.. option:: -hlsl-entry <arg>
4401+
4402+
Entry point name for hlsl
4403+
4404+
.. program:: clang7
44054405
.. option:: /hlsl-no-stdinc, -hlsl-no-stdinc
44064406
.. program:: clang
44074407

0 commit comments

Comments
 (0)