Skip to content

Commit 4922d9e

Browse files
authored
Merge branch 'main' into alignas-order
2 parents d0df126 + 52b18b4 commit 4922d9e

Some content is hidden

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

48 files changed

+2027
-71
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,7 @@ Bug Fixes to C++ Support
681681
fixes crashes from follow-on processing of the invalid requirement. (#GH138820)
682682
- Fixed the handling of pack indexing types in the constraints of a member function redeclaration. (#GH138255)
683683
- Clang now correctly parses arbitrary order of ``[[]]``, ``__attribute__`` and ``alignas`` attributes for declarations (#GH133107)
684+
- Fixed a crash when forming an invalid function type in a dependent context. (#GH138657) (#GH115725) (#GH68852)
684685

685686
Bug Fixes to AST Handling
686687
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/include/clang/Basic/CodeGenOptions.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,9 @@ CODEGENOPT(StaticClosure, 1, 0)
483483
/// Assume that UAVs/SRVs may alias
484484
CODEGENOPT(ResMayAlias, 1, 0)
485485

486+
/// Enables unwind v2 (epilog) information for x64 Windows.
487+
CODEGENOPT(WinX64EHUnwindV2, 1, 0)
488+
486489
/// FIXME: Make DebugOptions its own top-level .def file.
487490
#include "DebugOptions.def"
488491

clang/include/clang/Driver/Options.td

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2167,6 +2167,11 @@ defm assume_nothrow_exception_dtor: BoolFOption<"assume-nothrow-exception-dtor",
21672167
LangOpts<"AssumeNothrowExceptionDtor">, DefaultFalse,
21682168
PosFlag<SetTrue, [], [ClangOption, CC1Option], "Assume that exception objects' destructors are non-throwing">,
21692169
NegFlag<SetFalse>>;
2170+
defm winx64_eh_unwindv2 : BoolFOption<"winx64-eh-unwindv2",
2171+
CodeGenOpts<"WinX64EHUnwindV2">, DefaultFalse,
2172+
PosFlag<SetTrue, [], [ClangOption, CC1Option], "Enable">,
2173+
NegFlag<SetFalse, [], [ClangOption], "Disable">,
2174+
BothFlags<[], [ClangOption], " unwind v2 (epilog) information for x64 Windows">>;
21702175
def fexcess_precision_EQ : Joined<["-"], "fexcess-precision=">, Group<f_Group>,
21712176
Visibility<[ClangOption, CLOption]>,
21722177
HelpText<"Allows control over excess precision on targets where native "
@@ -8947,6 +8952,8 @@ def _SLASH_M_Group : OptionGroup<"</M group>">, Group<cl_compile_Group>;
89478952
def _SLASH_volatile_Group : OptionGroup<"</volatile group>">,
89488953
Group<cl_compile_Group>;
89498954

8955+
def _SLASH_d2epilogunwind : CLFlag<"d2epilogunwind">,
8956+
HelpText<"Enable unwind v2 (epilog) information for x64 Windows">;
89508957
def _SLASH_EH : CLJoined<"EH">, HelpText<"Set exception handling model">;
89518958
def _SLASH_EP : CLFlag<"EP">,
89528959
HelpText<"Disable linemarker output and preprocess to stdout">;

clang/include/clang/Parse/ParseHLSLRootSignature.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ class RootSignatureParser {
8282
struct ParsedConstantParams {
8383
std::optional<llvm::hlsl::rootsig::Register> Reg;
8484
std::optional<uint32_t> Num32BitConstants;
85+
std::optional<uint32_t> Space;
86+
std::optional<llvm::hlsl::rootsig::ShaderVisibility> Visibility;
8587
};
8688
std::optional<ParsedConstantParams> parseRootConstantParams();
8789

clang/include/clang/Sema/Sema.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10240,8 +10240,13 @@ class Sema final : public SemaBase {
1024010240
/// Determine whether the conversion from FromType to ToType is a valid
1024110241
/// conversion that strips "noexcept" or "noreturn" off the nested function
1024210242
/// type.
10243-
bool IsFunctionConversion(QualType FromType, QualType ToType,
10244-
QualType &ResultTy);
10243+
bool IsFunctionConversion(QualType FromType, QualType ToType) const;
10244+
10245+
/// Same as `IsFunctionConversion`, but if this would return true, it sets
10246+
/// `ResultTy` to `ToType`.
10247+
bool TryFunctionConversion(QualType FromType, QualType ToType,
10248+
QualType &ResultTy) const;
10249+
1024510250
bool DiagnoseMultipleUserDefinedConversion(Expr *From, QualType ToType);
1024610251
void DiagnoseUseOfDeletedFunction(SourceLocation Loc, SourceRange Range,
1024710252
DeclarationName Name,

clang/lib/CIR/CodeGen/CIRGenOpenACCClause.h

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -385,19 +385,23 @@ class OpenACCClauseCIREmitter final
385385
void VisitAutoClause(const OpenACCAutoClause &clause) {
386386
if constexpr (isOneOfTypes<OpTy, mlir::acc::LoopOp>) {
387387
operation.addAuto(builder.getContext(), lastDeviceTypeValues);
388+
} else if constexpr (isCombinedType<OpTy>) {
389+
applyToLoopOp(clause);
388390
} else {
389391
// TODO: When we've implemented this for everything, switch this to an
390-
// unreachable. Routine, Combined constructs remain.
392+
// unreachable. Routine, construct remains.
391393
return clauseNotImplemented(clause);
392394
}
393395
}
394396

395397
void VisitIndependentClause(const OpenACCIndependentClause &clause) {
396398
if constexpr (isOneOfTypes<OpTy, mlir::acc::LoopOp>) {
397399
operation.addIndependent(builder.getContext(), lastDeviceTypeValues);
400+
} else if constexpr (isCombinedType<OpTy>) {
401+
applyToLoopOp(clause);
398402
} else {
399403
// TODO: When we've implemented this for everything, switch this to an
400-
// unreachable. Routine, Combined constructs remain.
404+
// unreachable. Routine construct remains.
401405
return clauseNotImplemented(clause);
402406
}
403407
}
@@ -410,10 +414,10 @@ class OpenACCClauseCIREmitter final
410414
value = value.sextOrTrunc(64);
411415
operation.setCollapseForDeviceTypes(builder.getContext(),
412416
lastDeviceTypeValues, value);
417+
} else if constexpr (isCombinedType<OpTy>) {
418+
applyToLoopOp(clause);
413419
} else {
414-
// TODO: When we've implemented this for everything, switch this to an
415-
// unreachable. Combined constructs remain.
416-
return clauseNotImplemented(clause);
420+
llvm_unreachable("Unknown construct kind in VisitCollapseClause");
417421
}
418422
}
419423

clang/lib/CodeGen/CodeGenModule.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1307,6 +1307,10 @@ void CodeGenModule::Release() {
13071307
getModule().addModuleFlag(llvm::Module::Warning, "import-call-optimization",
13081308
1);
13091309

1310+
// Enable unwind v2 (epilog).
1311+
if (CodeGenOpts.WinX64EHUnwindV2)
1312+
getModule().addModuleFlag(llvm::Module::Warning, "winx64-eh-unwindv2", 1);
1313+
13101314
// Indicate whether this Module was compiled with -fopenmp
13111315
if (getLangOpts().OpenMP && !getLangOpts().OpenMPSimd)
13121316
getModule().addModuleFlag(llvm::Module::Max, "openmp", LangOpts.OpenMP);

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7504,6 +7504,10 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
75047504
}
75057505
}
75067506

7507+
// Unwind v2 (epilog) information for x64 Windows.
7508+
Args.addOptInFlag(CmdArgs, options::OPT_fwinx64_eh_unwindv2,
7509+
options::OPT_fno_winx64_eh_unwindv2);
7510+
75077511
// C++ "sane" operator new.
75087512
Args.addOptOutFlag(CmdArgs, options::OPT_fassume_sane_operator_new,
75097513
options::OPT_fno_assume_sane_operator_new);
@@ -8549,6 +8553,10 @@ void Clang::AddClangCLArgs(const ArgList &Args, types::ID InputType,
85498553
if (Args.hasArg(options::OPT__SLASH_kernel))
85508554
CmdArgs.push_back("-fms-kernel");
85518555

8556+
// Unwind v2 (epilog) information for x64 Windows.
8557+
if (Args.hasArg(options::OPT__SLASH_d2epilogunwind))
8558+
CmdArgs.push_back("-fwinx64-eh-unwindv2");
8559+
85528560
for (const Arg *A : Args.filtered(options::OPT__SLASH_guard)) {
85538561
StringRef GuardArgs = A->getValue();
85548562
// The only valid options are "cf", "cf,nochecks", "cf-", "ehcont" and

clang/lib/Parse/ParseHLSLRootSignature.cpp

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ std::optional<RootConstants> RootSignatureParser::parseRootConstants() {
7878

7979
Constants.Reg = Params->Reg.value();
8080

81+
// Fill in optional parameters
82+
if (Params->Visibility.has_value())
83+
Constants.Visibility = Params->Visibility.value();
84+
85+
if (Params->Space.has_value())
86+
Constants.Space = Params->Space.value();
87+
8188
if (consumeExpectedToken(TokenKind::pu_r_paren,
8289
diag::err_hlsl_unexpected_end_of_params,
8390
/*param of=*/TokenKind::kw_RootConstants))
@@ -247,6 +254,40 @@ RootSignatureParser::parseRootConstantParams() {
247254
return std::nullopt;
248255
Params.Reg = Reg;
249256
}
257+
258+
// `space` `=` POS_INT
259+
if (tryConsumeExpectedToken(TokenKind::kw_space)) {
260+
if (Params.Space.has_value()) {
261+
getDiags().Report(CurToken.TokLoc, diag::err_hlsl_rootsig_repeat_param)
262+
<< CurToken.TokKind;
263+
return std::nullopt;
264+
}
265+
266+
if (consumeExpectedToken(TokenKind::pu_equal))
267+
return std::nullopt;
268+
269+
auto Space = parseUIntParam();
270+
if (!Space.has_value())
271+
return std::nullopt;
272+
Params.Space = Space;
273+
}
274+
275+
// `visibility` `=` SHADER_VISIBILITY
276+
if (tryConsumeExpectedToken(TokenKind::kw_visibility)) {
277+
if (Params.Visibility.has_value()) {
278+
getDiags().Report(CurToken.TokLoc, diag::err_hlsl_rootsig_repeat_param)
279+
<< CurToken.TokKind;
280+
return std::nullopt;
281+
}
282+
283+
if (consumeExpectedToken(TokenKind::pu_equal))
284+
return std::nullopt;
285+
286+
auto Visibility = parseShaderVisibility();
287+
if (!Visibility.has_value())
288+
return std::nullopt;
289+
Params.Visibility = Visibility;
290+
}
250291
} while (tryConsumeExpectedToken(TokenKind::pu_comma));
251292

252293
return Params;

clang/lib/Sema/SemaExceptionSpec.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -700,12 +700,11 @@ bool Sema::handlerCanCatch(QualType HandlerType, QualType ExceptionType) {
700700
// -- a qualification conversion
701701
// -- a function pointer conversion
702702
bool LifetimeConv;
703-
QualType Result;
704703
// FIXME: Should we treat the exception as catchable if a lifetime
705704
// conversion is required?
706705
if (IsQualificationConversion(ExceptionType, HandlerType, false,
707706
LifetimeConv) ||
708-
IsFunctionConversion(ExceptionType, HandlerType, Result))
707+
IsFunctionConversion(ExceptionType, HandlerType))
709708
return true;
710709

711710
// -- a standard pointer conversion [...]

0 commit comments

Comments
 (0)