Skip to content

Commit 8f4349e

Browse files
authored
Merge branch 'llvm:main' into main
2 parents 302b83d + 7257c37 commit 8f4349e

File tree

536 files changed

+14909
-9885
lines changed

Some content is hidden

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

536 files changed

+14909
-9885
lines changed

.ci/generate-buildkite-pipeline-premerge

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ function add-dependencies() {
108108
compiler-rt|libc|openmp)
109109
echo clang lld
110110
;;
111-
flang|lldb)
111+
flang|lldb|libclc)
112112
for p in llvm clang; do
113113
echo $p
114114
done

.github/CODEOWNERS

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,11 @@ clang/test/AST/Interp/ @tbaederr
113113

114114
# MLIR NVVM Dialect in MLIR
115115
/mlir/**/LLVMIR/**/BasicPtxBuilderInterface* @grypp
116-
/mlir/**/NVVM*/ @grypp
116+
/mlir/**/NVVM* @grypp
117117

118118
# MLIR Python Bindings
119-
/mlir/test/python/ @makslevental @stellaraccident
120-
/mlir/python/ @makslevental @stellaraccident
119+
/mlir/test/python/ @ftynse @makslevental @stellaraccident
120+
/mlir/python/ @ftynse @makslevental @stellaraccident
121121

122122
# BOLT
123123
/bolt/ @aaupov @maksfb @rafaelauler @ayermolo @dcci

.github/new-prs-labeler.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
ClangIR:
2+
- clang/include/clang/CIR/**/*
3+
- clang/lib/CIR/**/*
4+
- clang/tools/cir-*/**/*
5+
- clang/test/CIR/**/*
6+
17
clang:dataflow:
28
- clang/include/clang/Analysis/FlowSensitive/**/*
39
- clang/lib/Analysis/FlowSensitive/**/*
@@ -938,3 +944,6 @@ openmp:libomptarget:
938944

939945
bazel:
940946
- utils/bazel/**
947+
948+
offload:
949+
- offload/**

clang-tools-extra/clang-tidy/add_new_check.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ def adapt_module(module_path, module, check_name, check_name_camel):
211211
f.write(check_decl)
212212
else:
213213
match = re.search(
214-
'registerCheck<(.*)> *\( *(?:"([^"]*)")?', line
214+
r'registerCheck<(.*)> *\( *(?:"([^"]*)")?', line
215215
)
216216
prev_line = None
217217
if match:
@@ -383,7 +383,7 @@ def filename_from_module(module_name, check_name):
383383
if stmt_start_pos == -1:
384384
return ""
385385
stmt = code[stmt_start_pos + 1 : stmt_end_pos]
386-
matches = re.search('registerCheck<([^>:]*)>\(\s*"([^"]*)"\s*\)', stmt)
386+
matches = re.search(r'registerCheck<([^>:]*)>\(\s*"([^"]*)"\s*\)', stmt)
387387
if matches and matches[2] == full_check_name:
388388
class_name = matches[1]
389389
if "::" in class_name:
@@ -401,8 +401,8 @@ def filename_from_module(module_name, check_name):
401401
# Examine code looking for a c'tor definition to get the base class name.
402402
def get_base_class(code, check_file):
403403
check_class_name = os.path.splitext(os.path.basename(check_file))[0]
404-
ctor_pattern = check_class_name + "\([^:]*\)\s*:\s*([A-Z][A-Za-z0-9]*Check)\("
405-
matches = re.search("\s+" + check_class_name + "::" + ctor_pattern, code)
404+
ctor_pattern = check_class_name + r"\([^:]*\)\s*:\s*([A-Z][A-Za-z0-9]*Check)\("
405+
matches = re.search(r"\s+" + check_class_name + "::" + ctor_pattern, code)
406406

407407
# The constructor might be inline in the header.
408408
if not matches:
@@ -476,7 +476,7 @@ def process_doc(doc_file):
476476
# Orphan page, don't list it.
477477
return "", ""
478478

479-
match = re.search(".*:http-equiv=refresh: \d+;URL=(.*).html(.*)", content)
479+
match = re.search(r".*:http-equiv=refresh: \d+;URL=(.*).html(.*)", content)
480480
# Is it a redirect?
481481
return check_name, match
482482

@@ -505,7 +505,7 @@ def format_link_alias(doc_file):
505505
ref_begin = ""
506506
ref_end = "_"
507507
else:
508-
redirect_parts = re.search("^\.\./([^/]*)/([^/]*)$", match.group(1))
508+
redirect_parts = re.search(r"^\.\./([^/]*)/([^/]*)$", match.group(1))
509509
title = redirect_parts[1] + "-" + redirect_parts[2]
510510
target = redirect_parts[1] + "/" + redirect_parts[2]
511511
autofix = has_auto_fix(title)

clang-tools-extra/clang-tidy/bugprone/ForwardingReferenceOverloadCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ void ForwardingReferenceOverloadCheck::registerMatchers(MatchFinder *Finder) {
7272

7373
DeclarationMatcher FindOverload =
7474
cxxConstructorDecl(
75-
hasParameter(0, ForwardingRefParm),
75+
hasParameter(0, ForwardingRefParm), unless(isDeleted()),
7676
unless(hasAnyParameter(
7777
// No warning: enable_if as constructor parameter.
7878
parmVarDecl(hasType(isEnableIf())))),

clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ void ProTypeMemberInitCheck::checkMissingMemberInitializer(
444444
if (!F->hasInClassInitializer() &&
445445
utils::type_traits::isTriviallyDefaultConstructible(F->getType(),
446446
Context) &&
447-
!isEmpty(Context, F->getType()) && !F->isUnnamedBitfield() &&
447+
!isEmpty(Context, F->getType()) && !F->isUnnamedBitField() &&
448448
!AnyMemberHasInitPerUnion)
449449
FieldsToInit.insert(F);
450450
});

clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ getAllNamedFields(const CXXRecordDecl *Record) {
2626
std::set<const FieldDecl *> Result;
2727
for (const auto *Field : Record->fields()) {
2828
// Static data members are not in this range.
29-
if (Field->isUnnamedBitfield())
29+
if (Field->isUnnamedBitField())
3030
continue;
3131
Result.insert(Field);
3232
}

clang-tools-extra/clang-tidy/utils/ExceptionSpecAnalyzer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ ExceptionSpecAnalyzer::analyzeRecord(const CXXRecordDecl *RecordDecl,
9999
}
100100

101101
for (const auto *FDecl : RecordDecl->fields())
102-
if (!FDecl->isInvalidDecl() && !FDecl->isUnnamedBitfield()) {
102+
if (!FDecl->isInvalidDecl() && !FDecl->isUnnamedBitField()) {
103103
State Result = analyzeFieldDecl(FDecl, Kind);
104104
if (Result == State::Throwing || Result == State::Unknown)
105105
return Result;

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,10 @@ Changes in existing checks
147147
<clang-tidy/checks/bugprone/assert-side-effect>` check by detecting side
148148
effect from calling a method with non-const reference parameters.
149149

150+
- Improved :doc:`bugprone-forwarding-reference-overload
151+
<clang-tidy/checks/bugprone/forwarding-reference-overload>`
152+
check to ignore deleted constructors which won't hide other overloads.
153+
150154
- Improved :doc:`bugprone-inc-dec-in-conditions
151155
<clang-tidy/checks/bugprone/inc-dec-in-conditions>` check to ignore code
152156
within unevaluated contexts, such as ``decltype``.

clang-tools-extra/test/clang-tidy/checkers/bugprone/forwarding-reference-overload.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,3 +251,13 @@ class Test10 {
251251
Test10(T &&Item, E e)
252252
: e(e){}
253253
};
254+
255+
// A deleted ctor cannot hide anything
256+
class Test11 {
257+
public:
258+
template <typename T>
259+
Test11(T&&) = delete;
260+
261+
Test11(const Test11 &) = default;
262+
Test11(Test11 &&) = default;
263+
};

clang/docs/ReleaseNotes.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,9 @@ Attribute Changes in Clang
287287
This allows the ``_Nullable`` and ``_Nonnull`` family of type attributes to
288288
apply to this class.
289289

290+
- Clang now warns that the ``exclude_from_explicit_instantiation`` attribute
291+
is ignored when applied to a local class or a member thereof.
292+
290293
Improvements to Clang's diagnostics
291294
-----------------------------------
292295
- Clang now applies syntax highlighting to the code snippets it
@@ -536,6 +539,8 @@ Bug Fixes to C++ Support
536539
Fixes (#GH70604), (#GH79754), (#GH84163), (#GH84425), (#GH86054), (#GH86398), and (#GH86399).
537540
- Fix a crash when deducing ``auto`` from an invalid dereference (#GH88329).
538541
- Fix a crash in requires expression with templated base class member function. Fixes (#GH84020).
542+
- Fix a crash caused by defined struct in a type alias template when the structure
543+
has fields with dependent type. Fixes (#GH75221).
539544

540545
Bug Fixes to AST Handling
541546
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/docs/StandardCPlusPlusModules.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,13 @@ violations with the flag enabled.
483483
ABI Impacts
484484
-----------
485485

486+
This section describes the new ABI changes brought by modules.
487+
488+
Only Itanium C++ ABI related change are mentioned
489+
490+
Mangling Names
491+
~~~~~~~~~~~~~~
492+
486493
The declarations in a module unit which are not in the global module fragment have new linkage names.
487494

488495
For example,
@@ -520,6 +527,23 @@ is attached to the global module fragments. For example:
520527

521528
Now the linkage name of ``NS::foo()`` will be ``_ZN2NS3fooEv``.
522529

530+
Module Initializers
531+
~~~~~~~~~~~~~~~~~~~
532+
533+
All the importable module units are required to emit an initializer function.
534+
The initializer function should contain calls to importing modules first and
535+
all the dynamic-initializers in the current module unit then.
536+
537+
Translation units explicitly or implicitly importing named modules must call
538+
the initializer functions of the imported named modules within the sequence of
539+
the dynamic-initializers in the TU. Initializations of entities at namespace
540+
scope are appearance-ordered. This (recursively) extends into imported modules
541+
at the point of appearance of the import declaration.
542+
543+
It is allowed to omit calls to importing modules if it is known empty.
544+
545+
It is allowed to omit calls to importing modules for which is known to be called.
546+
523547
Reduced BMI
524548
-----------
525549

clang/include/clang/AST/ASTMutationListener.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ namespace clang {
2727
class FunctionTemplateDecl;
2828
class Module;
2929
class NamedDecl;
30+
class NamespaceDecl;
3031
class ObjCCategoryDecl;
3132
class ObjCContainerDecl;
3233
class ObjCInterfaceDecl;
@@ -35,6 +36,7 @@ namespace clang {
3536
class QualType;
3637
class RecordDecl;
3738
class TagDecl;
39+
class TranslationUnitDecl;
3840
class ValueDecl;
3941
class VarDecl;
4042
class VarTemplateDecl;
@@ -147,6 +149,31 @@ class ASTMutationListener {
147149
virtual void AddedAttributeToRecord(const Attr *Attr,
148150
const RecordDecl *Record) {}
149151

152+
/// The parser find the named module declaration.
153+
virtual void EnteringModulePurview() {}
154+
155+
/// An mangling number was added to a Decl
156+
///
157+
/// \param D The decl that got a mangling number
158+
///
159+
/// \param Number The mangling number that was added to the Decl
160+
virtual void AddedManglingNumber(const Decl *D, unsigned Number) {}
161+
162+
/// An static local number was added to a Decl
163+
///
164+
/// \param D The decl that got a static local number
165+
///
166+
/// \param Number The static local number that was added to the Decl
167+
virtual void AddedStaticLocalNumbers(const Decl *D, unsigned Number) {}
168+
169+
/// An anonymous namespace was added the translation unit decl
170+
///
171+
/// \param TU The translation unit decl that got a new anonymous namespace
172+
///
173+
/// \param AnonNamespace The anonymous namespace that was added
174+
virtual void AddedAnonymousNamespace(const TranslationUnitDecl *TU,
175+
NamespaceDecl *AnonNamespace) {}
176+
150177
// NOTE: If new methods are added they should also be added to
151178
// MultiplexASTMutationListener.
152179
};

clang/include/clang/AST/Decl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class TranslationUnitDecl : public Decl,
120120
ASTContext &getASTContext() const { return Ctx; }
121121

122122
NamespaceDecl *getAnonymousNamespace() const { return AnonymousNamespace; }
123-
void setAnonymousNamespace(NamespaceDecl *D) { AnonymousNamespace = D; }
123+
void setAnonymousNamespace(NamespaceDecl *D);
124124

125125
static TranslationUnitDecl *Create(ASTContext &C);
126126

@@ -3149,7 +3149,7 @@ class FieldDecl : public DeclaratorDecl, public Mergeable<FieldDecl> {
31493149
bool isBitField() const { return BitField; }
31503150

31513151
/// Determines whether this is an unnamed bitfield.
3152-
bool isUnnamedBitfield() const { return isBitField() && !getDeclName(); }
3152+
bool isUnnamedBitField() const { return isBitField() && !getDeclName(); }
31533153

31543154
/// Determines whether this field is a
31553155
/// representative for an anonymous struct or union. Such fields are

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3669,6 +3669,9 @@ def warn_attribute_dllexport_explicit_instantiation_decl : Warning<
36693669
def warn_attribute_dllexport_explicit_instantiation_def : Warning<
36703670
"'dllexport' attribute ignored on explicit instantiation definition">,
36713671
InGroup<IgnoredAttributes>;
3672+
def warn_attribute_exclude_from_explicit_instantiation_local_class : Warning<
3673+
"%0 attribute ignored on local class%select{| member}1">,
3674+
InGroup<IgnoredAttributes>;
36723675
def warn_invalid_initializer_from_system_header : Warning<
36733676
"invalid constructor from class in system header, should not be explicit">,
36743677
InGroup<DiagGroup<"invalid-initializer-from-system-header">>;

clang/include/clang/Sema/Scope.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,9 @@ class Scope {
156156
/// This is the scope of an OpenACC Compute Construct, which restricts
157157
/// jumping into/out of it.
158158
OpenACCComputeConstructScope = 0x10000000,
159+
160+
/// This is a scope of type alias declaration.
161+
TypeAliasScope = 0x20000000,
159162
};
160163

161164
private:
@@ -580,6 +583,9 @@ class Scope {
580583
/// if/switch/while/for statement.
581584
bool isControlScope() const { return getFlags() & Scope::ControlScope; }
582585

586+
/// Determine whether this scope is a type alias scope.
587+
bool isTypeAliasScope() const { return getFlags() & Scope::TypeAliasScope; }
588+
583589
/// Returns if rhs has a higher scope depth than this.
584590
///
585591
/// The caller is responsible for calling this only if one of the two scopes

clang/include/clang/Serialization/ASTWriter.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,11 @@ class ASTWriter : public ASTDeserializationListener,
399399
/// record containing modifications to them.
400400
DeclUpdateMap DeclUpdates;
401401

402+
/// DeclUpdates added during parsing the GMF. We split these from
403+
/// DeclUpdates since we want to add these updates in GMF on need.
404+
/// Only meaningful for reduced BMI.
405+
DeclUpdateMap DeclUpdatesFromGMF;
406+
402407
using FirstLatestDeclMap = llvm::DenseMap<Decl *, Decl *>;
403408

404409
/// Map of first declarations from a chained PCH that point to the
@@ -554,6 +559,8 @@ class ASTWriter : public ASTDeserializationListener,
554559
void WriteIdentifierTable(Preprocessor &PP, IdentifierResolver &IdResolver,
555560
bool IsModule);
556561
void WriteDeclAndTypes(ASTContext &Context);
562+
void PrepareWritingSpecialDecls(Sema &SemaRef);
563+
void WriteSpecialDeclRecords(Sema &SemaRef);
557564
void WriteDeclUpdatesBlocks(RecordDataImpl &OffsetsRecord);
558565
void WriteDeclContextVisibleUpdate(const DeclContext *DC);
559566
void WriteFPPragmaOptions(const FPOptionsOverride &Opts);
@@ -707,6 +714,8 @@ class ASTWriter : public ASTDeserializationListener,
707714

708715
/// Emit a reference to a declaration.
709716
void AddDeclRef(const Decl *D, RecordDataImpl &Record);
717+
// Emit a reference to a declaration if the declaration was emitted.
718+
void AddEmittedDeclRef(const Decl *D, RecordDataImpl &Record);
710719

711720
/// Force a declaration to be emitted and get its ID.
712721
serialization::DeclID GetDeclRef(const Decl *D);
@@ -866,6 +875,11 @@ class ASTWriter : public ASTDeserializationListener,
866875
void RedefinedHiddenDefinition(const NamedDecl *D, Module *M) override;
867876
void AddedAttributeToRecord(const Attr *Attr,
868877
const RecordDecl *Record) override;
878+
void EnteringModulePurview() override;
879+
void AddedManglingNumber(const Decl *D, unsigned) override;
880+
void AddedStaticLocalNumbers(const Decl *D, unsigned) override;
881+
void AddedAnonymousNamespace(const TranslationUnitDecl *,
882+
NamespaceDecl *AnonNamespace) override;
869883
};
870884

871885
/// AST and semantic-analysis consumer that generates a

clang/lib/AST/APValue.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -908,7 +908,8 @@ void APValue::printPretty(raw_ostream &Out, const PrintingPolicy &Policy,
908908
for (const auto *FI : RD->fields()) {
909909
if (!First)
910910
Out << ", ";
911-
if (FI->isUnnamedBitfield()) continue;
911+
if (FI->isUnnamedBitField())
912+
continue;
912913
getStructField(FI->getFieldIndex()).
913914
printPretty(Out, Policy, FI->getType(), Ctx);
914915
First = false;

clang/lib/AST/ASTContext.cpp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2684,7 +2684,7 @@ getSubobjectSizeInBits(const FieldDecl *Field, const ASTContext &Context,
26842684
if (Field->isBitField()) {
26852685
// If we have explicit padding bits, they don't contribute bits
26862686
// to the actual object representation, so return 0.
2687-
if (Field->isUnnamedBitfield())
2687+
if (Field->isUnnamedBitField())
26882688
return 0;
26892689

26902690
int64_t BitfieldSize = Field->getBitWidthValue(Context);
@@ -12245,8 +12245,13 @@ QualType ASTContext::getRealTypeForBitwidth(unsigned DestWidth,
1224512245
}
1224612246

1224712247
void ASTContext::setManglingNumber(const NamedDecl *ND, unsigned Number) {
12248-
if (Number > 1)
12249-
MangleNumbers[ND] = Number;
12248+
if (Number <= 1)
12249+
return;
12250+
12251+
MangleNumbers[ND] = Number;
12252+
12253+
if (Listener)
12254+
Listener->AddedManglingNumber(ND, Number);
1225012255
}
1225112256

1225212257
unsigned ASTContext::getManglingNumber(const NamedDecl *ND,
@@ -12265,8 +12270,13 @@ unsigned ASTContext::getManglingNumber(const NamedDecl *ND,
1226512270
}
1226612271

1226712272
void ASTContext::setStaticLocalNumber(const VarDecl *VD, unsigned Number) {
12268-
if (Number > 1)
12269-
StaticLocalNumbers[VD] = Number;
12273+
if (Number <= 1)
12274+
return;
12275+
12276+
StaticLocalNumbers[VD] = Number;
12277+
12278+
if (Listener)
12279+
Listener->AddedStaticLocalNumbers(VD, Number);
1227012280
}
1227112281

1227212282
unsigned ASTContext::getStaticLocalNumber(const VarDecl *VD) const {

0 commit comments

Comments
 (0)