Skip to content

Commit a6f3951

Browse files
Merged main:93d2e49b6aa6904620a7e9b559c04ec8756dc596 into amd-gfx:7792c2d62d39
Local branch amd-gfx 7792c2d Merged main:c49965b97e159b7ff92a5fca3e144b2d2574a84d into amd-gfx:75d03f4f8f7e Remote branch main 93d2e49 Fix file index verifier when there is no file name in the prologue. (llvm#77004)
2 parents 7792c2d + 93d2e49 commit a6f3951

File tree

28 files changed

+1347
-268
lines changed

28 files changed

+1347
-268
lines changed

clang/include/clang/Basic/DiagnosticParseKinds.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,6 +1364,8 @@ def err_acc_invalid_clause : Error<"invalid OpenACC clause %0">;
13641364
def err_acc_missing_directive : Error<"expected OpenACC directive">;
13651365
def err_acc_invalid_open_paren
13661366
: Error<"expected clause-list or newline in OpenACC directive">;
1367+
def err_acc_invalid_default_clause_kind
1368+
: Error<"invalid value for 'default' clause; expected 'present' or 'none'">;
13671369

13681370
// OpenMP support.
13691371
def warn_pragma_omp_ignored : Warning<

clang/include/clang/Basic/OpenACCKinds.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,21 @@ enum class OpenACCClauseKind {
9090
Vector,
9191
/// 'nohost' clause, allowed on 'routine' directives.
9292
NoHost,
93+
/// 'default' clause, allowed on parallel, serial, kernel (and compound)
94+
/// constructs.
95+
Default,
9396
/// Represents an invalid clause, for the purposes of parsing.
9497
Invalid,
9598
};
99+
100+
enum class OpenACCDefaultClauseKind {
101+
/// 'none' option.
102+
None,
103+
/// 'present' option.
104+
Present,
105+
/// Not a valid option.
106+
Invalid,
107+
};
96108
} // namespace clang
97109

98110
#endif // LLVM_CLANG_BASIC_OPENACCKINDS_H

clang/lib/Parse/ParseOpenACC.cpp

Lines changed: 79 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,17 @@ OpenACCClauseKind getOpenACCClauseKind(Token Tok) {
7676
if (Tok.is(tok::kw_auto))
7777
return OpenACCClauseKind::Auto;
7878

79+
// default is a keyword, so make sure we parse it correctly.
80+
if (Tok.is(tok::kw_default))
81+
return OpenACCClauseKind::Default;
82+
7983
if (!Tok.is(tok::identifier))
8084
return OpenACCClauseKind::Invalid;
8185

8286
return llvm::StringSwitch<OpenACCClauseKind>(
8387
Tok.getIdentifierInfo()->getName())
8488
.Case("auto", OpenACCClauseKind::Auto)
89+
.Case("default", OpenACCClauseKind::Default)
8590
.Case("finalize", OpenACCClauseKind::Finalize)
8691
.Case("if_present", OpenACCClauseKind::IfPresent)
8792
.Case("independent", OpenACCClauseKind::Independent)
@@ -106,6 +111,17 @@ OpenACCAtomicKind getOpenACCAtomicKind(Token Tok) {
106111
.Default(OpenACCAtomicKind::Invalid);
107112
}
108113

114+
OpenACCDefaultClauseKind getOpenACCDefaultClauseKind(Token Tok) {
115+
if (!Tok.is(tok::identifier))
116+
return OpenACCDefaultClauseKind::Invalid;
117+
118+
return llvm::StringSwitch<OpenACCDefaultClauseKind>(
119+
Tok.getIdentifierInfo()->getName())
120+
.Case("none", OpenACCDefaultClauseKind::None)
121+
.Case("present", OpenACCDefaultClauseKind::Present)
122+
.Default(OpenACCDefaultClauseKind::Invalid);
123+
}
124+
109125
enum class OpenACCSpecialTokenKind {
110126
ReadOnly,
111127
DevNum,
@@ -176,6 +192,22 @@ bool isOpenACCDirectiveKind(OpenACCDirectiveKind Kind, Token Tok) {
176192
llvm_unreachable("Unknown 'Kind' Passed");
177193
}
178194

195+
/// Used for cases where we expect an identifier-like token, but don't want to
196+
/// give awkward error messages in cases where it is accidentially a keyword.
197+
bool expectIdentifierOrKeyword(Parser &P) {
198+
Token Tok = P.getCurToken();
199+
200+
if (Tok.is(tok::identifier))
201+
return false;
202+
203+
if (!Tok.isAnnotation() && Tok.getIdentifierInfo() &&
204+
Tok.getIdentifierInfo()->isKeyword(P.getLangOpts()))
205+
return false;
206+
207+
P.Diag(P.getCurToken(), diag::err_expected) << tok::identifier;
208+
return true;
209+
}
210+
179211
OpenACCDirectiveKind
180212
ParseOpenACCEnterExitDataDirective(Parser &P, Token FirstTok,
181213
OpenACCDirectiveKindEx ExtDirKind) {
@@ -291,13 +323,56 @@ OpenACCDirectiveKind ParseOpenACCDirectiveKind(Parser &P) {
291323
return DirKind;
292324
}
293325

326+
bool ClauseHasRequiredParens(OpenACCClauseKind Kind) {
327+
return Kind == OpenACCClauseKind::Default;
328+
}
329+
330+
bool ParseOpenACCClauseParams(Parser &P, OpenACCClauseKind Kind) {
331+
BalancedDelimiterTracker Parens(P, tok::l_paren,
332+
tok::annot_pragma_openacc_end);
333+
334+
if (ClauseHasRequiredParens(Kind)) {
335+
if (Parens.expectAndConsume()) {
336+
// We are missing a paren, so assume that the person just forgot the
337+
// parameter. Return 'false' so we try to continue on and parse the next
338+
// clause.
339+
P.SkipUntil(tok::comma, tok::r_paren, tok::annot_pragma_openacc_end,
340+
Parser::StopBeforeMatch);
341+
return false;
342+
}
343+
344+
switch (Kind) {
345+
case OpenACCClauseKind::Default: {
346+
Token DefKindTok = P.getCurToken();
347+
348+
if (expectIdentifierOrKeyword(P))
349+
break;
350+
351+
P.ConsumeToken();
352+
353+
if (getOpenACCDefaultClauseKind(DefKindTok) ==
354+
OpenACCDefaultClauseKind::Invalid)
355+
P.Diag(DefKindTok, diag::err_acc_invalid_default_clause_kind);
356+
357+
break;
358+
}
359+
default:
360+
llvm_unreachable("Not a required parens type?");
361+
}
362+
363+
return Parens.consumeClose();
364+
}
365+
// FIXME: Handle optional parens
366+
return false;
367+
}
368+
294369
// The OpenACC Clause List is a comma or space-delimited list of clauses (see
295370
// the comment on ParseOpenACCClauseList). The concept of a 'clause' doesn't
296371
// really have its owner grammar and each individual one has its own definition.
297-
// However, they all are named with a single-identifier (or auto!) token,
298-
// followed in some cases by either braces or parens.
372+
// However, they all are named with a single-identifier (or auto/default!)
373+
// token, followed in some cases by either braces or parens.
299374
bool ParseOpenACCClause(Parser &P) {
300-
if (!P.getCurToken().isOneOf(tok::identifier, tok::kw_auto))
375+
if (!P.getCurToken().isOneOf(tok::identifier, tok::kw_auto, tok::kw_default))
301376
return P.Diag(P.getCurToken(), diag::err_expected) << tok::identifier;
302377

303378
OpenACCClauseKind Kind = getOpenACCClauseKind(P.getCurToken());
@@ -309,8 +384,7 @@ bool ParseOpenACCClause(Parser &P) {
309384
// Consume the clause name.
310385
P.ConsumeToken();
311386

312-
// FIXME: For future clauses, we need to handle parens/etc below.
313-
return false;
387+
return ParseOpenACCClauseParams(P, Kind);
314388
}
315389

316390
// Skip until we see the end of pragma token, but don't consume it. This is us

clang/lib/Sema/SemaInit.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5512,6 +5512,14 @@ static void TryOrBuildParenListInitialization(
55125512
} else if (auto *RT = Entity.getType()->getAs<RecordType>()) {
55135513
bool IsUnion = RT->isUnionType();
55145514
const CXXRecordDecl *RD = cast<CXXRecordDecl>(RT->getDecl());
5515+
if (RD->isInvalidDecl()) {
5516+
// Exit early to avoid confusion when processing members.
5517+
// We do the same for braced list initialization in
5518+
// `CheckStructUnionTypes`.
5519+
Sequence.SetFailed(
5520+
clang::InitializationSequence::FK_ParenthesizedListInitFailed);
5521+
return;
5522+
}
55155523

55165524
if (!IsUnion) {
55175525
for (const CXXBaseSpecifier &Base : RD->bases()) {

clang/test/ParserOpenACC/parse-clauses.c

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,102 @@ void func() {
5454
// expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
5555
#pragma acc loop seq,
5656

57+
}
58+
59+
void DefaultClause() {
60+
// expected-error@+2{{expected '('}}
61+
// expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
62+
#pragma acc serial loop default
63+
for(;;){}
64+
65+
// expected-error@+2{{expected '('}}
66+
// expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
67+
#pragma acc serial default seq
68+
for(;;){}
69+
70+
// expected-error@+2{{expected '('}}
71+
// expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
72+
#pragma acc serial default, seq
73+
for(;;){}
74+
75+
// expected-error@+4{{expected identifier}}
76+
// expected-error@+3{{expected ')'}}
77+
// expected-note@+2{{to match this '('}}
78+
// expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
79+
#pragma acc serial default(
80+
for(;;){}
81+
82+
// expected-error@+4{{invalid value for 'default' clause; expected 'present' or 'none'}}
83+
// expected-error@+3{{expected ')'}}
84+
// expected-note@+2{{to match this '('}}
85+
// expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
86+
#pragma acc serial default( seq
87+
for(;;){}
88+
89+
// expected-error@+4{{expected identifier}}
90+
// expected-error@+3{{expected ')'}}
91+
// expected-note@+2{{to match this '('}}
92+
// expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
93+
#pragma acc serial default(, seq
94+
for(;;){}
95+
96+
// expected-error@+3{{expected '('}}
97+
// expected-error@+2{{expected identifier}}
98+
// expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
99+
#pragma acc serial default)
100+
for(;;){}
101+
102+
// expected-error@+3{{expected '('}}
103+
// expected-error@+2{{expected identifier}}
104+
// expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
105+
#pragma acc serial default) seq
106+
for(;;){}
107+
108+
// expected-error@+3{{expected '('}}
109+
// expected-error@+2{{expected identifier}}
110+
// expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
111+
#pragma acc serial default), seq
112+
for(;;){}
113+
114+
// expected-error@+2{{expected identifier}}
115+
// expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
116+
#pragma acc serial default()
117+
for(;;){}
118+
119+
// expected-error@+2{{expected identifier}}
120+
// expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
121+
#pragma acc serial default() seq
122+
for(;;){}
123+
124+
// expected-error@+2{{expected identifier}}
125+
// expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
126+
#pragma acc serial default(), seq
127+
for(;;){}
128+
129+
// expected-error@+2{{invalid value for 'default' clause; expected 'present' or 'none'}}
130+
// expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
131+
#pragma acc serial default(invalid)
132+
for(;;){}
133+
134+
// expected-error@+2{{invalid value for 'default' clause; expected 'present' or 'none'}}
135+
// expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
136+
#pragma acc serial default(auto) seq
137+
for(;;){}
138+
139+
// expected-error@+2{{invalid value for 'default' clause; expected 'present' or 'none'}}
140+
// expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
141+
#pragma acc serial default(invalid), seq
142+
for(;;){}
143+
144+
// expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
145+
#pragma acc serial default(none)
146+
for(;;){}
147+
148+
// expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}
149+
#pragma acc serial default(present), seq
150+
for(;;){}
151+
152+
57153
}
58154

59155
// expected-warning@+1{{OpenACC directives not yet implemented, pragma ignored}}

clang/test/SemaCXX/crash-GH76228.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// RUN: %clang_cc1 -std=c++20 -verify %s
2+
// Check we don't crash on incomplete members and bases when handling parenthesized initialization.
3+
class incomplete; // expected-note@-0 3 {{forward declaration of 'incomplete'}}
4+
struct foo {
5+
int a;
6+
incomplete b;
7+
// expected-error@-1 {{incomplete type}}
8+
};
9+
foo a1(0);
10+
11+
struct one_int {
12+
int a;
13+
};
14+
struct bar : one_int, incomplete {};
15+
// expected-error@-1 {{incomplete type}}
16+
bar a2(0);
17+
18+
incomplete a3[3](1,2,3);
19+
// expected-error@-1 {{incomplete type}}
20+
21+
struct qux : foo {
22+
};
23+
qux a4(0);
24+
25+
struct fred {
26+
foo a[3];
27+
};
28+
fred a5(0);

clang/test/SemaCXX/paren-list-agg-init.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ int test() {
289289
// used to crash
290290
S a(0, 1);
291291
S b(0);
292-
S c(0, 0, 1); // beforecxx20-warning {{aggregate initialization of type 'S' from a parenthesized list of values is a C++20 extension}}
292+
S c(0, 0, 1);
293293

294294
S d {0, 1};
295295
S e {0};

libcxx/test/libcxx/utilities/expected/expected.expected/transform_error.mandates.verify.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9+
// https://github.com/llvm/llvm-project/pull/76232 breaks this libc++ test.
10+
// The fix would be to update this file. The issue is that the CI uses 2
11+
// versions of Clang-18
12+
// - An older nightly build as the main compiler
13+
// - A freshly bootstrap build
14+
// This means the test can't be used until the nightly build is updated.
15+
// TODO(mordante) Reenable clang-18.
16+
// UNSUPPORTED: clang-18
17+
918
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
1019

1120
// Test the mandates

libcxx/test/libcxx/utilities/expected/expected.void/transform_error.mandates.verify.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9+
// https://github.com/llvm/llvm-project/pull/76232 breaks this libc++ test.
10+
// The fix would be to update this file. The issue is that the CI uses 2
11+
// versions of Clang-18
12+
// - An older nightly build as the main compiler
13+
// - A freshly bootstrap build
14+
// This means the test can't be used until the nightly build is updated.
15+
// TODO(mordante) Reenable clang-18.
16+
// UNSUPPORTED: clang-18
17+
918
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
1019

1120
// Test the mandates

lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2150,6 +2150,7 @@ bool DWARFASTParserClang::CompleteRecordType(const DWARFDIE &die,
21502150
SymbolFileDWARF *dwarf = die.GetDWARF();
21512151

21522152
ClangASTImporter::LayoutInfo layout_info;
2153+
std::vector<DWARFDIE> contained_type_dies;
21532154

21542155
if (die.HasChildren()) {
21552156
const bool type_is_objc_object_or_interface =
@@ -2175,7 +2176,8 @@ bool DWARFASTParserClang::CompleteRecordType(const DWARFDIE &die,
21752176

21762177
DelayedPropertyList delayed_properties;
21772178
ParseChildMembers(die, clang_type, bases, member_function_dies,
2178-
delayed_properties, default_accessibility, layout_info);
2179+
contained_type_dies, delayed_properties,
2180+
default_accessibility, layout_info);
21792181

21802182
// Now parse any methods if there were any...
21812183
for (const DWARFDIE &die : member_function_dies)
@@ -2231,6 +2233,12 @@ bool DWARFASTParserClang::CompleteRecordType(const DWARFDIE &die,
22312233
if (record_decl)
22322234
GetClangASTImporter().SetRecordLayout(record_decl, layout_info);
22332235
}
2236+
// Now parse all contained types inside of the class. We make forward
2237+
// declarations to all classes, but we need the CXXRecordDecl to have decls
2238+
// for all contained types because we don't get asked for them via the
2239+
// external AST support.
2240+
for (const DWARFDIE &die : contained_type_dies)
2241+
dwarf->ResolveType(die);
22342242

22352243
return (bool)clang_type;
22362244
}
@@ -3110,6 +3118,7 @@ bool DWARFASTParserClang::ParseChildMembers(
31103118
const DWARFDIE &parent_die, CompilerType &class_clang_type,
31113119
std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> &base_classes,
31123120
std::vector<DWARFDIE> &member_function_dies,
3121+
std::vector<DWARFDIE> &contained_type_dies,
31133122
DelayedPropertyList &delayed_properties,
31143123
const AccessType default_accessibility,
31153124
ClangASTImporter::LayoutInfo &layout_info) {
@@ -3159,6 +3168,8 @@ bool DWARFASTParserClang::ParseChildMembers(
31593168
break;
31603169

31613170
default:
3171+
if (llvm::dwarf::isType(tag))
3172+
contained_type_dies.push_back(die);
31623173
break;
31633174
}
31643175
}

0 commit comments

Comments
 (0)