Skip to content

Commit 2eaf340

Browse files
committed
Merge remote-tracking branch 'parent/main' into issue149103
2 parents 5f406ad + d77ac81 commit 2eaf340

File tree

799 files changed

+68402
-33670
lines changed

Some content is hidden

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

799 files changed

+68402
-33670
lines changed

.github/workflows/build-ci-container-windows.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ on:
1111
- .github/workflows/build-ci-container-windows.yml
1212
- '.github/workflows/containers/github-action-ci-windows/**'
1313
pull_request:
14-
branches:
15-
- main
1614
paths:
1715
- .github/workflows/build-ci-container-windows.yml
1816
- '.github/workflows/containers/github-action-ci-windows/**'

.github/workflows/build-ci-container.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ on:
1111
- .github/workflows/build-ci-container.yml
1212
- '.github/workflows/containers/github-action-ci/**'
1313
pull_request:
14-
branches:
15-
- main
1614
paths:
1715
- .github/workflows/build-ci-container.yml
1816
- '.github/workflows/containers/github-action-ci/**'

clang-tools-extra/clangd/unittests/FindTargetTests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,7 @@ TEST_F(TargetDeclTest, OverloadExpr) {
838838
)cpp";
839839
// Sized deallocation is enabled by default in C++14 onwards.
840840
EXPECT_DECLS("CXXDeleteExpr",
841-
"void operator delete(void *, unsigned long) noexcept");
841+
"void operator delete(void *, __size_t) noexcept");
842842
}
843843

844844
TEST_F(TargetDeclTest, DependentExprs) {

clang-tools-extra/clangd/unittests/HoverTests.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2794,7 +2794,7 @@ TEST(Hover, All) {
27942794
})cpp",
27952795
[](HoverInfo &HI) {
27962796
HI.Name = "expression";
2797-
HI.Type = "unsigned long";
2797+
HI.Type = {"__size_t", "unsigned long"};
27982798
HI.Value = "1";
27992799
}},
28002800
{
@@ -2804,7 +2804,7 @@ TEST(Hover, All) {
28042804
})cpp",
28052805
[](HoverInfo &HI) {
28062806
HI.Name = "expression";
2807-
HI.Type = "unsigned long";
2807+
HI.Type = {"__size_t", "unsigned long"};
28082808
HI.Value = "1";
28092809
}},
28102810
{

clang/docs/ClangTools.rst

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,50 @@ they'll be tracked here. The focus of this documentation is on the scope
8989
and features of the tools for other tool developers; each tool should
9090
provide its own user-focused documentation.
9191

92-
``clang-tidy``
92+
``Clang-Doc``
93+
-------------
94+
95+
`Clang-Doc <https://clang.llvm.org/extra/clang-doc.html>`_ is a tool for
96+
generating C and C++ documentation from source code and comments.
97+
98+
``Clang-Include-Fixer``
99+
-----------------------
100+
101+
`Clang-Include-Fixer <https://clang.llvm.org/extra/clang-include-fixer.html>`_
102+
is a tool to automate the addition of missing ``#include`` directives in a C++
103+
file. It adds missing namespace qualifiers to unidentified symbols when
104+
necessary and also removes unused headers.
105+
106+
``Clang-Tidy``
93107
--------------
94108

95-
`clang-tidy <https://clang.llvm.org/extra/clang-tidy/>`_ is a clang-based C++
109+
`Clang-Tidy <https://clang.llvm.org/extra/clang-tidy/>`_ is a Clang-based C++
96110
linter tool. It provides an extensible framework for building compiler-based
97111
static analyses detecting and fixing bug-prone patterns, performance,
98-
portability and maintainability issues.
112+
portability and maintainability issues. It also has checks for modernizing code
113+
to newer language standards.
114+
115+
``Clangd``
116+
----------
117+
118+
`Clangd <https://clangd.llvm.org/>`_ is a language server that can work with
119+
many editors via a plugin. It understands your C++ code and adds smart
120+
features to your editor: code completion, compile errors, go-to-definition and
121+
more.
122+
123+
``Modularize``
124+
--------------
125+
126+
`Modularize <https://clang.llvm.org/extra/modularize.html>`_ is a standalone
127+
tool that checks whether a set of headers provides the consistent definitions
128+
required to use modules.
129+
130+
``pp-trace``
131+
------------
132+
133+
`pp-trace <https://clang.llvm.org/extra/pp-trace.html>`_ is a standalone tool
134+
that traces preprocessor activity. It’s also used as a test of Clang’s
135+
``PPCallbacks`` interface.
99136

100137

101138
Ideas for new Tools

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ Potentially Breaking Changes
4646
``endbr64`` instruction at the labels named as possible branch
4747
destinations, so it is not safe to use a register-controlled branch
4848
instruction to branch to one. (In line with gcc.)
49+
- Added a sugar type `PredefinedSugarType` to improve diagnostic messages. (#GH143653)
4950

5051
C/C++ Language Potentially Breaking Changes
5152
-------------------------------------------

clang/include/clang/AST/ASTContext.h

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,11 @@ class ASTContext : public RefCountedBase<ASTContext> {
277277
mutable llvm::ContextualFoldingSet<ArrayParameterType, ASTContext &>
278278
ArrayParameterTypes;
279279

280+
/// Store the unique Type corresponding to each Kind.
281+
mutable std::array<Type *,
282+
llvm::to_underlying(PredefinedSugarType::Kind::Last) + 1>
283+
PredefinedSugarTypes{};
284+
280285
/// The set of nested name specifiers.
281286
///
282287
/// This set is managed by the NestedNameSpecifier class.
@@ -1192,6 +1197,8 @@ class ASTContext : public RefCountedBase<ASTContext> {
11921197
bool isInSameModule(const Module *M1, const Module *M2) const;
11931198

11941199
TranslationUnitDecl *getTranslationUnitDecl() const {
1200+
assert(TUDecl->getMostRecentDecl() == TUDecl &&
1201+
"The active TU is not current one!");
11951202
return TUDecl->getMostRecentDecl();
11961203
}
11971204
void addTranslationUnitDecl() {
@@ -1567,6 +1574,8 @@ class ASTContext : public RefCountedBase<ASTContext> {
15671574
/// and bit count.
15681575
QualType getDependentBitIntType(bool Unsigned, Expr *BitsExpr) const;
15691576

1577+
QualType getPredefinedSugarType(PredefinedSugarType::Kind KD) const;
1578+
15701579
/// Gets the struct used to keep track of the extended descriptor for
15711580
/// pointer to blocks.
15721581
QualType getBlockDescriptorExtendedType() const;
@@ -1999,11 +2008,13 @@ class ASTContext : public RefCountedBase<ASTContext> {
19992008
/// <stddef.h>.
20002009
///
20012010
/// The sizeof operator requires this (C99 6.5.3.4p4).
2002-
CanQualType getSizeType() const;
2011+
QualType getSizeType() const;
2012+
2013+
CanQualType getCanonicalSizeType() const;
20032014

20042015
/// Return the unique signed counterpart of
20052016
/// the integer type corresponding to size_t.
2006-
CanQualType getSignedSizeType() const;
2017+
QualType getSignedSizeType() const;
20072018

20082019
/// Return the unique type for "intmax_t" (C99 7.18.1.5), defined in
20092020
/// <stdint.h>.

clang/include/clang/AST/FormatString.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,8 @@ class FormatSpecifier {
489489

490490
/// For a TypedefType QT, if it is a named integer type such as size_t,
491491
/// assign the appropriate value to LM and return true.
492-
static bool namedTypeToLengthModifier(QualType QT, LengthModifier &LM);
492+
static bool namedTypeToLengthModifier(ASTContext &Ctx, QualType QT,
493+
LengthModifier &LM);
493494
};
494495

495496
} // end analyze_format_string namespace

clang/include/clang/AST/RecursiveASTVisitor.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,6 +1208,8 @@ DEF_TRAVERSE_TYPE(BitIntType, {})
12081208
DEF_TRAVERSE_TYPE(DependentBitIntType,
12091209
{ TRY_TO(TraverseStmt(T->getNumBitsExpr())); })
12101210

1211+
DEF_TRAVERSE_TYPE(PredefinedSugarType, {})
1212+
12111213
#undef DEF_TRAVERSE_TYPE
12121214

12131215
// ----------------- TypeLoc traversal -----------------
@@ -1524,6 +1526,8 @@ DEF_TRAVERSE_TYPELOC(DependentBitIntType, {
15241526
TRY_TO(TraverseStmt(TL.getTypePtr()->getNumBitsExpr()));
15251527
})
15261528

1529+
DEF_TRAVERSE_TYPELOC(PredefinedSugarType, {})
1530+
15271531
#undef DEF_TRAVERSE_TYPELOC
15281532

15291533
// ----------------- Decl traversal -----------------

clang/include/clang/AST/Type.h

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2258,6 +2258,30 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
22582258
unsigned NumExpansions;
22592259
};
22602260

2261+
enum class PredefinedSugarKind {
2262+
/// The "size_t" type.
2263+
SizeT,
2264+
2265+
/// The signed integer type corresponding to "size_t".
2266+
SignedSizeT,
2267+
2268+
/// The "ptrdiff_t" type.
2269+
PtrdiffT,
2270+
2271+
// Indicates how many items the enum has.
2272+
Last = PtrdiffT
2273+
};
2274+
2275+
class PresefinedSugarTypeBitfields {
2276+
friend class PredefinedSugarType;
2277+
2278+
LLVM_PREFERRED_TYPE(TypeBitfields)
2279+
unsigned : NumTypeBits;
2280+
2281+
LLVM_PREFERRED_TYPE(PredefinedSugarKind)
2282+
unsigned Kind : 8;
2283+
};
2284+
22612285
class CountAttributedTypeBitfields {
22622286
friend class CountAttributedType;
22632287

@@ -2297,6 +2321,7 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
22972321
DependentTemplateSpecializationTypeBits;
22982322
PackExpansionTypeBitfields PackExpansionTypeBits;
22992323
CountAttributedTypeBitfields CountAttributedTypeBits;
2324+
PresefinedSugarTypeBitfields PredefinedSugarTypeBits;
23002325
};
23012326

23022327
private:
@@ -8038,6 +8063,37 @@ class DependentBitIntType final : public Type, public llvm::FoldingSetNode {
80388063
}
80398064
};
80408065

8066+
class PredefinedSugarType final : public Type {
8067+
public:
8068+
friend class ASTContext;
8069+
using Kind = PredefinedSugarKind;
8070+
8071+
private:
8072+
PredefinedSugarType(Kind KD, const IdentifierInfo *IdentName,
8073+
QualType CanonicalType)
8074+
: Type(PredefinedSugar, CanonicalType, TypeDependence::None),
8075+
Name(IdentName) {
8076+
PredefinedSugarTypeBits.Kind = llvm::to_underlying(KD);
8077+
}
8078+
8079+
static StringRef getName(Kind KD);
8080+
8081+
const IdentifierInfo *Name;
8082+
8083+
public:
8084+
bool isSugared() const { return true; }
8085+
8086+
QualType desugar() const { return getCanonicalTypeInternal(); }
8087+
8088+
Kind getKind() const { return Kind(PredefinedSugarTypeBits.Kind); }
8089+
8090+
const IdentifierInfo *getIdentifier() const { return Name; }
8091+
8092+
static bool classof(const Type *T) {
8093+
return T->getTypeClass() == PredefinedSugar;
8094+
}
8095+
};
8096+
80418097
/// A qualifier set is used to build a set of qualifiers.
80428098
class QualifierCollector : public Qualifiers {
80438099
public:

0 commit comments

Comments
 (0)