Skip to content

Commit 1694792

Browse files
authored
Merge branch 'llvm:main' into gh-101657
2 parents f6ba504 + 58fc4b1 commit 1694792

File tree

86 files changed

+3231
-780
lines changed

Some content is hidden

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

86 files changed

+3231
-780
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ Bug Fixes to C++ Support
294294
direct-list-initialized from an array is corrected to direct-initialization.
295295
- Clang no longer crashes when a coroutine is declared ``[[noreturn]]``. (#GH127327)
296296
- Clang now uses the parameter location for abbreviated function templates in ``extern "C"``. (#GH46386)
297+
- Clang now correctly parses ``if constexpr`` expressions in immediate function context. (#GH123524)
297298

298299
Improvements to C++ diagnostics
299300
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

clang/docs/analyzer/checkers.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3522,6 +3522,18 @@ Raw pointers and references to an object which supports CheckedPtr or CheckedRef
35223522
35233523
See `WebKit Guidelines for Safer C++ Programming <https://github.com/WebKit/WebKit/wiki/Safer-CPP-Guidelines>`_ for details.
35243524
3525+
alpha.webkit.UnretainedLambdaCapturesChecker
3526+
""""""""""""""""""""""""""""""""""""""""""""
3527+
Raw pointers and references to NS or CF types can't be captured in lambdas. Only RetainPtr is allowed for CF types regardless of whether ARC is enabled or disabled, and only RetainPtr is allowed for NS types when ARC is disabled.
3528+
3529+
.. code-block:: cpp
3530+
3531+
void foo(NSObject *a, NSObject *b) {
3532+
[&, a](){ // warn about 'a'
3533+
do_something(b); // warn about 'b'
3534+
};
3535+
};
3536+
35253537
.. _alpha-webkit-UncountedCallArgsChecker:
35263538
35273539
alpha.webkit.UncountedCallArgsChecker

clang/include/clang/Basic/DiagnosticParseKinds.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1817,5 +1817,9 @@ def ext_hlsl_access_specifiers : ExtWarn<
18171817
InGroup<HLSLExtension>;
18181818
def err_hlsl_unsupported_component : Error<"invalid component '%0' used; expected 'x', 'y', 'z', or 'w'">;
18191819
def err_hlsl_packoffset_invalid_reg : Error<"invalid resource class specifier '%0' for packoffset, expected 'c'">;
1820+
def err_hlsl_virtual_function
1821+
: Error<"virtual functions are unsupported in HLSL">;
1822+
def err_hlsl_virtual_inheritance
1823+
: Error<"virtual inheritance is unsupported in HLSL">;
18201824

18211825
} // end of Parser diagnostics

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12707,6 +12707,10 @@ def err_hlsl_param_qualifier_mismatch :
1270712707
def err_hlsl_vector_compound_assignment_truncation : Error<
1270812708
"left hand operand of type %0 to compound assignment cannot be truncated "
1270912709
"when used with right hand operand of type %1">;
12710+
def err_hlsl_builtin_scalar_vector_mismatch
12711+
: Error<
12712+
"%select{all|second and third}0 arguments to %1 must be of scalar or "
12713+
"vector type with matching scalar element type%diff{: $ vs $|}2,3">;
1271012714

1271112715
def warn_hlsl_impcast_vector_truncation : Warning<
1271212716
"implicit conversion truncates vector: %0 to %1">, InGroup<Conversion>;

clang/include/clang/Basic/LangOptions.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ VALUE_LANGOPT(FuchsiaAPILevel, 32, 0, "Fuchsia API level")
515515
// on large _BitInts.
516516
BENIGN_VALUE_LANGOPT(MaxBitIntWidth, 32, 128, "Maximum width of a _BitInt")
517517

518-
COMPATIBLE_LANGOPT(IncrementalExtensions, 1, 0, " True if we want to process statements"
518+
COMPATIBLE_LANGOPT(IncrementalExtensions, 1, 0, "True if we want to process statements "
519519
"on the global scope, ignore EOF token and continue later on (thus "
520520
"avoid tearing the Lexer and etc. down). Controlled by "
521521
"-fincremental-extensions.")

clang/include/clang/Driver/Options.td

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -876,7 +876,7 @@ def Wa_COMMA : CommaJoined<["-"], "Wa,">,
876876
MetaVarName<"<arg>">;
877877
def warning_suppression_mappings_EQ : Joined<["--"],
878878
"warning-suppression-mappings=">, Group<Diag_Group>,
879-
HelpText<"File containing diagnostic suppresion mappings. See user manual "
879+
HelpText<"File containing diagnostic suppression mappings. See user manual "
880880
"for file format.">, Visibility<[ClangOption, CC1Option]>;
881881
def Wall : Flag<["-"], "Wall">, Group<W_Group>, Flags<[HelpHidden]>,
882882
Visibility<[ClangOption, CC1Option, FlangOption]>;
@@ -941,7 +941,7 @@ def Xarch__
941941
target matches the specified architecture. This can be used with the target
942942
CPU, triple architecture, or offloading host and device. It is most useful
943943
for separating behavior undesirable on one of the targets when combining many
944-
compilation jobs, as is commong with offloading. For example, -Xarch_x86_64,
944+
compilation jobs, as is common with offloading. For example, -Xarch_x86_64,
945945
-Xarch_gfx90a, and -Xarch_device are all valid selectors. -Xarch_device will
946946
forward the argument to the offloading device while -Xarch_host will target
947947
the host system, which can be used to suppress incompatible GPU arguments.}]>,
@@ -1678,7 +1678,7 @@ def fsample_profile_use_profi : Flag<["-"], "fsample-profile-use-profi">,
16781678
HelpText<"Use profi to infer block and edge counts">,
16791679
DocBrief<[{Infer block and edge counts. If the profiles have errors or missing
16801680
blocks caused by sampling, profile inference (profi) can convert
1681-
basic block counts to branch probabilites to fix them by extended
1681+
basic block counts to branch probabilities to fix them by extended
16821682
and re-engineered classic MCMF (min-cost max-flow) approach.}]>;
16831683
def fno_profile_sample_accurate : Flag<["-"], "fno-profile-sample-accurate">, Group<f_Group>;
16841684
def fno_auto_profile : Flag<["-"], "fno-auto-profile">, Group<f_Group>,

clang/include/clang/StaticAnalyzer/Checkers/Checkers.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1765,6 +1765,10 @@ def NoUncheckedPtrMemberChecker : Checker<"NoUncheckedPtrMemberChecker">,
17651765
HelpText<"Check for no unchecked member variables.">,
17661766
Documentation<HasDocumentation>;
17671767

1768+
def UnretainedLambdaCapturesChecker : Checker<"UnretainedLambdaCapturesChecker">,
1769+
HelpText<"Check unretained lambda captures.">,
1770+
Documentation<HasDocumentation>;
1771+
17681772
def UncountedCallArgsChecker : Checker<"UncountedCallArgsChecker">,
17691773
HelpText<"Check uncounted call arguments.">,
17701774
Documentation<HasDocumentation>;

clang/lib/AST/ExprConstant.cpp

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2419,6 +2419,16 @@ static bool CheckLValueConstantExpression(EvalInfo &Info, SourceLocation Loc,
24192419
LVal.getLValueCallIndex() == 0) &&
24202420
"have call index for global lvalue");
24212421

2422+
if (LVal.allowConstexprUnknown()) {
2423+
if (BaseVD) {
2424+
Info.FFDiag(Loc, diag::note_constexpr_var_init_non_constant, 1) << BaseVD;
2425+
NoteLValueLocation(Info, Base);
2426+
} else {
2427+
Info.FFDiag(Loc);
2428+
}
2429+
return false;
2430+
}
2431+
24222432
if (Base.is<DynamicAllocLValue>()) {
24232433
Info.FFDiag(Loc, diag::note_constexpr_dynamic_alloc)
24242434
<< IsReferenceType << !Designator.Entries.empty();
@@ -3597,7 +3607,8 @@ static bool evaluateVarDeclInit(EvalInfo &Info, const Expr *E,
35973607
// expressions here; doing so would regress diagnostics for things like
35983608
// reading from a volatile constexpr variable.
35993609
if ((Info.getLangOpts().CPlusPlus && !VD->hasConstantInitialization() &&
3600-
VD->mightBeUsableInConstantExpressions(Info.Ctx)) ||
3610+
VD->mightBeUsableInConstantExpressions(Info.Ctx) &&
3611+
!AllowConstexprUnknown) ||
36013612
((Info.getLangOpts().CPlusPlus || Info.getLangOpts().OpenCL) &&
36023613
!Info.getLangOpts().CPlusPlus11 && !VD->hasICEInitializer(Info.Ctx))) {
36033614
if (Init) {
@@ -16993,18 +17004,6 @@ bool Expr::EvaluateAsInitializer(APValue &Value, const ASTContext &Ctx,
1699317004

1699417005
if (!Info.discardCleanups())
1699517006
llvm_unreachable("Unhandled cleanup; missing full expression marker?");
16996-
16997-
if (Value.allowConstexprUnknown()) {
16998-
assert(Value.isLValue() && "Expected an lvalue");
16999-
auto Base = Value.getLValueBase();
17000-
const auto *NewVD = Base.dyn_cast<const ValueDecl *>();
17001-
if (!NewVD)
17002-
NewVD = VD;
17003-
Info.FFDiag(getExprLoc(), diag::note_constexpr_var_init_non_constant, 1)
17004-
<< NewVD;
17005-
NoteLValueLocation(Info, Base);
17006-
return false;
17007-
}
1700817007
}
1700917008

1701017009
return CheckConstantExpression(Info, DeclLoc, DeclTy, Value,

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19836,6 +19836,14 @@ case Builtin::BI__builtin_hlsl_elementwise_isinf: {
1983619836
RValFalse.isScalar()
1983719837
? RValFalse.getScalarVal()
1983819838
: RValFalse.getAggregatePointer(E->getArg(2)->getType(), *this);
19839+
if (auto *VTy = E->getType()->getAs<VectorType>()) {
19840+
if (!OpTrue->getType()->isVectorTy())
19841+
OpTrue =
19842+
Builder.CreateVectorSplat(VTy->getNumElements(), OpTrue, "splat");
19843+
if (!OpFalse->getType()->isVectorTy())
19844+
OpFalse =
19845+
Builder.CreateVectorSplat(VTy->getNumElements(), OpFalse, "splat");
19846+
}
1983919847

1984019848
Value *SelectVal =
1984119849
Builder.CreateSelect(OpCond, OpTrue, OpFalse, "hlsl.select");

clang/lib/CodeGen/CodeGenModule.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2068,9 +2068,10 @@ StringRef CodeGenModule::getMangledName(GlobalDecl GD) {
20682068
// Prior work:
20692069
// https://discourse.llvm.org/t/rfc-clang-diagnostic-for-demangling-failures/82835/8
20702070
// https://github.com/llvm/llvm-project/issues/111345
2071-
// assert((MangledName.startswith("_Z") || MangledName.startswith("?")) &&
2072-
// !GD->hasAttr<AsmLabelAttr>() &&
2073-
// llvm::demangle(MangledName) != MangledName &&
2071+
// assert(!((StringRef(MangledName).starts_with("_Z") ||
2072+
// StringRef(MangledName).starts_with("?")) &&
2073+
// !GD.getDecl()->hasAttr<AsmLabelAttr>() &&
2074+
// llvm::demangle(MangledName) == MangledName) &&
20742075
// "LLVM demangler must demangle clang-generated names");
20752076

20762077
auto Result = Manglings.insert(std::make_pair(MangledName, GD));

0 commit comments

Comments
 (0)