Skip to content

Commit 0c63506

Browse files
author
z1.cciauto
committed
merge main into amd-staging
2 parents a2cfc21 + c28d6c2 commit 0c63506

File tree

67 files changed

+2096
-1479
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

+2096
-1479
lines changed

clang/bindings/python/clang/cindex.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1585,6 +1585,8 @@ class Cursor(Structure):
15851585
"""
15861586
The Cursor class represents a reference to an element within the AST. It
15871587
acts as a kind of iterator.
1588+
1589+
Null cursors are mapped to None.
15881590
"""
15891591

15901592
_fields_ = [("_kind_id", c_int), ("xdata", c_int), ("data", c_void_p * 3)]

clang/docs/ClangFormatStyleOptions.rst

Lines changed: 13 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5990,41 +5990,25 @@ the configuration (without a prefix: ``Auto``).
59905990
**SortIncludes** (``SortIncludesOptions``) :versionbadge:`clang-format 3.8` :ref:`<SortIncludes>`
59915991
Controls if and how clang-format will sort ``#includes``.
59925992

5993-
Possible values:
5994-
5995-
* ``SI_Never`` (in configuration: ``Never``)
5996-
Includes are never sorted.
5997-
5998-
.. code-block:: c++
5999-
6000-
#include "B/A.h"
6001-
#include "A/B.h"
6002-
#include "a/b.h"
6003-
#include "A/b.h"
6004-
#include "B/a.h"
6005-
6006-
* ``SI_CaseSensitive`` (in configuration: ``CaseSensitive``)
6007-
Includes are sorted in an ASCIIbetical or case sensitive fashion.
5993+
Nested configuration flags:
60085994

6009-
.. code-block:: c++
5995+
Includes sorting options.
60105996

6011-
#include "A/B.h"
6012-
#include "A/b.h"
6013-
#include "B/A.h"
6014-
#include "B/a.h"
6015-
#include "a/b.h"
5997+
* ``bool Enabled`` If ``true``, includes are sorted based on the other suboptions below.
5998+
(``Never`` is deprecated by ``Enabled: false``.)
60165999

6017-
* ``SI_CaseInsensitive`` (in configuration: ``CaseInsensitive``)
6018-
Includes are sorted in an alphabetical or case insensitive fashion.
6000+
* ``bool IgnoreCase`` Whether or not includes are sorted in a case-insensitive fashion.
6001+
(``CaseSensitive`` and ``CaseInsensitive`` are deprecated by
6002+
``IgnoreCase: false`` and ``IgnoreCase: true``, respectively.)
60196003

60206004
.. code-block:: c++
60216005

6022-
#include "A/B.h"
6023-
#include "A/b.h"
6024-
#include "a/b.h"
6025-
#include "B/A.h"
6026-
#include "B/a.h"
6027-
6006+
true: false:
6007+
#include "A/B.h" vs. #include "A/B.h"
6008+
#include "A/b.h" #include "A/b.h"
6009+
#include "a/b.h" #include "B/A.h"
6010+
#include "B/A.h" #include "B/a.h"
6011+
#include "B/a.h" #include "a/b.h"
60286012

60296013

60306014
.. _SortJavaStaticImport:

clang/include/clang/Format/Format.h

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4365,35 +4365,29 @@ struct FormatStyle {
43654365
/// \version 18
43664366
bool SkipMacroDefinitionBody;
43674367

4368-
/// Include sorting options.
4369-
enum SortIncludesOptions : int8_t {
4370-
/// Includes are never sorted.
4371-
/// \code
4372-
/// #include "B/A.h"
4373-
/// #include "A/B.h"
4374-
/// #include "a/b.h"
4375-
/// #include "A/b.h"
4376-
/// #include "B/a.h"
4377-
/// \endcode
4378-
SI_Never,
4379-
/// Includes are sorted in an ASCIIbetical or case sensitive fashion.
4380-
/// \code
4381-
/// #include "A/B.h"
4382-
/// #include "A/b.h"
4383-
/// #include "B/A.h"
4384-
/// #include "B/a.h"
4385-
/// #include "a/b.h"
4386-
/// \endcode
4387-
SI_CaseSensitive,
4388-
/// Includes are sorted in an alphabetical or case insensitive fashion.
4389-
/// \code
4390-
/// #include "A/B.h"
4391-
/// #include "A/b.h"
4392-
/// #include "a/b.h"
4393-
/// #include "B/A.h"
4394-
/// #include "B/a.h"
4395-
/// \endcode
4396-
SI_CaseInsensitive,
4368+
/// Includes sorting options.
4369+
struct SortIncludesOptions {
4370+
/// If ``true``, includes are sorted based on the other suboptions below.
4371+
/// (``Never`` is deprecated by ``Enabled: false``.)
4372+
bool Enabled;
4373+
/// Whether or not includes are sorted in a case-insensitive fashion.
4374+
/// (``CaseSensitive`` and ``CaseInsensitive`` are deprecated by
4375+
/// ``IgnoreCase: false`` and ``IgnoreCase: true``, respectively.)
4376+
/// \code
4377+
/// true: false:
4378+
/// #include "A/B.h" vs. #include "A/B.h"
4379+
/// #include "A/b.h" #include "A/b.h"
4380+
/// #include "a/b.h" #include "B/A.h"
4381+
/// #include "B/A.h" #include "B/a.h"
4382+
/// #include "B/a.h" #include "a/b.h"
4383+
/// \endcode
4384+
bool IgnoreCase;
4385+
bool operator==(const SortIncludesOptions &R) const {
4386+
return Enabled == R.Enabled && IgnoreCase == R.IgnoreCase;
4387+
}
4388+
bool operator!=(const SortIncludesOptions &R) const {
4389+
return !(*this == R);
4390+
}
43974391
};
43984392

43994393
/// Controls if and how clang-format will sort ``#includes``.

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 70 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,6 @@ template <class Emitter> class DeclScope final : public LocalScope<Emitter> {
4545
Ctx->InitStack.push_back(InitLink::Decl(VD));
4646
}
4747

48-
void addExtended(const Scope::Local &Local) override {
49-
return this->addLocal(Local);
50-
}
51-
5248
~DeclScope() {
5349
this->Ctx->InitializingDecl = OldInitializingDecl;
5450
this->Ctx->InitStack.pop_back();
@@ -2021,6 +2017,45 @@ bool Compiler<Emitter>::visitArrayElemInit(unsigned ElemIndex, const Expr *Init,
20212017
return this->emitFinishInitPop(Init);
20222018
}
20232019

2020+
template <class Emitter>
2021+
bool Compiler<Emitter>::visitCallArgs(ArrayRef<const Expr *> Args,
2022+
const FunctionDecl *FuncDecl) {
2023+
assert(VarScope->getKind() == ScopeKind::Call);
2024+
llvm::BitVector NonNullArgs = collectNonNullArgs(FuncDecl, Args);
2025+
2026+
unsigned ArgIndex = 0;
2027+
for (const Expr *Arg : Args) {
2028+
if (std::optional<PrimType> T = classify(Arg)) {
2029+
if (!this->visit(Arg))
2030+
return false;
2031+
} else {
2032+
2033+
std::optional<unsigned> LocalIndex = allocateLocal(
2034+
Arg, Arg->getType(), /*ExtendingDecl=*/nullptr, ScopeKind::Call);
2035+
if (!LocalIndex)
2036+
return false;
2037+
2038+
if (!this->emitGetPtrLocal(*LocalIndex, Arg))
2039+
return false;
2040+
InitLinkScope<Emitter> ILS(this, InitLink::Temp(*LocalIndex));
2041+
if (!this->visitInitializer(Arg))
2042+
return false;
2043+
}
2044+
2045+
if (FuncDecl && NonNullArgs[ArgIndex]) {
2046+
PrimType ArgT = classify(Arg).value_or(PT_Ptr);
2047+
if (ArgT == PT_Ptr) {
2048+
if (!this->emitCheckNonNullArg(ArgT, Arg))
2049+
return false;
2050+
}
2051+
}
2052+
2053+
++ArgIndex;
2054+
}
2055+
2056+
return true;
2057+
}
2058+
20242059
template <class Emitter>
20252060
bool Compiler<Emitter>::VisitInitListExpr(const InitListExpr *E) {
20262061
return this->visitInitList(E->inits(), E->getArrayFiller(), E);
@@ -4343,7 +4378,7 @@ bool Compiler<Emitter>::emitConst(const APSInt &Value, const Expr *E) {
43434378
template <class Emitter>
43444379
unsigned Compiler<Emitter>::allocateLocalPrimitive(
43454380
DeclTy &&Src, PrimType Ty, bool IsConst, const ValueDecl *ExtendingDecl,
4346-
bool IsConstexprUnknown) {
4381+
ScopeKind SC, bool IsConstexprUnknown) {
43474382
// Make sure we don't accidentally register the same decl twice.
43484383
if (const auto *VD =
43494384
dyn_cast_if_present<ValueDecl>(Src.dyn_cast<const Decl *>())) {
@@ -4364,14 +4399,14 @@ unsigned Compiler<Emitter>::allocateLocalPrimitive(
43644399
if (ExtendingDecl)
43654400
VarScope->addExtended(Local, ExtendingDecl);
43664401
else
4367-
VarScope->add(Local, false);
4402+
VarScope->addForScopeKind(Local, SC);
43684403
return Local.Offset;
43694404
}
43704405

43714406
template <class Emitter>
43724407
std::optional<unsigned>
43734408
Compiler<Emitter>::allocateLocal(DeclTy &&Src, QualType Ty,
4374-
const ValueDecl *ExtendingDecl,
4409+
const ValueDecl *ExtendingDecl, ScopeKind SC,
43754410
bool IsConstexprUnknown) {
43764411
// Make sure we don't accidentally register the same decl twice.
43774412
if ([[maybe_unused]] const auto *VD =
@@ -4409,7 +4444,7 @@ Compiler<Emitter>::allocateLocal(DeclTy &&Src, QualType Ty,
44094444
if (ExtendingDecl)
44104445
VarScope->addExtended(Local, ExtendingDecl);
44114446
else
4412-
VarScope->add(Local, false);
4447+
VarScope->addForScopeKind(Local, SC);
44134448
return Local.Offset;
44144449
}
44154450

@@ -4676,7 +4711,7 @@ VarCreationState Compiler<Emitter>::visitVarDecl(const VarDecl *VD,
46764711
if (VarT) {
46774712
unsigned Offset = this->allocateLocalPrimitive(
46784713
VD, *VarT, VD->getType().isConstQualified(), nullptr,
4679-
IsConstexprUnknown);
4714+
ScopeKind::Block, IsConstexprUnknown);
46804715
if (Init) {
46814716
// If this is a toplevel declaration, create a scope for the
46824717
// initializer.
@@ -4692,8 +4727,9 @@ VarCreationState Compiler<Emitter>::visitVarDecl(const VarDecl *VD,
46924727
}
46934728
}
46944729
} else {
4695-
if (std::optional<unsigned> Offset = this->allocateLocal(
4696-
VD, VD->getType(), nullptr, IsConstexprUnknown)) {
4730+
if (std::optional<unsigned> Offset =
4731+
this->allocateLocal(VD, VD->getType(), nullptr, ScopeKind::Block,
4732+
IsConstexprUnknown)) {
46974733
if (!Init)
46984734
return true;
46994735

@@ -4881,26 +4917,28 @@ bool Compiler<Emitter>::VisitCallExpr(const CallExpr *E) {
48814917
if (FuncDecl) {
48824918
if (unsigned BuiltinID = FuncDecl->getBuiltinID())
48834919
return VisitBuiltinCallExpr(E, BuiltinID);
4884-
}
48854920

4886-
// Calls to replaceable operator new/operator delete.
4887-
if (FuncDecl &&
4888-
FuncDecl->isUsableAsGlobalAllocationFunctionInConstantEvaluation()) {
4889-
if (FuncDecl->getDeclName().isAnyOperatorNew()) {
4890-
return VisitBuiltinCallExpr(E, Builtin::BI__builtin_operator_new);
4891-
} else {
4892-
assert(FuncDecl->getDeclName().getCXXOverloadedOperator() == OO_Delete);
4893-
return VisitBuiltinCallExpr(E, Builtin::BI__builtin_operator_delete);
4921+
// Calls to replaceable operator new/operator delete.
4922+
if (FuncDecl->isUsableAsGlobalAllocationFunctionInConstantEvaluation()) {
4923+
if (FuncDecl->getDeclName().isAnyOperatorNew()) {
4924+
return VisitBuiltinCallExpr(E, Builtin::BI__builtin_operator_new);
4925+
} else {
4926+
assert(FuncDecl->getDeclName().getCXXOverloadedOperator() == OO_Delete);
4927+
return VisitBuiltinCallExpr(E, Builtin::BI__builtin_operator_delete);
4928+
}
4929+
}
4930+
4931+
// Explicit calls to trivial destructors
4932+
if (const auto *DD = dyn_cast<CXXDestructorDecl>(FuncDecl);
4933+
DD && DD->isTrivial()) {
4934+
const auto *MemberCall = cast<CXXMemberCallExpr>(E);
4935+
if (!this->visit(MemberCall->getImplicitObjectArgument()))
4936+
return false;
4937+
return this->emitCheckDestruction(E) && this->emitPopPtr(E);
48944938
}
48954939
}
4896-
// Explicit calls to trivial destructors
4897-
if (const auto *DD = dyn_cast_if_present<CXXDestructorDecl>(FuncDecl);
4898-
DD && DD->isTrivial()) {
4899-
const auto *MemberCall = cast<CXXMemberCallExpr>(E);
4900-
if (!this->visit(MemberCall->getImplicitObjectArgument()))
4901-
return false;
4902-
return this->emitCheckDestruction(E) && this->emitPopPtr(E);
4903-
}
4940+
4941+
BlockScope<Emitter> CallScope(this, ScopeKind::Call);
49044942

49054943
QualType ReturnType = E->getCallReturnType(Ctx.getASTContext());
49064944
std::optional<PrimType> T = classify(ReturnType);
@@ -4996,23 +5034,8 @@ bool Compiler<Emitter>::VisitCallExpr(const CallExpr *E) {
49965034
return false;
49975035
}
49985036

4999-
llvm::BitVector NonNullArgs = collectNonNullArgs(FuncDecl, Args);
5000-
// Put arguments on the stack.
5001-
unsigned ArgIndex = 0;
5002-
for (const auto *Arg : Args) {
5003-
if (!this->visit(Arg))
5004-
return false;
5005-
5006-
// If we know the callee already, check the known parametrs for nullability.
5007-
if (FuncDecl && NonNullArgs[ArgIndex]) {
5008-
PrimType ArgT = classify(Arg).value_or(PT_Ptr);
5009-
if (ArgT == PT_Ptr) {
5010-
if (!this->emitCheckNonNullArg(ArgT, Arg))
5011-
return false;
5012-
}
5013-
}
5014-
++ArgIndex;
5015-
}
5037+
if (!this->visitCallArgs(Args, FuncDecl))
5038+
return false;
50165039

50175040
// Undo the argument reversal we did earlier.
50185041
if (IsAssignmentOperatorCall) {
@@ -5088,9 +5111,9 @@ bool Compiler<Emitter>::VisitCallExpr(const CallExpr *E) {
50885111

50895112
// Cleanup for discarded return values.
50905113
if (DiscardResult && !ReturnType->isVoidType() && T)
5091-
return this->emitPop(*T, E);
5114+
return this->emitPop(*T, E) && CallScope.destroyLocals();
50925115

5093-
return true;
5116+
return CallScope.destroyLocals();
50945117
}
50955118

50965119
template <class Emitter>

0 commit comments

Comments
 (0)