Skip to content

Commit 09c0e6c

Browse files
author
z1_cciauto
authored
merge main into amd-staging (llvm#3394)
2 parents 5eabf2e + f37bb13 commit 09c0e6c

File tree

67 files changed

+3766
-563
lines changed

Some content is hidden

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

67 files changed

+3766
-563
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,8 @@ New features
499499

500500
Crash and bug fixes
501501
^^^^^^^^^^^^^^^^^^^
502+
- Fixed a crash in the static analyzer that when the expression in an
503+
``[[assume(expr)]]`` attribute was enclosed in parentheses. (#GH151529)
502504

503505
Improvements
504506
^^^^^^^^^^^^

clang/docs/ThinLTO.rst

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,9 @@ during the traditional link step.
249249

250250
The implementation is documented here: https://llvm.org/docs/DTLTO.html.
251251

252+
Command-Line Options
253+
^^^^^^^^^^^^^^^^^^^^
254+
252255
DTLTO requires the LLD linker (``-fuse-ld=lld``).
253256

254257
``-fthinlto-distributor=<path>``
@@ -260,17 +263,29 @@ DTLTO requires the LLD linker (``-fuse-ld=lld``).
260263
- Can be specified multiple times to pass multiple options.
261264
- Multiple options can also be specified by separating them with commas.
262265

263-
Examples:
264-
- ``clang -flto=thin -fthinlto-distributor=incredibuild.exe -Xthinlto-distributor=--verbose,--j10 -fuse-ld=lld``
265-
- ``clang -flto=thin -fthinlto-distributor=$(which python) -Xthinlto-distributor=incredibuild.py -fuse-ld=lld``
266-
267266
If ``-fthinlto-distributor=`` is specified, Clang supplies the path to a
268267
compiler to be executed remotely to perform the ThinLTO backend
269268
compilations. Currently, this is Clang itself.
270269

270+
Usage
271+
^^^^^
272+
273+
Compilation is unchanged from ThinLTO. DTLTO options need to supplied for the link step:
274+
275+
.. code-block:: console
276+
277+
% clang -flto=thin -fthinlto-distributor=distribute.sh -Xthinlto-distributor=--verbose,--j10 -fuse-ld=lld file1.o file2.o
278+
% clang -flto=thin -fthinlto-distributor=$(which python) -Xthinlto-distributor=distribute.py -fuse-ld=lld file1.o file2.o
279+
280+
When using lld-link:
281+
282+
.. code-block:: console
283+
284+
% lld-link /out:a.exe file1.obj file2.obj /thinlto-distributor:distribute.exe /thinlto-remote-compiler:${LLVM}\bin\clang.exe /thinlto-distributor-arg:--verbose
285+
271286
Note that currently, DTLTO is only supported in some LLD flavors. Support can
272287
be added to other LLD flavours in the future.
273-
See `DTLTO <https://lld.llvm.org/dtlto.html>`_ for more information.
288+
See `DTLTO <https://lld.llvm.org/DTLTO.html>`_ for more information.
274289

275290
More Information
276291
================

clang/include/clang/AST/Expr.h

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -553,17 +553,13 @@ class Expr : public ValueStmt {
553553
bool IgnoreTemplateOrMacroSubstitution = false) const;
554554

555555
/// isIntegerConstantExpr - Return the value if this expression is a valid
556-
/// integer constant expression. If not a valid i-c-e, return std::nullopt
557-
/// and fill in Loc (if specified) with the location of the invalid
558-
/// expression.
556+
/// integer constant expression. If not a valid i-c-e, return std::nullopt.
559557
///
560558
/// Note: This does not perform the implicit conversions required by C++11
561559
/// [expr.const]p5.
562560
std::optional<llvm::APSInt>
563-
getIntegerConstantExpr(const ASTContext &Ctx,
564-
SourceLocation *Loc = nullptr) const;
565-
bool isIntegerConstantExpr(const ASTContext &Ctx,
566-
SourceLocation *Loc = nullptr) const;
561+
getIntegerConstantExpr(const ASTContext &Ctx) const;
562+
bool isIntegerConstantExpr(const ASTContext &Ctx) const;
567563

568564
/// isCXX98IntegralConstantExpr - Return true if this expression is an
569565
/// integral constant expression in C++98. Can only be used in C++.
@@ -574,8 +570,8 @@ class Expr : public ValueStmt {
574570
///
575571
/// Note: This does not perform the implicit conversions required by C++11
576572
/// [expr.const]p5.
577-
bool isCXX11ConstantExpr(const ASTContext &Ctx, APValue *Result = nullptr,
578-
SourceLocation *Loc = nullptr) const;
573+
bool isCXX11ConstantExpr(const ASTContext &Ctx,
574+
APValue *Result = nullptr) const;
579575

580576
/// isPotentialConstantExpr - Return true if this function's definition
581577
/// might be usable in a constant expression in C++11, if it were marked

clang/lib/AST/ExprConstant.cpp

Lines changed: 13 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -17312,8 +17312,7 @@ bool Expr::EvalResult::isGlobalLValue() const {
1731217312
/// comma, etc
1731317313

1731417314
// CheckICE - This function does the fundamental ICE checking: the returned
17315-
// ICEDiag contains an ICEKind indicating whether the expression is an ICE,
17316-
// and a (possibly null) SourceLocation indicating the location of the problem.
17315+
// ICEDiag contains an ICEKind indicating whether the expression is an ICE.
1731717316
//
1731817317
// Note that to reduce code duplication, this helper does no evaluation
1731917318
// itself; the caller checks whether the expression is evaluatable, and
@@ -17777,46 +17776,38 @@ static ICEDiag CheckICE(const Expr* E, const ASTContext &Ctx) {
1777717776
/// Evaluate an expression as a C++11 integral constant expression.
1777817777
static bool EvaluateCPlusPlus11IntegralConstantExpr(const ASTContext &Ctx,
1777917778
const Expr *E,
17780-
llvm::APSInt *Value,
17781-
SourceLocation *Loc) {
17782-
if (!E->getType()->isIntegralOrUnscopedEnumerationType()) {
17783-
if (Loc) *Loc = E->getExprLoc();
17779+
llvm::APSInt *Value) {
17780+
if (!E->getType()->isIntegralOrUnscopedEnumerationType())
1778417781
return false;
17785-
}
1778617782

1778717783
APValue Result;
17788-
if (!E->isCXX11ConstantExpr(Ctx, &Result, Loc))
17784+
if (!E->isCXX11ConstantExpr(Ctx, &Result))
1778917785
return false;
1779017786

17791-
if (!Result.isInt()) {
17792-
if (Loc) *Loc = E->getExprLoc();
17787+
if (!Result.isInt())
1779317788
return false;
17794-
}
1779517789

1779617790
if (Value) *Value = Result.getInt();
1779717791
return true;
1779817792
}
1779917793

17800-
bool Expr::isIntegerConstantExpr(const ASTContext &Ctx,
17801-
SourceLocation *Loc) const {
17794+
bool Expr::isIntegerConstantExpr(const ASTContext &Ctx) const {
1780217795
assert(!isValueDependent() &&
1780317796
"Expression evaluator can't be called on a dependent expression.");
1780417797

1780517798
ExprTimeTraceScope TimeScope(this, Ctx, "isIntegerConstantExpr");
1780617799

1780717800
if (Ctx.getLangOpts().CPlusPlus11)
17808-
return EvaluateCPlusPlus11IntegralConstantExpr(Ctx, this, nullptr, Loc);
17801+
return EvaluateCPlusPlus11IntegralConstantExpr(Ctx, this, nullptr);
1780917802

1781017803
ICEDiag D = CheckICE(this, Ctx);
17811-
if (D.Kind != IK_ICE) {
17812-
if (Loc) *Loc = D.Loc;
17804+
if (D.Kind != IK_ICE)
1781317805
return false;
17814-
}
1781517806
return true;
1781617807
}
1781717808

1781817809
std::optional<llvm::APSInt>
17819-
Expr::getIntegerConstantExpr(const ASTContext &Ctx, SourceLocation *Loc) const {
17810+
Expr::getIntegerConstantExpr(const ASTContext &Ctx) const {
1782017811
if (isValueDependent()) {
1782117812
// Expression evaluator can't succeed on a dependent expression.
1782217813
return std::nullopt;
@@ -17825,12 +17816,12 @@ Expr::getIntegerConstantExpr(const ASTContext &Ctx, SourceLocation *Loc) const {
1782517816
APSInt Value;
1782617817

1782717818
if (Ctx.getLangOpts().CPlusPlus11) {
17828-
if (EvaluateCPlusPlus11IntegralConstantExpr(Ctx, this, &Value, Loc))
17819+
if (EvaluateCPlusPlus11IntegralConstantExpr(Ctx, this, &Value))
1782917820
return Value;
1783017821
return std::nullopt;
1783117822
}
1783217823

17833-
if (!isIntegerConstantExpr(Ctx, Loc))
17824+
if (!isIntegerConstantExpr(Ctx))
1783417825
return std::nullopt;
1783517826

1783617827
// The only possible side-effects here are due to UB discovered in the
@@ -17855,8 +17846,7 @@ bool Expr::isCXX98IntegralConstantExpr(const ASTContext &Ctx) const {
1785517846
return CheckICE(this, Ctx).Kind == IK_ICE;
1785617847
}
1785717848

17858-
bool Expr::isCXX11ConstantExpr(const ASTContext &Ctx, APValue *Result,
17859-
SourceLocation *Loc) const {
17849+
bool Expr::isCXX11ConstantExpr(const ASTContext &Ctx, APValue *Result) const {
1786017850
assert(!isValueDependent() &&
1786117851
"Expression evaluator can't be called on a dependent expression.");
1786217852

@@ -17877,15 +17867,7 @@ bool Expr::isCXX11ConstantExpr(const ASTContext &Ctx, APValue *Result,
1787717867
// call us on arbitrary full-expressions should generally not care.
1787817868
Info.discardCleanups() && !Status.HasSideEffects;
1787917869

17880-
if (!Diags.empty()) {
17881-
IsConstExpr = false;
17882-
if (Loc) *Loc = Diags[0].first;
17883-
} else if (!IsConstExpr) {
17884-
// FIXME: This shouldn't happen.
17885-
if (Loc) *Loc = getExprLoc();
17886-
}
17887-
17888-
return IsConstExpr;
17870+
return IsConstExpr && Diags.empty();
1788917871
}
1789017872

1789117873
bool Expr::EvaluateWithSubstitution(APValue &Value, ASTContext &Ctx,

clang/lib/CodeGen/CGDebugInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4863,7 +4863,7 @@ void CGDebugInfo::EmitFuncDeclForCallSite(llvm::CallBase *CallOrInvoke,
48634863
const FunctionDecl *CalleeDecl) {
48644864
if (!CallOrInvoke)
48654865
return;
4866-
auto *Func = CallOrInvoke->getCalledFunction();
4866+
auto *Func = dyn_cast<llvm::Function>(CallOrInvoke->getCalledOperand());
48674867
if (!Func)
48684868
return;
48694869
if (Func->getSubprogram())

clang/lib/Frontend/FrontendAction.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,8 @@ class DeserializedDeclsSourceRangePrinter : public ASTConsumer,
226226
}
227227
*OS << " ]\n";
228228
*OS << "}\n";
229+
230+
OS->flush();
229231
}
230232
};
231233

clang/lib/Sema/SemaDecl.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14751,9 +14751,10 @@ void Sema::CheckCompleteVariableDeclaration(VarDecl *var) {
1475114751
type->isIntegralOrEnumerationType()) {
1475214752
// In C++98, in-class initialization for a static data member must
1475314753
// be an integer constant expression.
14754-
SourceLocation Loc;
14755-
if (!Init->isIntegerConstantExpr(Context, &Loc)) {
14756-
Diag(Loc, diag::ext_in_class_initializer_non_constant)
14754+
// SourceLocation Loc;
14755+
if (!Init->isIntegerConstantExpr(Context)) {
14756+
Diag(Init->getExprLoc(),
14757+
diag::ext_in_class_initializer_non_constant)
1475714758
<< Init->getSourceRange();
1475814759
}
1475914760
}

clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1227,7 +1227,7 @@ void ExprEngine::VisitAttributedStmt(const AttributedStmt *A,
12271227

12281228
for (const auto *Attr : getSpecificAttrs<CXXAssumeAttr>(A->getAttrs())) {
12291229
for (ExplodedNode *N : CheckerPreStmt) {
1230-
Visit(Attr->getAssumption(), N, EvalSet);
1230+
Visit(Attr->getAssumption()->IgnoreParens(), N, EvalSet);
12311231
}
12321232
}
12331233

clang/test/Analysis/builtin_assume.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,16 @@ int using_builtin_assume_has_no_sideeffects(int y) {
6262

6363
return y;
6464
}
65+
66+
template <int ...args>
67+
bool issue151529() {
68+
// no-crash
69+
[[assume((true))]];
70+
// no-crash
71+
[[assume(((args >= 0) && ...))]]; // expected-warning {{pack fold expression is a C++17 extension}}
72+
return ((args >= 0) && ...); // expected-warning {{pack fold expression is a C++17 extension}}
73+
}
74+
75+
void instantiate_issue151529() {
76+
issue151529<0>();
77+
}
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
// Test that call site debug info is (un)supported in various configurations.
2+
3+
// Supported: DWARF5, -O1, standalone DI
4+
// RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple %s -o - \
5+
// RUN: -O1 -disable-llvm-passes \
6+
// RUN: -debug-info-kind=standalone -dwarf-version=5 \
7+
// RUN: | FileCheck %s -check-prefix=HAS-ATTR \
8+
// RUN: -implicit-check-not=DISubprogram -implicit-check-not=DIFlagAllCallsDescribed
9+
10+
// Supported: DWARF4 + LLDB tuning, -O1, limited DI
11+
// RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple %s -o - \
12+
// RUN: -O1 -disable-llvm-passes \
13+
// RUN: -debugger-tuning=lldb \
14+
// RUN: -debug-info-kind=standalone -dwarf-version=4 \
15+
// RUN: | FileCheck %s -check-prefix=HAS-ATTR \
16+
// RUN: -implicit-check-not=DISubprogram -implicit-check-not=DIFlagAllCallsDescribed
17+
18+
// Note: DIFlagAllCallsDescribed may have been enabled prematurely when tuning
19+
// for GDB under -gdwarf-4 in https://reviews.llvm.org/D69743. It's possible
20+
// this should have been 'Unsupported' until entry values emission was enabled
21+
// by default.
22+
//
23+
// Supported: DWARF4 + GDB tuning
24+
// RUN: %clang_cc1 -emit-llvm -triple x86_64-linux-gnu \
25+
// RUN: %s -o - -O1 -disable-llvm-passes -debugger-tuning=gdb \
26+
// RUN: -debug-info-kind=standalone -dwarf-version=4 \
27+
// RUN: | FileCheck %s -check-prefix=HAS-ATTR \
28+
// RUN: -implicit-check-not=DIFlagAllCallsDescribed
29+
30+
// Supported: DWARF4 + LLDB, -O1
31+
// RUN: %clang_cc1 -emit-llvm -triple x86_64-linux-gnu \
32+
// RUN: %s -o - -O1 -disable-llvm-passes -debugger-tuning=lldb \
33+
// RUN: -debug-info-kind=standalone -dwarf-version=4 \
34+
// RUN: | FileCheck %s -check-prefix=HAS-ATTR \
35+
// RUN: -implicit-check-not=DIFlagAllCallsDescribed
36+
37+
// Unsupported: -O0
38+
// RUN: %clang_cc1 -emit-llvm -triple x86_64-linux-gnu \
39+
// RUN: %s -o - -O0 -disable-llvm-passes -debugger-tuning=gdb \
40+
// RUN: -debug-info-kind=standalone -dwarf-version=4 \
41+
// RUN: | FileCheck %s -check-prefix=NO-ATTR
42+
43+
// Supported: DWARF4 + LLDB tuning, -O1, line-tables only DI
44+
// RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple %s -o - \
45+
// RUN: -O1 -disable-llvm-passes \
46+
// RUN: -debugger-tuning=lldb \
47+
// RUN: -debug-info-kind=line-tables-only -dwarf-version=4 \
48+
// RUN: | FileCheck %s -check-prefix=LINE-TABLES-ONLY
49+
50+
// Unsupported: -O0
51+
// RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple %s -o - \
52+
// RUN: -O0 \
53+
// RUN: -debug-info-kind=standalone -dwarf-version=5 \
54+
// RUN: | FileCheck %s -check-prefix=NO-ATTR
55+
56+
// Unsupported: DWARF4
57+
// RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple %s -o - \
58+
// RUN: -O1 -disable-llvm-passes \
59+
// RUN: -debug-info-kind=standalone -dwarf-version=4 \
60+
// RUN: | FileCheck %s -check-prefix=NO-ATTR
61+
62+
// NO-ATTR-NOT: FlagAllCallsDescribed
63+
64+
// HAS-ATTR-DAG: DISubprogram(name: "declaration1", {{.*}}, spFlags: DISPFlagOptimized)
65+
// HAS-ATTR-DAG: DISubprogram(name: "declaration2", {{.*}}, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized
66+
// HAS-ATTR-DAG: DISubprogram(name: "declaration3", {{.*}}, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized)
67+
// HAS-ATTR-DAG: DISubprogram(name: "declaration4", {{.*}}, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized
68+
69+
// HAS-ATTR-DAG: DISubprogram(name: "force_irgen", {{.*}}, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition
70+
71+
// LINE-TABLES-ONLY: DISubprogram(name: "force_irgen", {{.*}}, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition
72+
73+
void declaration1();
74+
75+
void declaration2();
76+
77+
void declaration2() {}
78+
79+
void declaration3(void);
80+
81+
void declaration4(void);
82+
83+
void declaration4(void) {}
84+
85+
void __attribute__((optnone)) force_irgen(void) {
86+
declaration1();
87+
declaration3();
88+
}

0 commit comments

Comments
 (0)