Skip to content

Commit b86dab6

Browse files
Merge branch 'main' into fix_regbank_fabs
2 parents 6f2a059 + ba84d0c commit b86dab6

File tree

315 files changed

+6538
-4023
lines changed

Some content is hidden

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

315 files changed

+6538
-4023
lines changed

.github/copilot-instructions.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
When performing a code review, pay close attention to code modifying a function's
2+
control flow. Could the change result in the corruption of performance profile
3+
data? Could the change result in invalid debug information, in particular for
4+
branches and calls?

clang-tools-extra/test/clang-doc/json/class.cpp

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ struct MyClass {
2323
typedef int MyTypedef;
2424

2525
class NestedClass;
26+
27+
friend struct Foo;
28+
template<typename T> friend void friendFunction(int);
2629
protected:
2730
int protectedMethod();
2831

@@ -86,6 +89,44 @@ struct MyClass {
8689
// CHECK-NEXT: "USR": "{{[0-9A-F]*}}"
8790
// CHECK-NEXT: }
8891
// CHECK-NEXT: ],
92+
// CHECK-NOT: "Friends": [
93+
// CHECK-NOT: {
94+
// CHECK-NOT: "IsClass": false,
95+
// CHECK-NOT: "Params": [
96+
// CHECK-NOT: {
97+
// CHECK-NOT: "Name": "",
98+
// CHECK-NOT: "Type": "int"
99+
// CHECK-NOT: }
100+
// CHECK-NOT: ],
101+
// CHECK-NOT: "Reference": {
102+
// CHECK-NOT: "Name": "friendFunction",
103+
// CHECK-NOT: "Path": "",
104+
// CHECK-NOT: "QualName": "friendFunction",
105+
// CHECK-NOT: "USR": "{{[0-9A-F]*}}"
106+
// CHECK-NOT: },
107+
// CHECK-NOT: "ReturnType": {
108+
// CHECK-NOT: "IsBuiltIn": true,
109+
// CHECK-NOT: "IsTemplate": false,
110+
// CHECK-NOT: "Name": "void",
111+
// CHECK-NOT: "QualName": "void",
112+
// CHECK-NOT: "USR": "0000000000000000000000000000000000000000"
113+
// CHECK-NOT: },
114+
// CHECK-NOT: "Template": {
115+
// CHECK-NOT: "Parameters": [
116+
// CHECK-NOT: "typename T"
117+
// CHECK-NOT: ]
118+
// CHECK-NOT: }
119+
// CHECK-NOT: },
120+
// CHECK-NOT: {
121+
// CHECK-NOT: "IsClass": true,
122+
// CHECK-NOT: "Reference": {
123+
// CHECK-NOT: "Name": "Foo",
124+
// CHECK-NOT: "Path": "GlobalNamespace",
125+
// CHECK-NOT: "QualName": "Foo",
126+
// CHECK-NOT: "USR": "{{[0-9A-F]*}}"
127+
// CHECK-NOT: },
128+
// CHECK-NOT: },
129+
// CHECK-NOT: ],
89130
// COM: FIXME: FullName is not emitted correctly.
90131
// CHECK-NEXT: "FullName": "",
91132
// CHECK-NEXT: "IsTypedef": false,

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -655,9 +655,6 @@ Improvements to Clang's diagnostics
655655
#GH69470, #GH59391, #GH58172, #GH46215, #GH45915, #GH45891, #GH44490,
656656
#GH36703, #GH32903, #GH23312, #GH69874.
657657

658-
- A warning is now emitted when ``main`` is attached to a named module,
659-
which can be turned off with ``-Wno-main-attached-to-named-module``. (#GH146247)
660-
661658
- Clang now avoids issuing `-Wreturn-type` warnings in some cases where
662659
the final statement of a non-void function is a `throw` expression, or
663660
a call to a function that is trivially known to always throw (i.e., its
@@ -901,7 +898,9 @@ Bug Fixes to AST Handling
901898
- Fixed a malformed printout of ``CXXParenListInitExpr`` in certain contexts.
902899
- Fixed a malformed printout of certain calling convention function attributes. (#GH143160)
903900
- Fixed dependency calculation for TypedefTypes (#GH89774)
901+
- The ODR checker now correctly hashes the names of conversion operators. (#GH143152)
904902
- Fixed the right parenthesis source location of ``CXXTemporaryObjectExpr``. (#GH143711)
903+
- Fixed a crash when performing an ``IgnoreUnlessSpelledInSource`` traversal of ASTs containing ``catch(...)`` statements. (#GH146103)
905904

906905
Miscellaneous Bug Fixes
907906
^^^^^^^^^^^^^^^^^^^^^^^

clang/include/clang/AST/ASTNodeTraverser.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class ASTNodeTraverser
9999
TraversalKind GetTraversalKind() const { return Traversal; }
100100

101101
void Visit(const Decl *D, bool VisitLocs = false) {
102-
if (Traversal == TK_IgnoreUnlessSpelledInSource && D->isImplicit())
102+
if (Traversal == TK_IgnoreUnlessSpelledInSource && D && D->isImplicit())
103103
return;
104104

105105
getNodeDelegate().AddChild([=] {

clang/include/clang/AST/ODRHash.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,13 @@ class ODRHash {
9696
void AddNestedNameSpecifier(const NestedNameSpecifier *NNS);
9797
void AddDependentTemplateName(const DependentTemplateStorage &Name);
9898
void AddTemplateName(TemplateName Name);
99-
void AddDeclarationName(DeclarationName Name, bool TreatAsDecl = false);
99+
void AddDeclarationNameInfo(DeclarationNameInfo NameInfo,
100+
bool TreatAsDecl = false);
101+
void AddDeclarationName(DeclarationName Name, bool TreatAsDecl = false) {
102+
AddDeclarationNameInfo(DeclarationNameInfo(Name, SourceLocation()),
103+
TreatAsDecl);
104+
}
105+
100106
void AddTemplateArgument(TemplateArgument TA);
101107
void AddTemplateParameterList(const TemplateParameterList *TPL);
102108

@@ -108,7 +114,7 @@ class ODRHash {
108114
static bool isSubDeclToBeProcessed(const Decl *D, const DeclContext *Parent);
109115

110116
private:
111-
void AddDeclarationNameImpl(DeclarationName Name);
117+
void AddDeclarationNameInfoImpl(DeclarationNameInfo NameInfo);
112118
};
113119

114120
} // end namespace clang

clang/include/clang/AST/OpenMPClause.h

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,8 @@ template <class T> class OMPVarListClause : public OMPClause {
295295

296296
/// Fetches list of variables associated with this clause.
297297
MutableArrayRef<Expr *> getVarRefs() {
298-
return static_cast<T *>(this)->template getTrailingObjects<Expr *>(NumVars);
298+
return static_cast<T *>(this)->template getTrailingObjectsNonStrict<Expr *>(
299+
NumVars);
299300
}
300301

301302
/// Sets the list of variables for this clause.
@@ -334,8 +335,8 @@ template <class T> class OMPVarListClause : public OMPClause {
334335

335336
/// Fetches list of all variables in the clause.
336337
ArrayRef<const Expr *> getVarRefs() const {
337-
return static_cast<const T *>(this)->template getTrailingObjects<Expr *>(
338-
NumVars);
338+
return static_cast<const T *>(this)
339+
->template getTrailingObjectsNonStrict<Expr *>(NumVars);
339340
}
340341
};
341342

@@ -380,7 +381,7 @@ template <class T> class OMPDirectiveListClause : public OMPClause {
380381

381382
MutableArrayRef<OpenMPDirectiveKind> getDirectiveKinds() {
382383
return static_cast<T *>(this)
383-
->template getTrailingObjects<OpenMPDirectiveKind>(NumKinds);
384+
->template getTrailingObjectsNonStrict<OpenMPDirectiveKind>(NumKinds);
384385
}
385386

386387
void setDirectiveKinds(ArrayRef<OpenMPDirectiveKind> DK) {
@@ -5921,15 +5922,17 @@ class OMPMappableExprListClause : public OMPVarListClause<T>,
59215922
/// Get the unique declarations that are in the trailing objects of the
59225923
/// class.
59235924
MutableArrayRef<ValueDecl *> getUniqueDeclsRef() {
5924-
return static_cast<T *>(this)->template getTrailingObjects<ValueDecl *>(
5925-
NumUniqueDeclarations);
5925+
return static_cast<T *>(this)
5926+
->template getTrailingObjectsNonStrict<ValueDecl *>(
5927+
NumUniqueDeclarations);
59265928
}
59275929

59285930
/// Get the unique declarations that are in the trailing objects of the
59295931
/// class.
59305932
ArrayRef<ValueDecl *> getUniqueDeclsRef() const {
59315933
return static_cast<const T *>(this)
5932-
->template getTrailingObjects<ValueDecl *>(NumUniqueDeclarations);
5934+
->template getTrailingObjectsNonStrict<ValueDecl *>(
5935+
NumUniqueDeclarations);
59335936
}
59345937

59355938
/// Set the unique declarations that are in the trailing objects of the
@@ -5943,15 +5946,15 @@ class OMPMappableExprListClause : public OMPVarListClause<T>,
59435946
/// Get the number of lists per declaration that are in the trailing
59445947
/// objects of the class.
59455948
MutableArrayRef<unsigned> getDeclNumListsRef() {
5946-
return static_cast<T *>(this)->template getTrailingObjects<unsigned>(
5947-
NumUniqueDeclarations);
5949+
return static_cast<T *>(this)
5950+
->template getTrailingObjectsNonStrict<unsigned>(NumUniqueDeclarations);
59485951
}
59495952

59505953
/// Get the number of lists per declaration that are in the trailing
59515954
/// objects of the class.
59525955
ArrayRef<unsigned> getDeclNumListsRef() const {
5953-
return static_cast<const T *>(this)->template getTrailingObjects<unsigned>(
5954-
NumUniqueDeclarations);
5956+
return static_cast<const T *>(this)
5957+
->template getTrailingObjectsNonStrict<unsigned>(NumUniqueDeclarations);
59555958
}
59565959

59575960
/// Set the number of lists per declaration that are in the trailing
@@ -5966,7 +5969,8 @@ class OMPMappableExprListClause : public OMPVarListClause<T>,
59665969
/// objects of the class. They are appended after the number of lists.
59675970
MutableArrayRef<unsigned> getComponentListSizesRef() {
59685971
return MutableArrayRef<unsigned>(
5969-
static_cast<T *>(this)->template getTrailingObjects<unsigned>() +
5972+
static_cast<T *>(this)
5973+
->template getTrailingObjectsNonStrict<unsigned>() +
59705974
NumUniqueDeclarations,
59715975
NumComponentLists);
59725976
}
@@ -5975,7 +5979,8 @@ class OMPMappableExprListClause : public OMPVarListClause<T>,
59755979
/// objects of the class. They are appended after the number of lists.
59765980
ArrayRef<unsigned> getComponentListSizesRef() const {
59775981
return ArrayRef<unsigned>(
5978-
static_cast<const T *>(this)->template getTrailingObjects<unsigned>() +
5982+
static_cast<const T *>(this)
5983+
->template getTrailingObjectsNonStrict<unsigned>() +
59795984
NumUniqueDeclarations,
59805985
NumComponentLists);
59815986
}
@@ -5991,13 +5996,15 @@ class OMPMappableExprListClause : public OMPVarListClause<T>,
59915996
/// Get the components that are in the trailing objects of the class.
59925997
MutableArrayRef<MappableComponent> getComponentsRef() {
59935998
return static_cast<T *>(this)
5994-
->template getTrailingObjects<MappableComponent>(NumComponents);
5999+
->template getTrailingObjectsNonStrict<MappableComponent>(
6000+
NumComponents);
59956001
}
59966002

59976003
/// Get the components that are in the trailing objects of the class.
59986004
ArrayRef<MappableComponent> getComponentsRef() const {
59996005
return static_cast<const T *>(this)
6000-
->template getTrailingObjects<MappableComponent>(NumComponents);
6006+
->template getTrailingObjectsNonStrict<MappableComponent>(
6007+
NumComponents);
60016008
}
60026009

60036010
/// Set the components that are in the trailing objects of the class.

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,10 +1062,6 @@ def err_constexpr_main : Error<
10621062
"'main' is not allowed to be declared %select{constexpr|consteval}0">;
10631063
def err_deleted_main : Error<"'main' is not allowed to be deleted">;
10641064
def err_mainlike_template_decl : Error<"%0 cannot be a template">;
1065-
def warn_main_in_named_module
1066-
: ExtWarn<"'main' should not be attached to a named module; consider "
1067-
"adding C++ language linkage">,
1068-
InGroup<DiagGroup<"main-attached-to-named-module">>;
10691065
def err_main_returns_nonint : Error<"'main' must return 'int'">;
10701066
def ext_main_returns_nonint : ExtWarn<"return type of 'main' is not 'int'">,
10711067
InGroup<MainReturnType>;

clang/include/clang/Basic/TargetInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1851,7 +1851,7 @@ class TargetInfo : public TransferrableTargetInfo,
18511851

18521852
/// Returns the version of the darwin target variant SDK which was used during
18531853
/// the compilation if one was specified, or an empty version otherwise.
1854-
const std::optional<VersionTuple> getDarwinTargetVariantSDKVersion() const {
1854+
std::optional<VersionTuple> getDarwinTargetVariantSDKVersion() const {
18551855
return !getTargetOpts().DarwinTargetVariantSDKVersion.empty()
18561856
? getTargetOpts().DarwinTargetVariantSDKVersion
18571857
: std::optional<VersionTuple>();

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4574,22 +4574,23 @@ VarCreationState Compiler<Emitter>::visitDecl(const VarDecl *VD,
45744574
template <class Emitter>
45754575
bool Compiler<Emitter>::visitDeclAndReturn(const VarDecl *VD,
45764576
bool ConstantContext) {
4577-
std::optional<PrimType> VarT = classify(VD->getType());
45784577

45794578
// We only create variables if we're evaluating in a constant context.
45804579
// Otherwise, just evaluate the initializer and return it.
45814580
if (!ConstantContext) {
45824581
DeclScope<Emitter> LS(this, VD);
4583-
if (!this->visit(VD->getAnyInitializer()))
4582+
const Expr *Init = VD->getInit();
4583+
if (!this->visit(Init))
45844584
return false;
4585-
return this->emitRet(VarT.value_or(PT_Ptr), VD) && LS.destroyLocals() &&
4586-
this->emitCheckAllocations(VD);
4585+
return this->emitRet(classify(Init).value_or(PT_Ptr), VD) &&
4586+
LS.destroyLocals() && this->emitCheckAllocations(VD);
45874587
}
45884588

45894589
LocalScope<Emitter> VDScope(this, VD);
45904590
if (!this->visitVarDecl(VD, /*Toplevel=*/true))
45914591
return false;
45924592

4593+
std::optional<PrimType> VarT = classify(VD->getType());
45934594
if (Context::shouldBeGloballyIndexed(VD)) {
45944595
auto GlobalIndex = P.getGlobal(VD);
45954596
assert(GlobalIndex); // visitVarDecl() didn't return false.

clang/lib/AST/ByteCode/Compiler.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -574,17 +574,17 @@ template <class Emitter> class LocalScope : public VariableScope<Emitter> {
574574
// Emit destructor calls for local variables of record
575575
// type with a destructor.
576576
for (Scope::Local &Local : llvm::reverse(this->Ctx->Descriptors[*Idx])) {
577-
if (!Local.Desc->isPrimitive() && !Local.Desc->isPrimitiveArray()) {
578-
if (!this->Ctx->emitGetPtrLocal(Local.Offset, E))
579-
return false;
577+
if (Local.Desc->hasTrivialDtor())
578+
continue;
579+
if (!this->Ctx->emitGetPtrLocal(Local.Offset, E))
580+
return false;
580581

581-
if (!this->Ctx->emitDestruction(Local.Desc, Local.Desc->getLoc()))
582-
return false;
582+
if (!this->Ctx->emitDestruction(Local.Desc, Local.Desc->getLoc()))
583+
return false;
583584

584-
if (!this->Ctx->emitPopPtr(E))
585-
return false;
586-
removeIfStoredOpaqueValue(Local);
587-
}
585+
if (!this->Ctx->emitPopPtr(E))
586+
return false;
587+
removeIfStoredOpaqueValue(Local);
588588
}
589589
return true;
590590
}

0 commit comments

Comments
 (0)