Skip to content

Commit 38e127d

Browse files
author
Jenkins
committed
merge main into amd-stg-open
Change-Id: I37ff8fb236f125cdc167fc3fb11a45a712d0b9c6
2 parents 2a9648e + c825abd commit 38e127d

File tree

179 files changed

+5244
-2302
lines changed

Some content is hidden

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

179 files changed

+5244
-2302
lines changed

clang-tools-extra/clang-apply-replacements/include/clang-apply-replacements/Tooling/ApplyReplacements.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ std::error_code collectReplacementsFromDirectory(
8787
/// \li false If there were conflicts.
8888
bool mergeAndDeduplicate(const TUReplacements &TUs, const TUDiagnostics &TUDs,
8989
FileToChangesMap &FileChanges,
90-
clang::SourceManager &SM);
90+
clang::SourceManager &SM,
91+
bool IgnoreInsertConflict = false);
9192

9293
/// Apply \c AtomicChange on File and rewrite it.
9394
///

clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ groupReplacements(const TUReplacements &TUs, const TUDiagnostics &TUDs,
202202

203203
bool mergeAndDeduplicate(const TUReplacements &TUs, const TUDiagnostics &TUDs,
204204
FileToChangesMap &FileChanges,
205-
clang::SourceManager &SM) {
205+
clang::SourceManager &SM, bool IgnoreInsertConflict) {
206206
auto GroupedReplacements = groupReplacements(TUs, TUDs, SM);
207207
bool ConflictDetected = false;
208208

@@ -231,7 +231,24 @@ bool mergeAndDeduplicate(const TUReplacements &TUs, const TUDiagnostics &TUDs,
231231
// For now, printing directly the error reported by `AtomicChange` is
232232
// the easiest solution.
233233
errs() << llvm::toString(std::move(Err)) << "\n";
234-
ConflictDetected = true;
234+
if (IgnoreInsertConflict) {
235+
tooling::Replacements &Replacements = FileChange.getReplacements();
236+
unsigned NewOffset =
237+
Replacements.getShiftedCodePosition(R.getOffset());
238+
unsigned NewLength = Replacements.getShiftedCodePosition(
239+
R.getOffset() + R.getLength()) -
240+
NewOffset;
241+
if (NewLength == R.getLength()) {
242+
tooling::Replacement RR = tooling::Replacement(
243+
R.getFilePath(), NewOffset, NewLength, R.getReplacementText());
244+
Replacements = Replacements.merge(tooling::Replacements(RR));
245+
} else {
246+
llvm::errs()
247+
<< "Can't resolve conflict, skipping the replacement.\n";
248+
ConflictDetected = true;
249+
}
250+
} else
251+
ConflictDetected = true;
235252
}
236253
}
237254
FileChanges.try_emplace(Entry,

clang-tools-extra/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ static cl::opt<bool> RemoveTUReplacementFiles(
4242
"merging/replacing."),
4343
cl::init(false), cl::cat(ReplacementCategory));
4444

45+
static cl::opt<bool> IgnoreInsertConflict(
46+
"ignore-insert-conflict",
47+
cl::desc("Ignore insert conflict and keep running to fix."),
48+
cl::init(false), cl::cat(ReplacementCategory));
49+
4550
static cl::opt<bool> DoFormat(
4651
"format",
4752
cl::desc("Enable formatting of code changed by applying replacements.\n"
@@ -131,7 +136,7 @@ int main(int argc, char **argv) {
131136
SourceManager SM(Diagnostics, Files);
132137

133138
FileToChangesMap Changes;
134-
if (!mergeAndDeduplicate(TURs, TUDs, Changes, SM))
139+
if (!mergeAndDeduplicate(TURs, TUDs, Changes, SM, IgnoreInsertConflict))
135140
return 1;
136141

137142
tooling::ApplyChangesSpec Spec;

clang-tools-extra/clang-tidy/tool/run-clang-tidy.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ def find_binary(arg, name, build_path):
180180
def apply_fixes(args, clang_apply_replacements_binary, tmpdir):
181181
"""Calls clang-apply-fixes on a given directory."""
182182
invocation = [clang_apply_replacements_binary]
183+
invocation.append('-ignore-insert-conflict')
183184
if args.format:
184185
invocation.append('-format')
185186
if args.style:

clang-tools-extra/pseudo/lib/grammar/GrammarBNF.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,10 +270,6 @@ class GrammarBuilder {
270270
if (T.Rules[RID] == T.Rules[RID + 1])
271271
Diagnostics.push_back(
272272
llvm::formatv("Duplicate rule: `{0}`", G.dumpRule(RID)));
273-
// Warning for nullable nonterminals
274-
if (T.Rules[RID].Size == 0)
275-
Diagnostics.push_back(
276-
llvm::formatv("Rule `{0}` has a nullable RHS", G.dumpRule(RID)));
277273
}
278274
// symbol-id -> used counts
279275
std::vector<unsigned> UseCounts(T.Nonterminals.size(), 0);
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
MainSourceFile: ignore-conflict.cpp
3+
Diagnostics:
4+
- DiagnosticName: test-ignore-conflict-insertion
5+
DiagnosticMessage:
6+
Message: Fix
7+
FilePath: $(path)/ignore-conflict.cpp
8+
FileOffset: 0
9+
Replacements:
10+
- FilePath: $(path)/ignore-conflict.cpp
11+
Offset: 0
12+
Length: 0
13+
ReplacementText: "#include <a.h>\n"
14+
- DiagnosticName: test-ignore-conflict-insertion
15+
DiagnosticMessage:
16+
Message: Fix
17+
FilePath: $(path)/ignore-conflict.cpp
18+
FileOffset: 0
19+
Replacements:
20+
- FilePath: $(path)/ignore-conflict.cpp
21+
Offset: 0
22+
Length: 0
23+
ReplacementText: "#include <b.h>\n"
24+
...
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
class MyType {};
2+
// CHECK: #include <a.h>
3+
// CHECK-NEXT: #include <b.h>
4+
// CEHCK-NEXT: class MyType {};
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// RUN: mkdir -p %T/Inputs/ignore-conflict
2+
// RUN: grep -Ev "// *[A-Z-]+:" %S/Inputs/ignore-conflict/ignore-conflict.cpp > %T/Inputs/ignore-conflict/ignore-conflict.cpp
3+
// RUN: sed "s#\$(path)#%/T/Inputs/ignore-conflict#" %S/Inputs/ignore-conflict/file1.yaml > %T/Inputs/ignore-conflict/file1.yaml
4+
// RUN: clang-apply-replacements --ignore-insert-conflict %T/Inputs/ignore-conflict
5+
// RUN: FileCheck -input-file=%T/Inputs/ignore-conflict/ignore-conflict.cpp %S/Inputs/ignore-conflict/ignore-conflict.cpp

clang-tools-extra/test/pp-trace/pp-trace-modules.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: rm -rf %t
2-
// RUN: pp-trace -callbacks '*,-FileChanged,-MacroDefined' %s -- -x objective-c++ -undef -target x86_64 -std=c++11 -fmodules -fcxx-modules -fmodules-cache-path=%t -I%S -I%S/Input | FileCheck --strict-whitespace %s
2+
// RUN: pp-trace -callbacks '*,-FileChanged,-MacroDefined' %s -- -x objective-c++ -undef -target x86_64 -std=c++11 -fmodules -fmodules-cache-path=%t -I%S -I%S/Input | FileCheck --strict-whitespace %s
33

44
// CHECK: ---
55

clang/include/clang/Basic/DiagnosticSerializationKinds.td

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,12 +375,14 @@ def err_module_odr_violation_mismatch_decl_unknown : Error<
375375
"%q0 %select{with definition in module '%2'|defined here}1 has different "
376376
"definitions in different modules; first difference is this "
377377
"%select{||||static assert|field|method|type alias|typedef|data member|"
378-
"friend declaration|unexpected decl}3">;
378+
"friend declaration|function template|"
379+
"unexpected decl}3">;
379380
def note_module_odr_violation_mismatch_decl_unknown : Note<
380381
"but in '%0' found "
381382
"%select{||||different static assert|different field|different method|"
382383
"different type alias|different typedef|different data member|"
383-
"different friend declaration|another unexpected decl}1">;
384+
"different friend declaration|different function template|"
385+
"another unexpected decl}1">;
384386

385387
def warn_duplicate_module_file_extension : Warning<
386388
"duplicate module file extension block name '%0'">,

clang/include/clang/Driver/Options.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1421,7 +1421,7 @@ defm async_exceptions: BoolFOption<"async-exceptions",
14211421
PosFlag<SetTrue, [CC1Option], "Enable EH Asynchronous exceptions">, NegFlag<SetFalse>>;
14221422
defm cxx_modules : BoolFOption<"cxx-modules",
14231423
LangOpts<"CPlusPlusModules">, Default<cpp20.KeyPath>,
1424-
NegFlag<SetFalse, [CC1Option], "Disable">, PosFlag<SetTrue, [], "Enable">,
1424+
NegFlag<SetFalse, [CC1Option], "Disable">, PosFlag<SetTrue, [CC1Option], "Enable">,
14251425
BothFlags<[NoXarchOption], " modules for C++">>,
14261426
ShouldParseIf<cplusplus.KeyPath>;
14271427
def fdebug_pass_arguments : Flag<["-"], "fdebug-pass-arguments">, Group<f_Group>;

clang/include/clang/Tooling/Refactoring/AtomicChange.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ class AtomicChange {
116116
/// Returns a const reference to existing replacements.
117117
const Replacements &getReplacements() const { return Replaces; }
118118

119+
Replacements &getReplacements() { return Replaces; }
120+
119121
llvm::ArrayRef<std::string> getInsertedHeaders() const {
120122
return InsertedHeaders;
121123
}

clang/lib/CodeGen/CGStmtOpenMP.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6287,8 +6287,8 @@ static void emitOMPAtomicCompareExpr(CodeGenFunction &CGF,
62876287

62886288
llvm::OpenMPIRBuilder::AtomicOpValue XOpVal{
62896289
XAddr.getPointer(), XAddr.getElementType(),
6290-
X->getType().isVolatileQualified(),
6291-
X->getType()->hasSignedIntegerRepresentation()};
6290+
X->getType()->hasSignedIntegerRepresentation(),
6291+
X->getType().isVolatileQualified()};
62926292

62936293
CGF.Builder.restoreIP(OMPBuilder.createAtomicCompare(
62946294
CGF.Builder, XOpVal, EVal, DVal, AO, Op, IsXBinopExpr));

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3669,6 +3669,12 @@ static void RenderModulesOptions(Compilation &C, const Driver &D,
36693669
HaveModules = true;
36703670
}
36713671

3672+
if (Args.hasFlag(options::OPT_fcxx_modules, options::OPT_fno_cxx_modules,
3673+
false)) {
3674+
CmdArgs.push_back("-fcxx-modules");
3675+
HaveModules = true;
3676+
}
3677+
36723678
// -fmodule-maps enables implicit reading of module map files. By default,
36733679
// this is enabled if we are using Clang's flavor of precompiled modules.
36743680
if (Args.hasFlag(options::OPT_fimplicit_module_maps,

clang/lib/Headers/opencl-c-base.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
#if (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300)
6969
// For the SPIR and SPIR-V target all features are supported.
7070
#if defined(__SPIR__) || defined(__SPIRV__)
71+
#define __opencl_c_work_group_collective_functions 1
7172
#define __opencl_c_atomic_order_seq_cst 1
7273
#define __opencl_c_atomic_scope_device 1
7374
#define __opencl_c_atomic_scope_all_devices 1

clang/test/CXX/temp/temp.decls/temp.class.spec/p6.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,16 @@ namespace rdar8651930 {
7474
int array0[Outer<int>::Inner<int, int>::value? 1 : -1];
7575
int array1[Outer<int>::Inner<int, float>::value? -1 : 1];
7676
}
77+
78+
namespace print_dependent_TemplateSpecializationType {
79+
80+
template <class T, class U> struct Foo {
81+
template <unsigned long, class X, class Y> struct Bar;
82+
template <class Y> struct Bar<0, T, Y> {};
83+
// expected-note-re@-1 {{previous declaration {{.*}} 'Bar<0UL, int, type-parameter-0-0>' is here}}
84+
template <class Y> struct Bar<0, U, Y> {};
85+
// expected-error@-1 {{partial specialization 'Bar<0, int, Y>' cannot be redeclared}}
86+
};
87+
template struct Foo<int, int>; // expected-note {{requested here}}
88+
89+
} // namespace print_dependent_TemplateSpecializationType

clang/test/Driver/modules.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,14 @@ import "foo.h";
7373
// CHECK-HEADER-UNIT-USE: BAR;
7474
FOO;
7575
#endif
76+
77+
// Check the independent use of -fcxx-modules
78+
//
79+
// RUN: %clang -fcxx-modules -std=c++17 -### %s 2>&1 | FileCheck %s --check-prefix=CHECK-CXX17-MODULES
80+
// CHECK-CXX17-MODULES: "-fcxx-modules"
81+
// RUN: %clang -fcxx-modules -std=c++14 -### %s 2>&1 | FileCheck %s --check-prefix=CHECK-CXX14-MODULES
82+
// CHECK-CXX14-MODULES: "-fcxx-modules"
83+
// RUN: %clang -fcxx-modules -std=c++11 -### %s 2>&1 | FileCheck %s --check-prefix=CHECK-CXX11-MODULES
84+
// CHECK-CXX11-MODULES: "-fcxx-modules"
85+
// RUN: %clang -fcxx-modules -std=c++03 -### %s 2>&1 | FileCheck %s --check-prefix=CHECK-CXX03-MODULES
86+
// CHECK-CXX03-MODULES: "-fcxx-modules"

clang/test/Index/index-concept-kind.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: c-index-test -index-file %s -std=gnu++20 | FileCheck %s
2-
// UNSUPPORTED: aix
2+
33
template <typename T>
44
concept LargeType = sizeof(T) > 8;
55
// CHECK: [indexDeclaration]: kind: concept | name: LargeType | USR: c:@CT@LargeType | lang: C | cursor: ConceptDecl=LargeType:[[@LINE-1]]:9 (Definition) | loc: [[@LINE-1]]:9 | semantic-container: [TU] | lexical-container: [TU] | isRedecl: 0 | isDef: 1 | isContainer: 0 | isImplicit: 0

clang/test/Index/index-concepts.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: c-index-test -test-load-source all %s -std=gnu++20 -fno-delayed-template-parsing | FileCheck %s
2-
// UNSUPPORTED: aix
2+
33
template<class T>
44
struct type_trait {
55
const static bool value = false;

clang/test/Modules/cxx-modules.cppm

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// This tests that we could use C++20 modules standalone.
2+
// RUN: %clang -std=c++03 -fcxx-modules -fsyntax-only -Xclang -verify %s
3+
// RUN: %clang -std=c++11 -fcxx-modules -fsyntax-only -Xclang -verify %s
4+
// RUN: %clang -std=c++14 -fcxx-modules -fsyntax-only -Xclang -verify %s
5+
// RUN: %clang -std=c++17 -fcxx-modules -fsyntax-only -Xclang -verify %s
6+
// expected-no-diagnostics
7+
export module M;

0 commit comments

Comments
 (0)